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)
    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)
    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, [])
    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)
    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()
    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()
    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")
    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)
    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)
 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))
Beispiel #11
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)
 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')
Beispiel #13
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)
    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)
 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)
    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))
 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)
    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()
Beispiel #19
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)
    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)
    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)
Beispiel #22
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)
Beispiel #23
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)
    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)
    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)
Beispiel #26
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"),
        ]
    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)
Beispiel #28
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"),
     ]
    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()
    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")