예제 #1
0
 def test_deleting_a_shot_will_not_delete_the_other_shots_in_the_related_sequence(self):
     """testing if deleting a shot will not delete the other shots in the
     sequence
     """
     proj1 = Project('test project 1')
     proj1.save()
     
     seq1 = Sequence(proj1, 'test seq 1')
     seq1.save()
     
     shot1 = Shot(seq1, 1)
     shot1.save()
     
     shot2 = Shot(seq1, 2)
     shot2.save()
     
     # check if they are in the session
     self.assertIn(proj1, db.session)
     self.assertIn(seq1, db.session)
     self.assertIn(shot1, db.session)
     self.assertIn(shot2, db.session)
     
     # delete the shot
     db.session.delete(shot1)
     db.session.commit()
     
     self.assertNotIn(shot1, db.session)
     self.assertIn(shot2, db.session)
예제 #2
0
 def test_deleting_an_asset_will_not_delete_the_other_assets_in_the_related_project(self):
     """testing if deleting an asset will not delete the other assets in the
     related project
     """
     proj1 = Project('test project 1')
     proj1.save()
     
     asset1 = Asset(proj1, 'test asset 1')
     asset1.save()
     
     asset2 = Asset(proj1, 'test asset 2')
     asset2.save()
     
     asset3 = Asset(proj1, 'test asset 3')
     asset3.save()
     
     # check if they are properly in the db.session
     self.assertIn(proj1, db.session)
     self.assertIn(asset1, db.session)
     self.assertIn(asset2, db.session)
     self.assertIn(asset3, db.session)
     
     # delete asset1
     db.session.delete(asset1)
     db.session.commit()
     
     # check if the asset1 is deleted
     self.assertNotIn(asset1, db.session)
     
     # and the others are in place
     self.assertIn(proj1, db.session)
     self.assertIn(asset2, db.session)
     self.assertIn(asset3, db.session)
예제 #3
0
    def test_deleting_an_asset_will_not_delete_the_other_assets_in_the_related_project(
            self):
        """testing if deleting an asset will not delete the other assets in the
        related project
        """
        proj1 = Project('test project 1')
        proj1.save()

        asset1 = Asset(proj1, 'test asset 1')
        asset1.save()

        asset2 = Asset(proj1, 'test asset 2')
        asset2.save()

        asset3 = Asset(proj1, 'test asset 3')
        asset3.save()

        # check if they are properly in the db.session
        self.assertIn(proj1, db.session)
        self.assertIn(asset1, db.session)
        self.assertIn(asset2, db.session)
        self.assertIn(asset3, db.session)

        # delete asset1
        db.session.delete(asset1)
        db.session.commit()

        # check if the asset1 is deleted
        self.assertNotIn(asset1, db.session)

        # and the others are in place
        self.assertIn(proj1, db.session)
        self.assertIn(asset2, db.session)
        self.assertIn(asset3, db.session)
예제 #4
0
 def test_client_attribute_is_None(self):
     """testing if the client attribute is set to None will not cause any
     error
     """
     new_client = Client(name="Test Client")
     new_proj = Project(name="Test Project", client=new_client)
     new_proj.client = None
     self.assertEqual(None, new_proj.client)
예제 #5
0
 def test_shot_number_prefix_attribute_initialization(self):
     """testing the shot_number_prefix attribute is initialized correctly
     for a newly created Project instance
     """
     new_proj = Project("TEST_PROJECT")
     new_proj.create()
     
     self.assertEqual(new_proj.shot_number_prefix, conf.shot_number_prefix)
예제 #6
0
 def test_client_attribute_is_None(self):
     """testing if the client attribute is set to None will not cause any
     error
     """
     new_client = Client(name="Test Client")
     new_proj = Project(name="Test Project", client=new_client)
     new_proj.client = None
     self.assertEqual(None, new_proj.client)
예제 #7
0
    def test_shot_number_prefix_attribute_initialization(self):
        """testing the shot_number_prefix attribute is initialized correctly
        for a newly created Project instance
        """
        new_proj = Project("TEST_PROJECT")
        new_proj.create()

        self.assertEqual(new_proj.shot_number_prefix, conf.shot_number_prefix)
예제 #8
0
 def test_client_attribute_is_working_properly(self):
     """testing if the client attribute is working properly
     """
     new_client1 = Client(name='Test Client 1')
     new_client2 = Client(name='Test Client 2')
     new_proj = Project(name='Test Project', client=new_client1)
     self.assertNotEqual(new_client2, new_proj.client)
     new_proj.client = new_client2
     self.assertEqual(new_client2, new_proj.client)
예제 #9
0
 def test_client_attribute_is_working_properly(self):
     """testing if the client attribute is working properly
     """
     new_client1 = Client(name='Test Client 1')
     new_client2 = Client(name='Test Client 2')
     new_proj = Project(name='Test Project', client=new_client1)
     self.assertNotEqual(new_client2, new_proj.client)
     new_proj.client = new_client2
     self.assertEqual(new_client2, new_proj.client)
예제 #10
0
 def test_project_creation_for_new_project(self):
     """testing if the project creation occurs without any problem
     """
     
     new_proj = Project("TEST_PROJECT")
     new_proj.create()
     
     # now check if the folder is created
     self.assertTrue(os.path.exists(new_proj.full_path))
예제 #11
0
    def test___eq__operator(self):
        """testing the __eq__ (equal) operator
        """

        # create two projects
        proj1 = Project(name="TEST_PROJ1")
        proj2 = Project(name="TEST_PROJ1")

        self.assertEqual(proj1, proj2)
예제 #12
0
    def test_project_creation_for_new_project(self):
        """testing if the project creation occurs without any problem
        """

        new_proj = Project("TEST_PROJECT")
        new_proj.create()

        # now check if the folder is created
        self.assertTrue(os.path.exists(new_proj.full_path))
예제 #13
0
    def test_calling_commit_multiple_times(self):
        """testing if there is no problem of calling Project.save() multiple
        times
        """

        new_proj = Project("TEST_PROJECT")
        new_proj.create()
        new_proj.save()
        new_proj.save()
예제 #14
0
    def test_name_attribute_formatting(self):
        """testing if the name property will be formatted correctly.
        """
        new_project = Project("TEST_NAME")

        for test_value in self._name_test_values:
            new_project.name = test_value[0]
            expected_project_name = test_value[1]

            self.assertEqual(new_project.name, expected_project_name)
예제 #15
0
    def test_name_attribute_formatting(self):
        """testing if the name property will be formatted correctly.
        """
        new_project = Project("TEST_NAME")

        for test_value in self._name_test_values:
            new_project.name = test_value[0]
            expected_project_name = test_value[1]

            self.assertEqual(new_project.name, expected_project_name)
예제 #16
0
 def test_asset_attribute_returns_a_list_of_assets_related_to_this_project(self):
     """testing if the asset attribute returns a list of assets which are
     related to this project
     """
     new_proj1 = Project("Test Project 1")
     new_proj1.create()
     
     new_proj2 = Project("Test Project 2")
     new_proj2.create()
     
     new_proj3 = Project("Test Project 3")
     new_proj3.create()
     
     asset1 = Asset(new_proj1, "Asset 1")
     asset1.save()
     
     asset2 = Asset(new_proj1, "Asset 2")
     asset2.save()
     
     asset3 = Asset(new_proj2, "Asset 3")
     asset3.save()
     
     asset4 = Asset(new_proj2, "Asset 4")
     asset4.save()
     
     self.assertItemsEqual(new_proj1.assets, [asset1, asset2])
     self.assertItemsEqual(new_proj2.assets, [asset3, asset4])
     self.assertItemsEqual(new_proj3.assets, [])
