Пример #1
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)
Пример #2
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)
Пример #3
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)
Пример #4
0
 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)
Пример #5
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)
Пример #6
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"),
     ]
Пример #7
0
    def _updateSequenceObject(self):
        """updates the sequence object if it is not
        """
        currentSequenceName = self.getCurrentSequenceName()

        #assert(isinstance(self._sequence,Sequence))
        if self._sequence is None or \
           self._sequence.name != currentSequenceName and \
           (currentSequenceName != "" or currentSequenceName is not None) or \
           self._sequence.projectName != self._project.name:
            self._updateProjectObject()
            newSeq = Sequence(self._project, currentSequenceName)
            if newSeq._exists:
                self._sequence = newSeq
Пример #8
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)
Пример #9
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")
Пример #10
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)