Skip to content

Commit

Permalink
Restructured the samples/ modules;
Browse files Browse the repository at this point in the history
  • Loading branch information
trystyncote committed Jan 14, 2024
1 parent d74131a commit 8b3e406
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 50 deletions.
23 changes: 13 additions & 10 deletions tests/samples/empty.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,13 @@ def get_current_directory():
return Path(__file__).absolute().parent


def data():
# Yes, I'm serious. This is equivalently 'default behaviour'.
metadata = scrivid.Metadata(
fps=12,
video_name="testSampleResult_\'empty\'",
window_size=(500, 500)
)
def ALL():
return INSTRUCTIONS(), METADATA()


def INSTRUCTIONS():
directory = get_current_directory().parent / "images"
instructions = [
return (
# This is a cheat to prevent the video from being one frame. Ideally,
# I'd just return an empty list or only have a list with an element
# that forces an extended length of the video.
Expand All @@ -30,6 +27,12 @@ def data():
),
scrivid.HideAdjustment("HIDDEN", 0),
scrivid.MoveAdjustment("HIDDEN", 1, scrivid.Properties(x=1), 11)
]
)

return instructions, metadata

def METADATA():
return scrivid.Metadata(
fps=12,
video_name="testSampleResult_\'empty\'",
window_size=(500, 500)
)
22 changes: 13 additions & 9 deletions tests/samples/figure_eight.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ def get_current_directory():
return Path(__file__).absolute().parent


def data():
metadata = scrivid.Metadata(
fps=12,
video_name="testSampleResult_\'figure_eight\'",
window_size=(1356, 856)
)
def ALL():
return INSTRUCTIONS(), METADATA()


def INSTRUCTIONS():
directory = get_current_directory().parent / "images"
instructions = [
return (
scrivid.create_image_reference(
"BLOCK",
directory / "img3.png",
Expand All @@ -30,6 +28,12 @@ def data():
scrivid.MoveAdjustment("BLOCK", 26, scrivid.Properties(x=-500, y=500), 10),
scrivid.MoveAdjustment("BLOCK", 36, scrivid.Properties(x=-250, y=-250), 5),
scrivid.MoveAdjustment("BLOCK", 41, scrivid.Properties(x=250, y=-250), 5)
]
)

return instructions, metadata

def METADATA():
return scrivid.Metadata(
fps=12,
video_name="testSampleResult_\'figure_eight\'",
window_size=(1356, 856)
)
22 changes: 13 additions & 9 deletions tests/samples/image_drawing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ def get_current_directory():
return Path(__file__).absolute().parent


def data():
metadata = scrivid.Metadata(
fps=12,
video_name="testSampleResult_\'image_drawing\'",
window_size=(660, 660)
)
def ALL():
return INSTRUCTIONS(), METADATA()


def INSTRUCTIONS():
directory = get_current_directory().parent / "images"
instructions = [
return (
scrivid.create_image_reference(
"TL",
directory / "img1.png",
Expand Down Expand Up @@ -63,6 +61,12 @@ def data():
),
scrivid.HideAdjustment("HIDDEN", 0),
scrivid.ShowAdjustment("HIDDEN", 20)
]
)

return instructions, metadata

def METADATA():
return scrivid.Metadata(
fps=12,
video_name="testSampleResult_\'image_drawing\'",
window_size=(660, 660)
)
22 changes: 13 additions & 9 deletions tests/samples/overlap.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ def get_current_directory():
return Path(__file__).absolute().parent


def data():
metadata = scrivid.Metadata(
fps=12,
video_name="testSampleResult_\'overlap\'",
window_size=(410, 410)
)
def ALL():
return INSTRUCTIONS(), METADATA()


def INSTRUCTIONS():
directory = get_current_directory().parent / "images"
instructions = [
return (
scrivid.create_image_reference(
"LEFT",
directory / "img2.png",
Expand All @@ -33,6 +31,12 @@ def data():
y=100
),
scrivid.MoveAdjustment("RIGHT", 12, scrivid.Properties(x=0), 1)
]
)

return instructions, metadata

def METADATA():
return scrivid.Metadata(
fps=12,
video_name="testSampleResult_\'overlap\'",
window_size=(410, 410)
)
22 changes: 13 additions & 9 deletions tests/samples/slide.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ def get_current_directory():
return Path(__file__).absolute().parent


def data():
metadata = scrivid.Metadata(
fps=12,
video_name="testSampleResult_\'slide\'",
window_size=(600, 306)
)
def ALL():
return INSTRUCTIONS(), METADATA()


def INSTRUCTIONS():
directory = get_current_directory().parent / "images"
instructions = [
return (
scrivid.create_image_reference(
"stone",
directory / "img2.png",
Expand All @@ -25,6 +23,12 @@ def data():
y=20
),
scrivid.MoveAdjustment("stone", 1, scrivid.Properties(x=500), 36)
]
)

return instructions, metadata

def METADATA():
return scrivid.Metadata(
fps=12,
video_name="testSampleResult_\'slide\'",
window_size=(600, 306)
)
6 changes: 3 additions & 3 deletions tests/test_motion_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_dump(indent, sample_module, expected_string_raw):
.replace(r"{\b}", "\n" if indent else "")
)

instructions, _ = sample_module.data()
instructions = sample_module.INSTRUCTIONS()
parsed_motion_tree = motion_tree.parse(instructions)

actual = motion_tree.dump(parsed_motion_tree, indent=indent)
Expand Down Expand Up @@ -138,7 +138,7 @@ def test_nodes_inheritance(node_cls, args):
@categorize(category="motion_tree")
@pytest_parametrize("sample_module", [empty, figure_eight, image_drawing])
def test_parse(sample_module):
instructions, _ = sample_module.data()
instructions = sample_module.INSTRUCTIONS()
motion_tree.parse(instructions)


Expand Down Expand Up @@ -172,7 +172,7 @@ def test_parse_duplicate_id():
motion_tree.InvokePrevious, motion_tree.End])
])
def test_walk(sample_module, expected_node_order):
instructions, _ = sample_module.data()
instructions = sample_module.INSTRUCTIONS()
parsed_motion_tree = motion_tree.parse(instructions)
for actual, expected_node in zip(motion_tree.walk(parsed_motion_tree), expected_node_order):
actual_node = type(actual)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_videos.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __exit__(self, *_):
(slide, "slide")
])
def test_compile_video_output(temp_dir, sample_function, sample_module_name):
instructions, metadata = sample_function.data()
instructions, metadata = sample_function.ALL()
metadata.save_location = temp_dir
scrivid.compile_video(instructions, metadata)

Expand Down

0 comments on commit 8b3e406

Please sign in to comment.