예제 #17
0
    def setUp(self):
        """setup the test settings with environment variables
        """
        # -----------------------------------------------------------------
        # start of the setUp
        # create the environment variable and point it to a temp directory
        conf.database_url = "sqlite://"

        self.temp_config_folder = tempfile.mkdtemp()
        self.temp_projects_folder = tempfile.mkdtemp()

        os.environ["OYPROJECTMANAGER_PATH"] = self.temp_config_folder
        os.environ[conf.repository_env_key] = self.temp_projects_folder

        self.test_proj = Project("TEST_PROJ1")
        self.test_proj.create()

        self.kwargs = {
            "project": self.test_proj,
            "name": "Test Asset",
            "code": "TEST_ASSET",
            'type': 'Prop',
        }

        self.test_asset = Asset(**self.kwargs)
        self.test_asset.save()

        self._name_test_values = [
            ("Test Asset", "Test Asset"),
            ("23Test_Asset", "23Test_Asset"),
            ("TEST_ASSET", "TEST_ASSET"),
            ("£#$£#$AB", "AB"),
            ("'^+'^%^+%&&AB3£#$£½'^+'3'^+'4", "AB334"),
            ("afasfas fasf asdf67", "Afasfas fasf asdf67"),
            ("45a", "45a"),
            ("45acafs", "45acafs"),
            ("45'^+'^+a 234", "45a 234"),
            ("45asf78wr", "45asf78wr"),
            ("'^+'afsd2342'^+'asdFGH", "Afsd2342asdFGH"),
        ]

        self._code_test_values = [
            ("Test Asset", "Test_Asset"),
            ("23Test_Asset", "23Test_Asset"),
            ("TEST_ASSET", "TEST_ASSET"),
            ("£#$£#$AB", "AB"),
            ("'^+'^%^+%&&AB3£#$£½'^+'3'^+'4", "AB334"),
            ("afasfas fasf asdf67", "Afasfas_fasf_asdf67"),
            ("45a", "45a"),
            ("45acafs", "45acafs"),
            ("45'^+'^+a 234", "45a_234"),
            ("45asf78wr", "45asf78wr"),
            ("'^+'afsd2342'^+'asdFGH", "Afsd2342asdFGH"),
        ]
예제 #18
0
 def test_path_attribute_does_not_change_when_the_name_of_the_project_is_changed(self):
     """testing if the path attribute will be the same even the name of
     the proejct is changed
     """
     new_proj = Project(name="TEST_PROJ1")
     path = new_proj.path
     
     # change the name
     new_proj.name = "TEST_PROJ1_NEW_NAME"
     
     # now check if the path is still the same
     self.assertEqual(new_proj.path, path)
예제 #19
0
    def test_path_attribute_does_not_change_when_the_name_of_the_project_is_changed(
            self):
        """testing if the path attribute will be the same even the name of
        the proejct is changed
        """
        new_proj = Project(name="TEST_PROJ1")
        path = new_proj.path

        # change the name
        new_proj.name = "TEST_PROJ1_NEW_NAME"

        # now check if the path is still the same
        self.assertEqual(new_proj.path, path)
예제 #20
0
 def setUp(self):
     """setup the test settings with environment variables
     """
     # -----------------------------------------------------------------
     # start of the setUp
     conf.database_url = "sqlite://"
     
     # create the environment variable and point it to a temp directory
     self.temp_config_folder = tempfile.mkdtemp()
     self.temp_projects_folder = tempfile.mkdtemp()
     
     os.environ["OYPROJECTMANAGER_PATH"] = self.temp_config_folder
     os.environ[conf.repository_env_key] = self.temp_projects_folder
     
     self.test_proj = Project("TEST_PROJ1")
     self.test_proj.create()
     
     self.test_seq = Sequence(self.test_proj, "TEST_SEQ")
     self.test_seq.save()
     self.test_seq.create()
     
     self.kwargs = {
         "sequence": self.test_seq,
         "number": 1,
         "start_frame": 1,
         "end_frame": 100,
         "description": "Test shot"
     }
     
     self.test_shot = Shot(**self.kwargs)
     
     self._number_test_values = [
         (23, "23"),
         ("24", "24"),
         ("324ASF", "324ASF"),
         ("AD43", "AD43"),
         ("AS43A", "AS43A"),
         ("afasfas fasf    asdf67", "AFASFAS_FASF_ASDF67"),
         ("45a", "45A"),
         ("45acafs","45ACAFS"),
         ("45'^+'^+b", "45B"),
         ("45asf78wr", "45ASF78WR"),
         ("'^+'afsd2342'^+'asdFGH", "AFSD2342ASDFGH"),
         ("46B-3-B", "46B-3-B"),
         ("XB58P-4-C", "XB58P-4-C"),
         ("A143AN-04-D", "A143AN-04-D"),
         ("xb58q-2-d", "XB58Q-2-D"),
         ("underscores_are_allowed", "UNDERSCORES_ARE_ALLOWED"),
         ("304_sb_0403_0040", "304_SB_0403_0040"),
         #("0001", "1"),
     ]
예제 #21
0
    def test_deleting_a_project_deletes_the_related_sequences(self):
        """testing if deleting a project will also delete the related sequences
        """
        proj1 = Project("Test Project 1")
        proj1.save()

        proj2 = Project("Test Project 2")
        proj2.save()

        seq1 = Sequence(proj1, "Test Sequence 1")
        seq1.save()

        seq2 = Sequence(proj1, "Test Sequence 2")
        seq2.save()

        seq3 = Sequence(proj2, "Test Sequence 3")
        seq3.save()

        self.assertIn(proj1, db.session)
        self.assertIn(seq1, db.session)
        self.assertIn(seq2, db.session)

        db.session.delete(proj1)
        db.session.commit()

        self.assertNotIn(proj1, db.session)
        self.assertNotIn(seq1, db.session)
        self.assertNotIn(seq2, db.session)

        self.assertIn(proj2, db.session)
        self.assertIn(seq3, db.session)
예제 #22
0
    def test_deleting_a_project_deletes_the_related_assets(self):
        """testing if deleting a project also deletes all Assets related to it
        """
        proj1 = Project("Test Project1")
        proj1.save()

        proj2 = Project("Test Project2")
        proj2.save()

        asset1 = Asset(proj1, "Test Asset 1")
        asset1.save()

        asset2 = Asset(proj1, "Test Asset 2")
        asset2.save()

        asset3 = Asset(proj2, "Test Asset 3")
        asset3.save()

        # confirm assets are in session
        self.assertIn(asset1, db.session)
        self.assertIn(asset2, db.session)

        db.session.delete(proj1)
        db.session.commit()

        # now check if asset1 and asset2 are also deleted
        assets = db.session.query(Asset).all()
        self.assertNotIn(asset1, assets)
        self.assertNotIn(asset2, assets)
        self.assertNotIn(asset1, db.session)
        self.assertNotIn(asset2, db.session)

        # check if proj2 and asset3 are  still there
        self.assertIn(proj2, db.session)
        self.assertIn(asset3, db.session)
예제 #23
0
    def test_shot_number_prefix_attribute_initialization_from_DB(self):
        """testing if the shot_number_prefix attribute is initialized correctly
        for a Project which is already in the database
        """
        new_proj = Project("TEST_PROJECT")
        new_proj.shot_number_prefix = "PL"
        new_proj.create()
        new_proj.save()

        # now get it back from db
        new_proj = Project("TEST_PROJECT")
        self.assertEqual(new_proj.shot_number_prefix, "PL")
예제 #24
0
 def test_full_path_attribute_is_calculated_from_the_project_code(self):
     """testing if the full_path attribute is calculated from the project
     code
     """
     new_proj = Project(name="Test Project 1", code="TEST_PROJECT_1")
     self.assertEqual(new_proj.full_path,
                      os.path.join(os.environ["REPO"], new_proj.code))
예제 #25
0
 def test_client_attribute_is_not_a_Client_instance(self):
     """testing if a TypeError will be raised when the client attribute is
     not set to a Client instance
     """
     new_client = Client(name='Test Client')
     new_proj = Project(name='Test Project', client=new_client)
     self.assertRaises(TypeError, setattr, new_proj, 'client', 'a client')
