def test_project_already_has_a_shot_with_the_same_code(self): """testing if a ValueError will be raised when the given project argument already has a shot with the same code """ # lets try to assign the shot to the same sequence2 which has another # shot with the same code assert self.kwargs['code'] == self.test_shot.code with pytest.raises(ValueError) as cm: Shot(**self.kwargs) assert str(cm.value) == 'There is a Shot with the same code: SH123' # this should not raise a ValueError self.kwargs["code"] = "DifferentCode" new_shot2 = Shot(**self.kwargs) assert isinstance(new_shot2, Shot)
def test_sequences_attribute_is_working_properly(self): """testing if the sequences attribute is working properly """ self.kwargs['code'] = 'NewShot' from stalker import Sequence seq1 = Sequence( name='seq1', code='seq1', project=self.test_project1, ) seq2 = Sequence( name='seq2', code='seq2', project=self.test_project1, ) seq3 = Sequence( name='seq3', code='seq3', project=self.test_project1, ) new_shot = Shot(**self.kwargs) new_shot.sequences = [seq1] new_shot.sequences.append(seq2) new_shot.sequences.append(seq3) seqs = [seq1, seq2, seq3] assert \ sorted(new_shot.sequences, key=lambda x: x.name) == \ sorted(seqs, key=lambda x: x.name)
def test_ReferenceMixin_initialization(self): """testing if the ReferenceMixin part is initialized correctly """ link_type_1 = Type(name="Image", code='image', target_entity_type="Link") link1 = Link(name="Artwork 1", full_path="/mnt/M/JOBs/TEST_PROJECT", filename="a.jpg", type=link_type_1) link2 = Link(name="Artwork 2", full_path="/mnt/M/JOBs/TEST_PROJECT", filename="b.jbg", type=link_type_1) references = [link1, link2] self.kwargs["code"] = "SH12314" self.kwargs["references"] = references new_shot = Shot(**self.kwargs) self.assertEqual(new_shot.references, references)
def test_sequences_attribute_is_working_properly(self): """testing if the sequences attribute is working properly """ self.kwargs['code'] = 'NewShot' seq1 = Sequence(name='seq1', code='seq1', project=self.test_project1, status_list=self.test_sequence_status_list) seq2 = Sequence(name='seq2', code='seq2', project=self.test_project1, status_list=self.test_sequence_status_list) seq3 = Sequence(name='seq3', code='seq3', project=self.test_project1, status_list=self.test_sequence_status_list) new_shot = Shot(**self.kwargs) new_shot.sequences = [seq1] new_shot.sequences.append(seq2) new_shot.sequences.append(seq3) seqs = [seq1, seq2, seq3] self.assertEqual(sorted(new_shot.sequences, key=lambda x: x.name), sorted(seqs, key=lambda x: x.name))
def test_scenes_argument_is_skipped(self): """testing if the scenes attribute will be an empty list when the scenes argument is skipped """ self.kwargs.pop('scenes') self.kwargs['code'] = 'DifferentCode' new_shot = Shot(**self.kwargs) assert new_shot.scenes == []
def test_image_format_argument_is_None(self): """testing if the image format is copied from the Project instance when the image_format argument is None """ self.kwargs['image_format'] = None self.kwargs['code'] = 'newShot' new_shot = Shot(**self.kwargs) assert new_shot.image_format == self.kwargs['project'].image_format
def test_image_format_argument_is_skipped(self): """testing if the image_format is copied from the Project instance when the image_format argument is skipped """ self.kwargs.pop('image_format') self.kwargs['code'] = 'TestShot' new_shot = Shot(**self.kwargs) assert new_shot.image_format == self.kwargs['project'].image_format
def test_sequences_argument_is_None(self): """testing if the sequences attribute will be an empty list when the sequences argument is set to None """ self.kwargs['sequences'] = None self.kwargs['code'] = 'NewCode' new_shot = Shot(**self.kwargs) self.assertEqual(new_shot.sequences, [])
def test_scenes_argument_is_None(self): """testing if the scenes attribute will be an empty list when the scenes argument is set to None """ self.kwargs['scenes'] = None self.kwargs['code'] = 'NewCode' new_shot = Shot(**self.kwargs) assert new_shot.scenes == []
def test_source_out_argument_is_skipped(self): """testing if the source_out attribute will be equal to cut_out argument value when the source_out argument is skipped """ self.kwargs["code"] = "SH123A" self.kwargs.pop("source_out") new_shot = Shot(**self.kwargs) assert new_shot.source_out == new_shot.cut_out
def test_source_in_argument_is_none(self): """testing if the source_in attribute value will be equal to the cut_in attribute value when the source_in argument is None """ self.kwargs["code"] = "SH123A" self.kwargs["source_in"] = None shot = Shot(**self.kwargs) assert shot.source_in == shot.cut_in
def test_fps_attribute_is_set_to_None(self): """testing if the Project.fps will be used if the fps argument is None """ self.kwargs["fps"] = None self.kwargs['code'] = 'SHnew' new_shot = Shot(**self.kwargs) assert new_shot.fps == self.test_project1.fps
def test_source_in_argument_is_skipped(self): """testing if the source_in argument is skipped the source_in argument will be equal to cut_in attribute value """ self.kwargs["code"] = "SH123A" self.kwargs.pop('source_in') shot = Shot(**self.kwargs) assert shot.source_in == shot.cut_in
def test_sequences_argument_is_skipped(self): """testing if the sequences attribute will be an empty list when the sequences argument is skipped """ self.kwargs.pop('sequences') self.kwargs['code'] = 'DifferentCode' new_shot = Shot(**self.kwargs) self.assertEqual(new_shot.sequences, [])
def test_source_out_argument_is_none(self): """testing if the source_out attribute value will be equal to cut_out if the source_out argument value is None """ self.kwargs["code"] = "SH123A" self.kwargs["source_out"] = None shot = Shot(**self.kwargs) assert shot.source_out == shot.cut_out
def test_fps_argument_is_skipped(self): """testing if the default value will be used when fps is skipped """ if 'fps' in self.kwargs: self.kwargs.pop("fps") self.kwargs['code'] = 'SHnew' new_shot = Shot(**self.kwargs) assert new_shot.fps == self.test_project1.fps
def test_fps_argument_is_zero(self): """testing if a ValueError will be raised when the fps is 0 """ self.kwargs['fps'] = 0 self.kwargs['code'] = 'SHnew' with pytest.raises(ValueError) as cm: Shot(**self.kwargs) assert str(cm.value) == \ 'Shot.fps should be a positive float or int, not 0.0'
def test_fps_attribute_float_conversion(self): """testing if the fps attribute is converted to float when the float argument is given as an integer """ test_value = 1 self.kwargs["fps"] = test_value self.kwargs['code'] = 'SHnew' new_shot = Shot(**self.kwargs) assert isinstance(new_shot.fps, float) assert new_shot.fps == float(test_value)
def test_source_out_argument_is_not_integer(self): """testing if a TypeError will be raised when the source_out argument is not an integer """ self.kwargs["code"] = "SH123A" self.kwargs["source_out"] = "a string" with pytest.raises(TypeError) as cm: Shot(**self.kwargs) assert str(cm.value) == 'Shot.source_out should be an int, not str'
def test_fps_argument_is_negative(self): """testing if a ValueError will be raised when the fps argument is negative """ self.kwargs['fps'] = -1.0 self.kwargs['code'] = 'SHrandom' with pytest.raises(ValueError) as cm: Shot(**self.kwargs) assert str(cm.value) == \ 'Shot.fps should be a positive float or int, not -1.0'
def test_scenes_argument_is_not_a_list(self): """testing if a TypeError will be raised when the scenes argument is not a list """ self.kwargs['scenes'] = 'not a list' self.kwargs['code'] = 'NewCode' with pytest.raises(TypeError) as cm: Shot(**self.kwargs) assert str(cm.value) == \ 'Incompatible collection type: str is not list-like'
def test_cut_in_argument_is_skipped(self): """testing if the cut_in argument is skipped the cut_in argument will be calculated from cut_out argument """ self.kwargs["code"] = "SH123A" self.kwargs.pop("cut_in") self.kwargs['source_in'] = None self.kwargs['source_out'] = None new_shot = Shot(**self.kwargs) self.assertEqual(new_shot.cut_out, self.kwargs['cut_out']) self.assertEqual(new_shot.cut_in, new_shot.cut_out)
def test_source_out_argument_is_not_integer(self): """testing if a TypeError will be raised when the source_out argument is not an integer """ self.kwargs["code"] = "SH123A" self.kwargs["source_out"] = "a string" with self.assertRaises(TypeError) as cm: Shot(**self.kwargs) self.assertEqual(str(cm.exception), 'Shot.source_out should be an int, not str')
def test_equality(self): """testing equality of shot objects """ self.kwargs["code"] = "SH123A" new_shot1 = Shot(**self.kwargs) self.kwargs["project"] = self.test_project2 new_shot2 = Shot(**self.kwargs) # an entity with the same parameters # just set the name to the code too self.kwargs["name"] = self.kwargs["code"] new_entity = Entity(**self.kwargs) # another shot with different code self.kwargs["code"] = "SHAnotherShot" new_shot3 = Shot(**self.kwargs) self.assertFalse(new_shot1 == new_shot2) self.assertFalse(new_shot1 == new_entity) self.assertFalse(new_shot1 == new_shot3)
def test_cut_out_argument_is_smaller_than_cut_in_argument(self): """testing if the cut_out attribute is updated when the cut_out argument is smaller than cut_in argument """ self.kwargs["code"] = "SH123A" self.kwargs["cut_out"] = self.kwargs["cut_in"] - 10 self.kwargs['source_in'] = None self.kwargs['source_out'] = None shot = Shot(**self.kwargs) assert shot.cut_in == 102 assert shot.cut_out == 102
def test_cut_out_argument_is_skipped(self): """testing if the cut_out attribute will be calculated from cut_in argument value when the cut_out argument is skipped """ self.kwargs["code"] = "SH123A" self.kwargs.pop("cut_out") self.kwargs['source_in'] = None self.kwargs['source_out'] = None new_shot = Shot(**self.kwargs) assert new_shot.cut_in == self.kwargs['cut_in'] assert new_shot.cut_out == new_shot.cut_in
def test_cut_in_argument_is_bigger_than_cut_out_argument(self): """testing if a cut_out will be offset when the cut_in argument value is bigger than the cut_out argument value """ self.kwargs["code"] = "SH123A" self.kwargs["cut_in"] = self.kwargs["cut_out"] + 10 self.kwargs['source_in'] = None self.kwargs['source_out'] = None shot = Shot(**self.kwargs) assert shot.cut_in == 149 assert shot.cut_out == 149
def test_cut_in_argument_is_not_integer(self): """testing if a TypeError will be raised if the cut_in argument is not an instance of int """ self.kwargs["code"] = "SH123A" self.kwargs["cut_in"] = "a string" with pytest.raises(TypeError) as cm: Shot(**self.kwargs) assert str(cm.value) == 'Shot.cut_in should be an int, not str'
def test_cut_in_argument_is_none(self): """testing if the cut_in attribute value will be calculated from the cut_out attribute value if the cut_in argument is None """ self.kwargs["code"] = "SH123A" self.kwargs["cut_in"] = None self.kwargs['source_in'] = None self.kwargs['source_out'] = None shot = Shot(**self.kwargs) assert shot.cut_out == self.kwargs['cut_out'] assert shot.cut_in == shot.cut_out
def test_inequality(self): """testing inequality of shot objects """ self.kwargs['code'] = 'SH123A' new_shot1 = Shot(**self.kwargs) self.kwargs['project'] = self.test_project2 new_shot2 = Shot(**self.kwargs) # an entity with the same parameters # just set the name to the code too self.kwargs['name'] = self.kwargs['code'] new_entity = Entity(**self.kwargs) # another shot with different code self.kwargs['code'] = 'SHAnotherShot' new_shot3 = Shot(**self.kwargs) self.assertTrue(new_shot1 != new_shot2) self.assertTrue(new_shot1 != new_entity) self.assertTrue(new_shot1 != new_shot3)