Implement structured H3 reference objects
This commit is contained in:
@@ -239,16 +239,13 @@ class DumasImageNodeTests(unittest.TestCase):
|
||||
saved_path = FakePILImage.saved_paths[0][0]
|
||||
self.assertTrue(os.path.isdir(os.path.dirname(saved_path)))
|
||||
|
||||
def test_character_helper_passes_through_images_and_formats_text(self):
|
||||
node = self.image_nodes.DumasCharacterHelperNode()
|
||||
image1 = FakeTensorBatch()
|
||||
image2 = FakeTensorBatch()
|
||||
def test_character_reference_builds_structured_reference(self):
|
||||
node = self.image_nodes.DumasCharacterReferenceNode()
|
||||
image = FakeTensorBatch()
|
||||
|
||||
result = node.build_character_text(
|
||||
image1=image1,
|
||||
image2=image2,
|
||||
image1_picture_id="2",
|
||||
image2_picture_id="3",
|
||||
result = node.build_reference(
|
||||
image=image,
|
||||
picture_id="2",
|
||||
character_id="char_dave",
|
||||
name="Dave",
|
||||
alias="The Locksmith",
|
||||
@@ -259,37 +256,46 @@ class DumasImageNodeTests(unittest.TestCase):
|
||||
height_feet="6",
|
||||
height_inches="2",
|
||||
accent="English",
|
||||
description="Square jaw, tired eyes, cropped brown hair.",
|
||||
general="wears a long grey coat",
|
||||
wardrobe="weathered red flight jacket, grey cargo shorts, black boots",
|
||||
)
|
||||
|
||||
self.assertIs(result[0], image1)
|
||||
self.assertIs(result[1], image2)
|
||||
reference = result[0]
|
||||
self.assertIs(reference["image"], image)
|
||||
self.assertEqual(
|
||||
result[2],
|
||||
(
|
||||
"<Picture 2> and <Picture 3> reference the same character who is called Dave.\n"
|
||||
"<Picture 2> is the primary full-body reference for Dave.\n"
|
||||
"<Picture 3> is a frontal facial reference for Dave.\n"
|
||||
"Dave is also known as The Locksmith, is male, is 41 years old, is English, works as a detective, is 6 feet 2 inches tall, speaks in an English accent.\n"
|
||||
"wears a long grey coat."
|
||||
),
|
||||
)
|
||||
self.assertEqual(
|
||||
result[3],
|
||||
"Dave = weathered red flight jacket, grey cargo shorts, black boots",
|
||||
reference,
|
||||
{
|
||||
"kind": "character",
|
||||
"id": "char-dave",
|
||||
"name": "Dave",
|
||||
"aliases": ["The Locksmith"],
|
||||
"picture_id": 2,
|
||||
"picture_label": "<Picture 2>",
|
||||
"image": image,
|
||||
"summary": "Dave shown in <Picture 2>.",
|
||||
"description": "Square jaw, tired eyes, cropped brown hair.",
|
||||
"wardrobe": "weathered red flight jacket, grey cargo shorts, black boots",
|
||||
"general": "wears a long grey coat",
|
||||
"facts": {
|
||||
"gender": "male",
|
||||
"age": "41",
|
||||
"nationality": "English",
|
||||
"occupation": "a detective",
|
||||
"height_feet": "6",
|
||||
"height_inches": "2",
|
||||
"accent": "English",
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
def test_character_helper_handles_missing_optional_fields(self):
|
||||
node = self.image_nodes.DumasCharacterHelperNode()
|
||||
image1 = FakeTensorBatch()
|
||||
image2 = FakeTensorBatch()
|
||||
def test_character_reference_handles_missing_optional_fields(self):
|
||||
node = self.image_nodes.DumasCharacterReferenceNode()
|
||||
image = FakeTensorBatch()
|
||||
|
||||
result = node.build_character_text(
|
||||
image1=image1,
|
||||
image2=image2,
|
||||
image1_picture_id="4",
|
||||
image2_picture_id="6",
|
||||
result = node.build_reference(
|
||||
image=image,
|
||||
picture_id="4",
|
||||
character_id="",
|
||||
name="",
|
||||
alias="",
|
||||
@@ -300,53 +306,50 @@ class DumasImageNodeTests(unittest.TestCase):
|
||||
height_feet="",
|
||||
height_inches="",
|
||||
accent="",
|
||||
description="",
|
||||
general="",
|
||||
wardrobe="",
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
result[2],
|
||||
(
|
||||
"<Picture 4> and <Picture 6> reference the same character.\n"
|
||||
"<Picture 4> is the primary full-body reference for the character.\n"
|
||||
"<Picture 6> is a frontal facial reference for the character."
|
||||
),
|
||||
)
|
||||
self.assertEqual(result[3], "")
|
||||
reference = result[0]
|
||||
self.assertEqual(reference["kind"], "character")
|
||||
self.assertEqual(reference["picture_id"], 4)
|
||||
self.assertEqual(reference["picture_label"], "<Picture 4>")
|
||||
self.assertEqual(reference["wardrobe"], "")
|
||||
self.assertEqual(reference["general"], "")
|
||||
self.assertEqual(reference["facts"]["age"], "")
|
||||
|
||||
def test_character_helper_allows_picture_one_and_preserves_full_sheet_wardrobe(self):
|
||||
node = self.image_nodes.DumasCharacterHelperNode()
|
||||
image1 = FakeTensorBatch()
|
||||
image2 = FakeTensorBatch()
|
||||
def test_location_reference_builds_structured_reference(self):
|
||||
node = self.image_nodes.DumasLocationReferenceNode()
|
||||
image = FakeTensorBatch()
|
||||
|
||||
result = node.build_character_text(
|
||||
image1=image1,
|
||||
image2=image2,
|
||||
image1_picture_id="1",
|
||||
image2_picture_id="9",
|
||||
character_id="char_kristy",
|
||||
name="Kristy",
|
||||
alias="",
|
||||
gender="",
|
||||
age="",
|
||||
nationality="",
|
||||
occupation="",
|
||||
height_feet="",
|
||||
height_inches="",
|
||||
accent="",
|
||||
general="",
|
||||
wardrobe="Kristy = black coat, silver boots",
|
||||
result = node.build_reference(
|
||||
image=image,
|
||||
picture_id="9",
|
||||
location_id="coffee-shop-01",
|
||||
name="Coffee Shop",
|
||||
alias="Cafe Interior",
|
||||
description="Warm tungsten lighting, narrow counter, rainy front window.",
|
||||
general="Evening ambience, cramped but cozy.",
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
result[2],
|
||||
(
|
||||
"<Picture 1> and <Picture 9> reference the same character who is called Kristy.\n"
|
||||
"<Picture 1> is the primary full-body reference for Kristy.\n"
|
||||
"<Picture 9> is a frontal facial reference for Kristy."
|
||||
),
|
||||
result[0],
|
||||
{
|
||||
"kind": "location",
|
||||
"id": "coffee-shop-01",
|
||||
"name": "Coffee Shop",
|
||||
"aliases": ["Cafe Interior"],
|
||||
"picture_id": 9,
|
||||
"picture_label": "<Picture 9>",
|
||||
"image": image,
|
||||
"summary": "Coffee Shop shown in <Picture 9>.",
|
||||
"description": "Warm tungsten lighting, narrow counter, rainy front window.",
|
||||
"wardrobe": "",
|
||||
"general": "Evening ambience, cramped but cozy.",
|
||||
"facts": {},
|
||||
},
|
||||
)
|
||||
self.assertEqual(result[3], "Kristy = black coat, silver boots")
|
||||
|
||||
def test_save_image_returns_ui_entries_for_output_folder(self):
|
||||
node = self.image_nodes.DumasSaveImageNode()
|
||||
|
||||
Reference in New Issue
Block a user