예제 #26
0
    def test_project_initialization_with_database(self):
        """testing the project initialization occurs without any problem
        """

        test_value = "TEST_PROJECT"
        new_proj = Project(test_value)
        self.assertEqual(new_proj.name, test_value)
예제 #27
0
 def test_shot_is_CRUD_properly_in_the_database(self):
     """testing if the shot instance is created properly in the database
     """
     new_proj = Project("TEST_PROJ_FOR_CRUD")
     new_proj.create()
     
     new_seq = Sequence(new_proj, "TEST_SEQ103")
     new_seq.save()
     
     new_shot = Shot(new_seq, '1a')
     new_shot.save()
     
     # now query the database if it is created and read correctly
     self.assertEqual(
         new_shot,
         Shot.query()
             .filter(Shot.number==new_shot.number)
             .first()
     )
     
     # now update it
     new_shot.start_frame = 100
     new_shot.end_frame = 200
     new_shot.save()
     
     self.assertEqual(
         new_shot.start_frame,
         Shot.query()
             .filter(Shot.number==new_shot.number)
             .first()
             .start_frame
     )
     self.assertEqual(
         new_shot.end_frame,
         Shot.query()
             .filter(Shot.number==new_shot.number)
             .first()
             .end_frame
     )
     
     # now delete it
     db.session.delete(new_shot)
     db.session.commit()
     
     self.assertEqual(len(Shot.query().all()), 1)
예제 #28
0
    def test_project_stored_and_retrieved_correctly(self):
        """testing if the project is stored and retrieved correctly
        """

        new_proj = Project(name="TEST_PROJECT")
        new_proj.create()

        name = new_proj.name
        path = new_proj.path
        full_path = new_proj.full_path

        del new_proj

        new_proj_DB = Project.query().first()

        self.assertEqual(new_proj_DB.name, name)
        self.assertEqual(new_proj_DB.path, path)
        self.assertEqual(new_proj_DB.full_path, full_path)
예제 #29
0
    def test_project_stored_and_retrieved_correctly(self):
        """testing if the project is stored and retrieved correctly
        """

        new_proj = Project(name="TEST_PROJECT")
        new_proj.create()

        name = new_proj.name
        path = new_proj.path
        full_path = new_proj.full_path

        del new_proj

        new_proj_DB = Project.query().first()

        self.assertEqual(new_proj_DB.name, name)
        self.assertEqual(new_proj_DB.path, path)
        self.assertEqual(new_proj_DB.full_path, full_path)
예제 #30
0
    def test_creating_two_different_projects_and_calling_create_in_mixed_order(
            self):
        """testing no error will be raised when creating two Project instances
        and calling their create method in mixed order
        """

        new_proj1 = Project("TEST_PROJECT1")
        new_proj2 = Project("TEST_PROJECT2")

        new_proj1.create()
        new_proj2.create()
예제 #31
0
    def _updateProjectObject(self):
        """updates the project object if it is changed
        it is introduced to take advantage of the cache system
        """
        currentProjectName = self.getCurrentProjectName()

        if self._project is None or \
           self._project.name != currentProjectName or \
           (currentProjectName != "" or currentProjectName is not None):
            self._project = Project(currentProjectName)
예제 #32
0
    def test_version_types_attribute_initialization_for_a_new_Project_instance(self):
        """testing if the version_types attribute initializes from the config
        correctly for a new Project instance
        """

        new_proj = Project("TEST_PROJECT")
        new_proj.create()

        # now check if the project has all the version types defined in the
        # config file

        for version_type in conf.version_types:
            version_type_name = version_type["name"]
            vtype_from_proj =\
                VersionType.query().\
                filter_by(name=version_type_name).\
                first()
            
            self.assertTrue(vtype_from_proj is not None)
예제 #33
0
    def test_calling_create_on_a_project_which_is_retrieved_from_db(self):
        """testing if there will be no error messages generated when the new
        project is retrieved from the database and the create method of this
        project is called
        """

        project_name = "TEST_PROJECT1"
        new_proj1 = Project(project_name)
        new_proj1.create()

        new_proj2 = Project(project_name)
        new_proj2.create()
예제 #34
0
 def test_inequality_of_shots(self):
     """testing if the equality operator is working properly
     """
     proj1 = Project("TEST_EQ_PROJ")
     proj1.create()
     
     seq1 = Sequence(proj1, "TEST_SEQ1")
     seq2 = Sequence(proj1, "TEST_SEQ2")
     
     shot1 = Shot(seq1, 1)
     shot2 = Shot(seq1, 2)
     shot3 = Shot(seq2, 1)
     
     #shot1a = Shot(seq1, 1)
     shot1a = seq1.shots[0]
     
     self.assertFalse(shot1!=shot1a)
     self.assertTrue(shot1!=shot2)
     self.assertTrue(shot1a!=shot3)
예제 #35
0
    def test_code_argument_is_formatted_correctly(self):
        """testing if the code attribute is formatted correctly on Project
        instance creation
        """
        for test_value in self._name_test_values:
            project_code = test_value[0]
            expected_project_code = test_value[2]

            new_project = Project(name="TEST_PROJ1", code=project_code)

            self.assertEqual(new_project.code, expected_project_code)
예제 #36
0
    def test_version_types_attribute_initialization_for_a_new_Project_instance(
            self):
        """testing if the version_types attribute initializes from the config
        correctly for a new Project instance
        """

        new_proj = Project("TEST_PROJECT")
        new_proj.create()

        # now check if the project has all the version types defined in the
        # config file

        for version_type in conf.version_types:
            version_type_name = version_type["name"]
            vtype_from_proj =\
                VersionType.query().\
                filter_by(name=version_type_name).\
                first()

            self.assertTrue(vtype_from_proj is not None)
예제 #37
0
    def test_name_argument_formatting(self):
        """testing if the name will be formatted correctly when creating a
        new project.
        """
        for test_value in self._name_test_values:
            project_name = test_value[0]
            expected_project_name = test_value[1]

            new_project = Project(project_name)

            self.assertEqual(new_project.name, expected_project_name)
예제 #38
0
 def setUp(self):
     """setup the test settings with environment variables
     """
     # -----------------------------------------------------------------
     # start of the setUp
     # create the environment variable and point it to a temp directory
     conf.database_url = "sqlite://"
     
     self.temp_config_folder = tempfile.mkdtemp()
     self.temp_projects_folder = tempfile.mkdtemp()
     
     os.environ["OYPROJECTMANAGER_PATH"] = self.temp_config_folder
     os.environ[conf.repository_env_key] = self.temp_projects_folder
     
     self.test_proj = Project("TEST_PROJ1")
     self.test_proj.create()
     
     self.kwargs = {
         "project": self.test_proj,
         "name": "Test Asset",
         "code": "TEST_ASSET",
         'type': 'Prop',
     }
     
     self.test_asset = Asset(**self.kwargs)
     self.test_asset.save()
     
     self._name_test_values = [
         ("Test Asset", "Test Asset"),
         ("23Test_Asset", "23Test_Asset"),
         ("TEST_ASSET", "TEST_ASSET"),
         ("£#$£#$AB", "AB"),
         ("'^+'^%^+%&&AB3£#$£½'^+'3'^+'4", "AB334"),
         ("afasfas fasf asdf67", "Afasfas fasf asdf67"),
         ("45a", "45a"),
         ("45acafs","45acafs"),
         ("45'^+'^+a 234", "45a 234"),
         ("45asf78wr", "45asf78wr"),
         ("'^+'afsd2342'^+'asdFGH", "Afsd2342asdFGH"),
     ]
     
     self._code_test_values = [
         ("Test Asset", "Test_Asset"),
         ("23Test_Asset", "23Test_Asset"),
         ("TEST_ASSET", "TEST_ASSET"),
         ("£#$£#$AB", "AB"),
         ("'^+'^%^+%&&AB3£#$£½'^+'3'^+'4", "AB334"),
         ("afasfas fasf asdf67", "Afasfas_fasf_asdf67"),
         ("45a", "45a"),
         ("45acafs","45acafs"),
         ("45'^+'^+a 234", "45a_234"),
         ("45asf78wr", "45asf78wr"),
         ("'^+'afsd2342'^+'asdFGH", "Afsd2342asdFGH"),
     ]
예제 #39
0
    def test_deleting_a_project_will_delete_the_related_shots(self):
        """testing if deleting a project will also delete the related shots
        """
        proj1 = Project("Test Project 1")
        proj1.save()

        proj2 = Project("Test Project 2")
        proj2.save()

        seq1 = Sequence(proj1, "Sequence 1")
        seq1.save()

        seq2 = Sequence(proj2, "Sequence 2")
        seq2.save()

        shot1 = Shot(seq1, 1)
        shot1.save()

        shot2 = Shot(seq1, 2)
        shot2.save()

        shot3 = Shot(seq2, 1)
        shot3.save()

        shot4 = Shot(seq2, 2)
        shot4.save()

        # check all are in session
        self.assertIn(proj1, db.session)
        self.assertIn(proj2, db.session)
        self.assertIn(seq1, db.session)
        self.assertIn(seq2, db.session)
        self.assertIn(shot1, db.session)
        self.assertIn(shot2, db.session)
        self.assertIn(shot3, db.session)
        self.assertIn(shot4, db.session)

        # delete the project
        db.session.delete(proj1)
        db.session.commit()

        self.assertNotIn(proj1, db.session)
        self.assertNotIn(seq1, db.session)
        self.assertNotIn(shot1, db.session)
        self.assertNotIn(shot2, db.session)

        self.assertIn(proj2, db.session)
        self.assertIn(seq2, db.session)
        self.assertIn(shot3, db.session)
        self.assertIn(shot4, db.session)
예제 #40
0
 def test_deleting_a_project_deletes_the_related_sequences(self):
     """testing if deleting a project will also delete the related sequences
     """
     proj1 = Project("Test Project 1")
     proj1.save()
     
     proj2 = Project("Test Project 2")
     proj2.save()
     
     seq1 = Sequence(proj1, "Test Sequence 1")
     seq1.save()
     
     seq2 = Sequence(proj1, "Test Sequence 2")
     seq2.save()
     
     seq3 = Sequence(proj2, "Test Sequence 3")
     seq3.save()
     
     self.assertIn(proj1, db.session)
     self.assertIn(seq1, db.session)
     self.assertIn(seq2, db.session)
     
     db.session.delete(proj1)
     db.session.commit()
     
     self.assertNotIn(proj1, db.session)
     self.assertNotIn(seq1, db.session)
     self.assertNotIn(seq2, db.session)
     
     self.assertIn(proj2, db.session)
     self.assertIn(seq3, db.session)
예제 #41
0
 def test_deleting_a_project_deletes_the_related_assets(self):
     """testing if deleting a project also deletes all Assets related to it
     """
     proj1 = Project("Test Project1")
     proj1.save()
     
     proj2 = Project("Test Project2")
     proj2.save()
     
     asset1 = Asset(proj1, "Test Asset 1")
     asset1.save()
     
     asset2 = Asset(proj1, "Test Asset 2")
     asset2.save()
     
     asset3 = Asset(proj2, "Test Asset 3")
     asset3.save()
     
     # confirm assets are in session
     self.assertIn(asset1, db.session)
     self.assertIn(asset2, db.session)
     
     db.session.delete(proj1)
     db.session.commit()
     
     # now check if asset1 and asset2 are also deleted
     assets = db.session.query(Asset).all()
     self.assertNotIn(asset1, assets)
     self.assertNotIn(asset2, assets)
     self.assertNotIn(asset1, db.session)
     self.assertNotIn(asset2, db.session)
     
     # check if proj2 and asset3 are  still there
     self.assertIn(proj2, db.session)
     self.assertIn(asset3, db.session)
예제 #42
0
    def test_calling_create_over_and_over_again_will_not_cause_any_problem(
            self):
        """testing if calling the create over and over again will not create a
        problem
        """

        # we need to create a new project and a sequence
        new_proj = Project("TEST_PROJECT")
        new_proj.create()
        new_proj.create()
        new_proj.create()
        new_proj.create()
        new_proj.create()
        new_proj.create()
예제 #43
0
 def test_deleting_an_asset_will_not_delete_the_related_project(self):
     """testing if deleting an asset will not delete the related project
     """
     proj1 = Project('test project 1')
     proj1.save()
     
     asset = Asset(proj1, 'Test asset')
     asset.save()
     
     # check if they are in the session
     self.assertIn(proj1, db.session)
     self.assertIn(asset, db.session)
     
     # delete the asset
     db.session.delete(asset)
     db.session.commit()
     
     # check if it is removed from the session
     self.assertNotIn(asset, db.session)
     
     # and the project is there
     self.assertIn(proj1, db.session)
예제 #44
0
    def test_deleting_an_asset_will_not_delete_the_related_project(self):
        """testing if deleting an asset will not delete the related project
        """
        proj1 = Project('test project 1')
        proj1.save()

        asset = Asset(proj1, 'Test asset')
        asset.save()

        # check if they are in the session
        self.assertIn(proj1, db.session)
        self.assertIn(asset, db.session)

        # delete the asset
        db.session.delete(asset)
        db.session.commit()

        # check if it is removed from the session
        self.assertNotIn(asset, db.session)

        # and the project is there
        self.assertIn(proj1, db.session)
예제 #45
0
    def test_shot_number_prefix_attribute_initialization_from_DB(self):
        """testing if the shot_number_prefix attribute is initialized correctly
        for a Project which is already in the database
        """
        new_proj = Project("TEST_PROJECT")
        new_proj.shot_number_prefix = "PL"
        new_proj.create()
        new_proj.save()

        # now get it back from db
        new_proj = Project("TEST_PROJECT")
        self.assertEqual(new_proj.shot_number_prefix, "PL")
예제 #46
0
    def test_project_restores_from_database_2(self):
        """testing if a project restores it self from the database with all its
        connections
        """

        # we need to create a new project and a sequence
        new_proj = Project("TEST_PROJECT")
        new_proj.create()

        new_seq = Sequence(new_proj, "TEST_SEQ")
        new_seq.save()
        new_seq.create()

        db.session.add(new_proj)
        db.session.commit()

        del new_proj
        del new_seq

        # now retrieve the project by recreating it
        new_proj2 = Project(name="TEST_PROJECT")

        self.assertEqual(new_proj2.sequences[0].name, "TEST_SEQ")
예제 #47
0
    def test_project_restores_from_database_2(self):
        """testing if a project restores it self from the database with all its
        connections
        """

        # we need to create a new project and a sequence
        new_proj = Project("TEST_PROJECT")
        new_proj.create()
        
        new_seq = Sequence(new_proj, "TEST_SEQ")
        new_seq.save()
        new_seq.create()
        
        db.session.add(new_proj)
        db.session.commit()

        del new_proj
        del new_seq

        # now retrieve the project by recreating it
        new_proj2 = Project(name="TEST_PROJECT")

        self.assertEqual(new_proj2.sequences[0].name, "TEST_SEQ")
예제 #48
0
    def test_calling_create_over_and_over_again_will_not_cause_any_problem(self):
        """testing if calling the create over and over again will not create a
        problem
        """

        # we need to create a new project and a sequence
        new_proj = Project("TEST_PROJECT")
        new_proj.create()
        new_proj.create()
        new_proj.create()
        new_proj.create()
        new_proj.create()
        new_proj.create()
예제 #49
0
    def test_creating_two_different_projects_and_calling_create_in_mixed_order(self):
        """testing no error will be raised when creating two Project instances
        and calling their create method in mixed order
        """

        new_proj1 = Project("TEST_PROJECT1")
        new_proj2 = Project("TEST_PROJECT2")

        new_proj1.create()
        new_proj2.create()
예제 #50
0
    def test_calling_create_on_a_project_which_is_retrieved_from_db(self):
        """testing if there will be no error messages generated when the new
        project is retrieved from the database and the create method of this
        project is called
        """

        project_name = "TEST_PROJECT1"
        new_proj1 = Project(project_name)
        new_proj1.create()

        new_proj2 = Project(project_name)
        new_proj2.create()
예제 #51
0
 def test_deleting_a_project_will_delete_the_related_shots(self):
     """testing if deleting a project will also delete the related shots
     """
     proj1 = Project("Test Project 1")
     proj1.save()
     
     proj2 = Project("Test Project 2")
     proj2.save()
     
     seq1 = Sequence(proj1, "Sequence 1")
     seq1.save()
     
     seq2 = Sequence(proj2, "Sequence 2")
     seq2.save()
     
     shot1 = Shot(seq1, 1)
     shot1.save()
     
     shot2 = Shot(seq1, 2)
     shot2.save()
     
     shot3 = Shot(seq2, 1)
     shot3.save()
     
     shot4 = Shot(seq2, 2)
     shot4.save()
     
     # check all are in session
     self.assertIn(proj1, db.session)
     self.assertIn(proj2, db.session)
     self.assertIn(seq1, db.session)
     self.assertIn(seq2, db.session)
     self.assertIn(shot1, db.session)
     self.assertIn(shot2, db.session)
     self.assertIn(shot3, db.session)
     self.assertIn(shot4, db.session)
     
     # delete the project
     db.session.delete(proj1)
     db.session.commit()
     
     self.assertNotIn(proj1, db.session)
     self.assertNotIn(seq1, db.session)
     self.assertNotIn(shot1, db.session)
     self.assertNotIn(shot2, db.session)
     
     self.assertIn(proj2, db.session)
     self.assertIn(seq2, db.session)
     self.assertIn(shot3, db.session)
     self.assertIn(shot4, db.session)
예제 #52
0
    def test_project_restores_from_database_1(self):
        """testing if a project restores it self from the database with all its
        connections
        """

        # we need to create a new project and a sequence
        new_proj = Project("TEST_PROJECT")
        new_proj.create()

        test_description = "test description"
        new_proj.description = test_description
        new_proj.save()

        del new_proj

        # now retrieve the project by recreating it
        new_proj2 = Project("TEST_PROJECT")

        self.assertEqual(new_proj2.description, test_description)
예제 #53
0
 def test_equality_of_assets(self):
     """testing if two assets are equal if their names and projects are also
     equal
     """
     
     proj1 = Project("EQUALITY_TEST_PROJECT_1")
     proj1.create()
     
     proj2 = Project("EQUALITY_TEST_PROJECT_2")
     proj2.create()
     
     asset1 = Asset(proj1, "TEST_ASSET1")
     asset2 = Asset(proj1, "TEST_ASSET1")
     
     asset3 = Asset(proj1, "TEST_ASSET3")
     asset4 = Asset(proj2, "TEST_ASSET3")
     
     self.assertTrue(asset1==asset2)
     self.assertFalse(asset1==asset3)
     self.assertFalse(asset3==asset4)
예제 #54
0
 def test_inequality_of_assets(self):
     """testing if two assets are inequal if their names are different and
     or their projects are different
     """
     
     proj1 = Project("EQUALITY_TEST_PROJECT_1")
     proj1.create()
     
     proj2 = Project("EQUALITY_TEST_PROJECT_2")
     proj2.create()
     
     asset1 = Asset(proj1, "TEST_ASSET1")
     asset2 = Asset(proj1, "TEST_ASSET1")
     
     asset3 = Asset(proj1, "TEST_ASSET3")
     asset4 = Asset(proj2, "TEST_ASSET3")
     
     self.assertFalse(asset1!=asset2)
     self.assertTrue(asset1!=asset3)
     self.assertTrue(asset3!=asset4)
예제 #55
0
 def test_deleting_a_shot_will_delete_the_related_versions(self):
     """testing if deleting a shot will delete the related versions
     """
     
     proj1 = Project('test project 1')
     proj1.save()
     
     seq1 = Sequence(proj1, 'test sequence 1')
     seq1.save()
     
     shot1 = Shot(seq1, 1)
     shot1.save()
     
     shot2 = Shot(seq1, 2)
     shot2.save()
     
     user = User.query().first()
     shot_vtypes = VersionType.query().filter_by(type_for="Shot").all()
     
     # versions for shot1
     vers1 = Version(
         shot1,
         base_name=shot1.code,
         type=shot_vtypes[0],
         created_by=user
     )
     vers1.save()
     
     vers2 = Version(
         shot1,
         base_name=shot1.code,
         type=shot_vtypes[0],
         created_by=user
     )
     vers2.save()
     
     vers3 = Version(
         shot1,
         base_name=shot1.code,
         type=shot_vtypes[0],
         created_by=user
     )
     vers3.save()
     
     # versions for shot2
     vers4 = Version(
         shot2,
         base_name=shot2.code,
         type=shot_vtypes[0],
         created_by=user
     )
     vers4.save()
     
     vers5 = Version(
         shot2,
         base_name=shot2.code,
         type=shot_vtypes[0],
         created_by=user
     )
     vers5.save()
     
     vers6 = Version(
         shot2,
         base_name=shot2.code,
         type=shot_vtypes[0],
         created_by=user
     )
     vers6.save()
     
     # test all are in the session
     self.assertIn(proj1, db.session)
     self.assertIn(seq1, db.session)
     self.assertIn(shot1, db.session)
     self.assertIn(shot2, db.session)
     self.assertIn(vers1, db.session)
     self.assertIn(vers2, db.session)
     self.assertIn(vers3, db.session)
     self.assertIn(vers4, db.session)
     self.assertIn(vers5, db.session)
     self.assertIn(vers6, db.session)
     
     # delete shot1
     db.session.delete(shot1)
     db.session.commit()
     
     # check if versions are deleted
     self.assertNotIn(shot1, db.session)
     self.assertNotIn(vers1, db.session)
     self.assertNotIn(vers2, db.session)
     self.assertNotIn(vers3, db.session)
     
     # check if all the others are still there
     self.assertIn(proj1, db.session)
     self.assertIn(seq1, db.session)
     self.assertIn(shot2, db.session)
     self.assertIn(vers4, db.session)
     self.assertIn(vers5, db.session)
     self.assertIn(vers6, db.session)
예제 #56
0
class ShotTester(unittest.TestCase):
    """tests the Shot class
    """
    
    def setUp(self):
        """setup the test settings with environment variables
        """
        # -----------------------------------------------------------------
        # start of the setUp
        conf.database_url = "sqlite://"
        
        # create the environment variable and point it to a temp directory
        self.temp_config_folder = tempfile.mkdtemp()
        self.temp_projects_folder = tempfile.mkdtemp()
        
        os.environ["OYPROJECTMANAGER_PATH"] = self.temp_config_folder
        os.environ[conf.repository_env_key] = self.temp_projects_folder
        
        self.test_proj = Project("TEST_PROJ1")
        self.test_proj.create()
        
        self.test_seq = Sequence(self.test_proj, "TEST_SEQ")
        self.test_seq.save()
        self.test_seq.create()
        
        self.kwargs = {
            "sequence": self.test_seq,
            "number": 1,
            "start_frame": 1,
            "end_frame": 100,
            "description": "Test shot"
        }
        
        self.test_shot = Shot(**self.kwargs)
        
        self._number_test_values = [
            (23, "23"),
            ("24", "24"),
            ("324ASF", "324ASF"),
            ("AD43", "AD43"),
            ("AS43A", "AS43A"),
            ("afasfas fasf    asdf67", "AFASFAS_FASF_ASDF67"),
            ("45a", "45A"),
            ("45acafs","45ACAFS"),
            ("45'^+'^+b", "45B"),
            ("45asf78wr", "45ASF78WR"),
            ("'^+'afsd2342'^+'asdFGH", "AFSD2342ASDFGH"),
            ("46B-3-B", "46B-3-B"),
            ("XB58P-4-C", "XB58P-4-C"),
            ("A143AN-04-D", "A143AN-04-D"),
            ("xb58q-2-d", "XB58Q-2-D"),
            ("underscores_are_allowed", "UNDERSCORES_ARE_ALLOWED"),
            ("304_sb_0403_0040", "304_SB_0403_0040"),
            #("0001", "1"),
        ]
    
    def tearDown(self):
        """cleanup the test
        """
        # set the db.session to None
        db.session = None
        
        # delete the temp folder
        shutil.rmtree(self.temp_config_folder)
        shutil.rmtree(self.temp_projects_folder)
    
    def test_number_argument_is_skipped(self):
        """testing if a TypeError will be raised when the number argument is
        skipped
        """
        self.kwargs.pop("number")
        self.assertRaises(TypeError, Shot, **self.kwargs)
    
    def test_number_argument_is_None(self):
        """testing if a TypeError will be raised when the number argument is
        None
        """
        self.kwargs["number"] = None
        self.assertRaises(TypeError, Shot, **self.kwargs)

    def test_number_attribute_is_None(self):
        """testing if a TypeError will be raised when the number attribute is
        set to None
        """
        self.assertRaises(TypeError, setattr, self.test_shot, "number", None)
    
    def test_number_argument_is_empty_string(self):
        """testing if a ValueError will be raised when the number argument is
        an empty string
        """
        self.kwargs["number"] = ""
        self.assertRaises(ValueError, Shot, **self.kwargs)
    
    def test_number_attribute_is_set_to_empty_string(self):
        """testing if a ValueError will be raised when the number attribute is
        set to an empty string
        """
        self.assertRaises(ValueError, setattr, self.test_shot, "number", "")
    
    def test_number_argument_is_not_a_string_or_integer(self):
        """testing if a TypeError will be raised when the number argument is
        not a string or integer
        """
        self.kwargs["number"] = [123]
        self.assertRaises(TypeError, Shot, **self.kwargs)
    
    def test_number_attribute_is_not_a_string_integer(self):
        """testing if a TypeError will be raised when the number attribute is
        not a string or integer
        """
        self.assertRaises(TypeError, setattr, self.test_shot, "number", [])
    
    def test_number_argument_formatted_correctly(self):
        """testing if the number attribute is formatted correctly when the class
        is initialized
        """
        for test_value in self._number_test_values:
            self.kwargs["number"] = test_value[0]
            new_shot = Shot(**self.kwargs)
            self.assertEqual(test_value[1], new_shot.number)
            
    
#    def test_number_attribute_formatted_correctly(self):
#        """testing if the number attribute is formatted correctly
#        """
#        for test_value in self._number_test_values:
#            self.kwargs["number"] = test_value[0]
#            new_shot = Shot(**self.kwargs)
#            self.assertEqual(test_value[1], new_shot.number)
    
    def test_number_is_already_defined_in_the_sequence(self):
        """testing if a ValueError will be raised when the shot number is
        already defined in the given Sequence
        """
        self.kwargs["number"] = 101
        new_shot1 = Shot(**self.kwargs)
        self.assertRaises(
            ValueError,
            Shot,
            **self.kwargs
        )
    
    def test_number_is_already_defined_in_the_sequence_for_an_already_created_one(self):
        """testing if a ValueError will be raised when the number is already
        defined for a Shot in the same Sequence instance
        """
        self.kwargs["number"] = 101
        new_shot1 = Shot(**self.kwargs)
        new_shot1.save()
        
        self.assertRaises(ValueError, Shot, **self.kwargs)
    
    def test_number_argument_is_string_or_integer(self):
        """testing if both strings and integers are ok to pass to the number
        argument
        """
        self.kwargs["number"] = 10
        new_shot1 = Shot(**self.kwargs)
        self.assertEqual(new_shot1.number, "10")
        
        self.kwargs["number"] = "11A"
        new_shot2 = Shot(**self.kwargs)
        self.assertEqual(new_shot2.number, "11A")
    
    def test_code_attribute_is_calculated_from_the_number_argument(self):
        """testing if the code attribute is calculated from the number
        argument
        """
        
        self.kwargs["number"] = 10
        new_shot1 = Shot(**self.kwargs)
        self.assertEqual(new_shot1.code, "SH010")
        
        self.kwargs["number"] = "10A"
        new_shot1 = Shot(**self.kwargs)
        self.assertEqual(new_shot1.code, "SH010A")
        
        self.kwargs["number"] = "A143AN-04-D"
        new_shot1 = Shot(**self.kwargs)
        self.assertEqual(new_shot1.code, "SHA143AN-04-D")
        
        self.kwargs["number"] = "A143AN-04-DB"
        self.test_proj.shot_number_prefix = ""
        new_shot1 = Shot(**self.kwargs)
        self.assertEqual(new_shot1.code, "A143AN-04-DB")
        
        self.kwargs['number'] = '304_sb_0403_0040'
        self.test_proj.shot_number_prefix = ""
        new_shot1 = Shot(**self.kwargs)
        self.assertEqual(new_shot1.code, '304_SB_0403_0040')
    
    def test_code_attribute_is_calculated_from_the_number_attribute(self):
        """testing if the code attribute is calculated from the number
        attribute
        """
        
        self.test_shot.number = 10
        self.assertEqual(self.test_shot.code, "SH010")
        
        self.test_shot.number = "10A"
        self.assertEqual(self.test_shot.code, "SH010A")
    
    def test_code_attribute_is_read_only(self):
        """testing if the code attribute is read_only
        """
        self.assertRaises(AttributeError, setattr, self.test_shot, "code",
                          "SH010A")
    
#    def test_code_argument_is_not_in_good_format(self):
#        """testing if a ValueError will be raised when the code argument format
#        is not correct
#        """
#        self.kwargs["code"] = "wrong format"
#        self.assertRaises(ValueError, Shot, **self.kwargs)
#    
#    def test_code_attribute_is_not_in_good_format(self):
#        """testing if a ValueError will be raised when the code attribute
#        format is not correct
#        """
#        self.assertRaises(ValueError, setattr, self.test_shot, "code",
#                          "wrong format")
#    
#    def test_code_argument_is_formatted_correctly(self):
#        """testing if the code argument is formatted correctly
#        """
#        for test_value in self._code_test_values:
#            self.kwargs["code"] = test_value[0]
#            new_shot = Shot(**self.kwargs)
#            self.assertEqual(new_shot.code, test_value[1])
#    
#    def test_code_attribute_is_formatted_correctly(self):
#        """testing if the code attribute is formatted correctly
#        """
#        for test_value in self._code_test_values:
#            self.test_shot.code = test_value[0]
#            self.assertEqual(self.test_shot.code, test_value[1])
    
    def test_sequence_argument_is_skipped(self):
        """testing if a TypeError will be raised when the sequence argument
        is skipped
        """
        self.kwargs.pop("sequence")
        self.assertRaises(TypeError, Shot, **self.kwargs)
    
    def test_sequence_argument_is_None(self):
        """testing if a TypeError will be raised when the sequence argument
        is None
        """
        self.kwargs["sequence"] = None
        self.assertRaises(TypeError, Shot, **self.kwargs)
    
    def test_sequence_argument_is_not_a_Sequence_instance(self):
        """testing if a TypeError will be raised when the sequence argument is
        not a Sequence instance
        """
        self.kwargs["sequence"] = "not a sequence instance"
        self.assertRaises(TypeError, Shot, **self.kwargs)
    
    def test_sequence_argument_is_working_properly(self):
        """testing if the sequence argument is working correctly
        """
        self.assertTrue(self.test_shot.sequence is self.test_seq)
    
    def test_sequence_attribute_is_read_only(self):
        """testing if the sequence attribute is read-only
        """
        new_seq = Sequence(self.test_proj, "TEST_SEQ2")
        new_seq.save()
        self.assertRaises(AttributeError, setattr, self.test_shot, "sequence",
                          new_seq)
    
    def test_start_frame_argument_is_skipped(self):
        """testing if the start_frame attribute will be set to the default
        value when the start_frame argument is skipped
        """
        self.kwargs['number'] = '1a'
        self.kwargs.pop("start_frame")
        new_shot = Shot(**self.kwargs)
        self.assertEqual(new_shot.start_frame, 1)
    
    def test_start_frame_argument_is_None(self):
        """testing if the start_frame attribute will be set to the default
        value when the start_frame argument is skipped
        """
        self.kwargs['number'] = '1a'
        self.kwargs["start_frame"] = None
        new_shot = Shot(**self.kwargs)
        self.assertEqual(new_shot.start_frame, 1)
    
    def test_start_frame_attribute_is_None(self):
        """testing if the start_frame attribute will be set to the default
        value when it is set to None
        """
        self.test_shot.start_frame = None
        self.assertEqual(self.test_shot.start_frame, 1)
    
    def test_start_frame_argument_is_not_integer(self):
        """testing if a TypeError will be raised when the start_frame argument
        is not an integer
        """
        self.kwargs['number'] = '1a'
        self.kwargs["start_frame"] = "asdfa"
        self.assertRaises(TypeError, Shot, **self.kwargs)
    
    def test_start_frame_attribute_is_not_integer(self):
        """testing if a TypeError will be raised when the start_frame attribute
        is not set to an integer value
        """
        self.assertRaises(TypeError, setattr, self.test_shot, "start_frame",
                          "asdfs")
    
    def test_start_frame_attribute_is_working_properly(self):
        """testing if the start_frame attribute is working properly
        """
        test_value = 10
        self.test_shot.start_frame = test_value
        self.assertEqual(self.test_shot.start_frame, test_value)
    
    def test_start_frame_attribute_updates_the_duration_attribute(self):
        """testing if the start_frame attribute updates the duration attribute
        value
        """
        self.test_shot.start_frame = 10
        self.assertEqual(self.test_shot.end_frame, 100)
        self.assertEqual(self.test_shot.duration, 91)
    
    def test_end_frame_argument_is_skipped(self):
        """testing if the end_frame attribute will be set to the default
        value when the end_frame argument is skipped
        """
        self.kwargs['number'] = '1a'
        self.kwargs.pop("end_frame")
        new_shot = Shot(**self.kwargs)
        self.assertEqual(new_shot.end_frame, 1)
    
    def test_end_frame_argument_is_None(self):
        """testing if the end_frame attribute will be set to the default
        value when the end_frame argument is skipped
        """
        self.kwargs['number'] = '1a'
        self.kwargs["end_frame"] = None
        new_shot = Shot(**self.kwargs)
        self.assertEqual(new_shot.end_frame, 1)
    
    def test_end_frame_attribute_is_Non(self):
        """testing if the end_frame attribute will be set to the default
        value when it is set to None
        """
        self.test_shot.end_frame = None
        self.assertEqual(self.test_shot.end_frame, 1)
    
    def test_end_frame_argument_is_not_integer(self):
        """testing if a TypeError will be raised when the end_frame argument
        is not an integer
        """
        self.kwargs['number'] = '1a'
        self.kwargs["end_frame"] = "asdfa"
        self.assertRaises(TypeError, Shot, **self.kwargs)
    
    def test_end_frame_attribute_is_not_integer(self):
        """testing if a TypeError will be raised when the end_frame attribute
        is not set to an integer value
        """
        self.assertRaises(TypeError, setattr, self.test_shot, "end_frame",
                          "asdfs")
    
    def test_end_frame_attribute_is_working_properly(self):
        """testing if the end_frame attribute is working properly
        """
        test_value = 10
        self.test_shot.end_frame = test_value
        self.assertEqual(self.test_shot.end_frame, test_value)
    
    def test_end_frame_attribute_updates_the_duration_attribute(self):
        """testing if the end_frame attribute updates the duration attribute
        value
        """
        self.test_shot.end_frame = 200
        self.assertEqual(self.test_shot.start_frame, 1)
        self.assertEqual(self.test_shot.duration, 200)
    
    def test_duration_attribute_is_initialized_correctly(self):
        """testing if the duration attribute is initialized correctly 
        """
        self.assertEqual(
            self.test_shot.duration,
            self.test_shot.end_frame - self.test_shot.start_frame + 1
        ) 
    
    def test_duration_attribute_is_updated_correctly(self):
        """testing if the duration attribute is updated correctly with the
        changing values of start_frame and end_frame values
        """
        self.kwargs['number'] = '1duration'
        new_shot = Shot(**self.kwargs)
        self.assertEqual(new_shot.start_frame, 1)
        self.assertEqual(new_shot.end_frame, 100)
        new_shot.start_frame = 10
        self.assertEqual(new_shot.duration, 91)
        
        new_shot.end_frame = 110
        self.assertEqual(new_shot.duration, 101)
    
    def test_project_attribute_is_initialized_correctly(self):
        """testing if the project attribute is initialized correctly
        """
        self.assertTrue(self.test_shot.project is
                        self.kwargs["sequence"].project)

    def test_shot_is_CRUD_properly_in_the_database(self):
        """testing if the shot instance is created properly in the database
        """
        new_proj = Project("TEST_PROJ_FOR_CRUD")
        new_proj.create()
        
        new_seq = Sequence(new_proj, "TEST_SEQ103")
        new_seq.save()
        
        new_shot = Shot(new_seq, '1a')
        new_shot.save()
        
        # now query the database if it is created and read correctly
        self.assertEqual(
            new_shot,
            Shot.query()
                .filter(Shot.number==new_shot.number)
                .first()
        )
        
        # now update it
        new_shot.start_frame = 100
        new_shot.end_frame = 200
        new_shot.save()
        
        self.assertEqual(
            new_shot.start_frame,
            Shot.query()
                .filter(Shot.number==new_shot.number)
                .first()
                .start_frame
        )
        self.assertEqual(
            new_shot.end_frame,
            Shot.query()
                .filter(Shot.number==new_shot.number)
                .first()
                .end_frame
        )
        
        # now delete it
        db.session.delete(new_shot)
        db.session.commit()
        
        self.assertEqual(len(Shot.query().all()), 1)
    
    def test_equality_of_shots(self):
        """testing if the equality operator is working properly
        """
        proj1 = Project("TEST_EQ_PROJ")
        proj1.create()
        
        seq1 = Sequence(proj1, "TEST_SEQ1")
        seq2 = Sequence(proj1, "TEST_SEQ2")
        
        shot1 = Shot(seq1, 1)
        shot2 = Shot(seq1, 2)
        shot3 = Shot(seq2, 1)
        
        #shot1a = Shot(seq1, 1)
        shot1a = seq1.shots[0]
        
        self.assertTrue(shot1==shot1a)
        self.assertFalse(shot1==shot2)
        self.assertFalse(shot1a==shot3)
    
    def test_inequality_of_shots(self):
        """testing if the equality operator is working properly
        """
        proj1 = Project("TEST_EQ_PROJ")
        proj1.create()
        
        seq1 = Sequence(proj1, "TEST_SEQ1")
        seq2 = Sequence(proj1, "TEST_SEQ2")
        
        shot1 = Shot(seq1, 1)
        shot2 = Shot(seq1, 2)
        shot3 = Shot(seq2, 1)
        
        #shot1a = Shot(seq1, 1)
        shot1a = seq1.shots[0]
        
        self.assertFalse(shot1!=shot1a)
        self.assertTrue(shot1!=shot2)
        self.assertTrue(shot1a!=shot3)
    
    def test_handle_at_start_attribute_not_an_integer(self):
        """testing if a TypeError will be raised when the handles_at_start
        attribute is set anything other then an integer
        """
        
        self.assertRaises(
            TypeError, setattr, self.test_shot, "handle_at_start",
            "test value"
        )
    
    def test_handle_at_start_defaults_to_zero(self):
        """testing if the default value of handle_at_start is 0
        """
        
        self.assertEqual(self.test_shot.handle_at_start, 0)
    
    def test_handle_at_start_is_negative(self):
        """testing if a ValueError will be raised when the handle_at_start is
        a negative value
        """
        
        self.assertRaises(
            ValueError, setattr, self.test_shot, "handle_at_start", -10
        )
    
    def test_handle_at_start_is_bigger_then_duration_minus_one(self):
       """testing if a ValueError will be raised when the handle_at_start is
       bigger then the duration-1
       """
       
       self.assertRaises(
           ValueError, setattr, self.test_shot, "handle_at_start",
           self.test_shot.duration
       )
    
    def test_handles_together_are_bigger_then_duration_minus_one_while_setting_handle_at_start(self):
       """testing if a ValueError will be raised when the handle_at_start and
       handle_at_end together are greater then duration-1
       """
       
       self.test_shot.start_frame = 1
       self.test_shot.end_frame = 100
       self.test_shot.handle_at_end = 50
       self.assertRaises(
           ValueError, setattr, self.test_shot, "handle_at_start", 50
       )
    
    def test_handle_at_end_attribute_not_an_integer(self):
        """testing if a TypeError will be raised when the handles_at_start
        attribute is set anything other then an integer
        """
        
        self.assertRaises(
            TypeError, setattr, self.test_shot, "handle_at_end",
            "test value"
        )
    
    def test_handle_at_end_defaults_to_zero(self):
        """testing if the default value of handle_at_end is 0
        """
        self.assertEqual(self.test_shot.handle_at_end, 0)
    
    def test_handle_at_end_is_negative(self):
        """testing if a ValueError will be raised when the handle_at_end is
        a negative value
        """
        self.assertRaises(
            ValueError, setattr, self.test_shot, "handle_at_end", -10
        )
    
    def test_handle_at_end_is_bigger_then_duration_minus_one(self):
       """testing if a ValueError will be raised when the handle_at_end is
       bigger then the duration-1
       """
       self.assertRaises(
           ValueError, setattr, self.test_shot, "handle_at_end",
           self.test_shot.duration
       )
    
    def test_handles_together_are_bigger_then_duration_minus_one_while_setting_handle_at_end(self):
       """testing if a ValueError will be raised when the handle_at_start and
       handle_at_end together are greater then duration-1
       """
       
       self.test_shot.start_frame = 1
       self.test_shot.end_frame = 100
       self.test_shot.handle_at_start = 50
       self.assertRaises(
           ValueError, setattr, self.test_shot, "handle_at_end", 50
       )
    
    def test_deleting_a_shot_will_not_delete_the_related_project(self):
        """testing if deleting a shot will not delete the related project
        """
        proj1 = Project('test project 1')
        proj1.save()
        
        seq1 = Sequence(proj1, 'test seq 1')
        seq1.save()
        
        shot1 = Shot(seq1, 1)
        shot1.save()
        
        # check if they are in the session
        self.assertIn(proj1, db.session)
        self.assertIn(seq1, db.session)
        self.assertIn(shot1, db.session)
        
        # delete the shot
        db.session.delete(shot1)
        db.session.commit()
        
        self.assertNotIn(shot1, db.session)
        
        self.assertIn(proj1, db.session)
    
    def test_deleting_a_shot_will_not_delete_the_related_sequence(self):
        """testing if deleting a shot will not delete the related sequence
        """
        proj1 = Project('test project 1')
        proj1.save()
        
        seq1 = Sequence(proj1, 'test seq 1')
        seq1.save()
        
        shot1 = Shot(seq1, 1)
        shot1.save()
        
        # check if they are in the session
        self.assertIn(proj1, db.session)
        self.assertIn(seq1, db.session)
        self.assertIn(shot1, db.session)
        
        # delete the shot
        db.session.delete(shot1)
        db.session.commit()
        
        self.assertNotIn(shot1, db.session)
        self.assertIn(seq1, db.session)
    
    def test_deleting_a_shot_will_not_delete_the_other_shots_in_the_related_sequence(self):
        """testing if deleting a shot will not delete the other shots in the
        sequence
        """
        proj1 = Project('test project 1')
        proj1.save()
        
        seq1 = Sequence(proj1, 'test seq 1')
        seq1.save()
        
        shot1 = Shot(seq1, 1)
        shot1.save()
        
        shot2 = Shot(seq1, 2)
        shot2.save()
        
        # check if they are in the session
        self.assertIn(proj1, db.session)
        self.assertIn(seq1, db.session)
        self.assertIn(shot1, db.session)
        self.assertIn(shot2, db.session)
        
        # delete the shot
        db.session.delete(shot1)
        db.session.commit()
        
        self.assertNotIn(shot1, db.session)
        self.assertIn(shot2, db.session)
    
    def test_deleting_a_shot_will_delete_the_related_versions(self):
        """testing if deleting a shot will delete the related versions
        """
        
        proj1 = Project('test project 1')
        proj1.save()
        
        seq1 = Sequence(proj1, 'test sequence 1')
        seq1.save()
        
        shot1 = Shot(seq1, 1)
        shot1.save()
        
        shot2 = Shot(seq1, 2)
        shot2.save()
        
        user = User.query().first()
        shot_vtypes = VersionType.query().filter_by(type_for="Shot").all()
        
        # versions for shot1
        vers1 = Version(
            shot1,
            base_name=shot1.code,
            type=shot_vtypes[0],
            created_by=user
        )
        vers1.save()
        
        vers2 = Version(
            shot1,
            base_name=shot1.code,
            type=shot_vtypes[0],
            created_by=user
        )
        vers2.save()
        
        vers3 = Version(
            shot1,
            base_name=shot1.code,
            type=shot_vtypes[0],
            created_by=user
        )
        vers3.save()
        
        # versions for shot2
        vers4 = Version(
            shot2,
            base_name=shot2.code,
            type=shot_vtypes[0],
            created_by=user
        )
        vers4.save()
        
        vers5 = Version(
            shot2,
            base_name=shot2.code,
            type=shot_vtypes[0],
            created_by=user
        )
        vers5.save()
        
        vers6 = Version(
            shot2,
            base_name=shot2.code,
            type=shot_vtypes[0],
            created_by=user
        )
        vers6.save()
        
        # test all are in the session
        self.assertIn(proj1, db.session)
        self.assertIn(seq1, db.session)
        self.assertIn(shot1, db.session)
        self.assertIn(shot2, db.session)
        self.assertIn(vers1, db.session)
        self.assertIn(vers2, db.session)
        self.assertIn(vers3, db.session)
        self.assertIn(vers4, db.session)
        self.assertIn(vers5, db.session)
        self.assertIn(vers6, db.session)
        
        # delete shot1
        db.session.delete(shot1)
        db.session.commit()
        
        # check if versions are deleted
        self.assertNotIn(shot1, db.session)
        self.assertNotIn(vers1, db.session)
        self.assertNotIn(vers2, db.session)
        self.assertNotIn(vers3, db.session)
        
        # check if all the others are still there
        self.assertIn(proj1, db.session)
        self.assertIn(seq1, db.session)
        self.assertIn(shot2, db.session)
        self.assertIn(vers4, db.session)
        self.assertIn(vers5, db.session)
        self.assertIn(vers6, db.session)