def create_statuses_and_status_lists(): """Creates the statuses needed for Project, Task, Asset, Shot and Sequence entities """ # Also create basic Status and status lists for # Project, Asset, Shot, Sequence # Project project_status_list = StatusList.query\ .filter_by(target_entity_type='Project').first() if not project_status_list: project_status_list = StatusList(name='Project Statuses', target_entity_type='Project') new = Status.query.filter_by(code='NEW').first() wip = Status.query.filter_by(code='WIP').first() cmpl = Status.query.filter_by(code='CMPL').first() # now use them in status lists project_status_list.statuses = [new, wip, cmpl] # Warning! Not using scoped_session here, it is the plain old session DBSession.add_all([ project_status_list, ]) DBSession.commit()
def setUp(self): """setup the test """ super(StatusMixinTester, self).setUp() self.test_status1 = Status(name="Status1", code="STS1") self.test_status2 = Status(name="Status2", code="STS2") self.test_status3 = Status(name="Status3", code="STS3") self.test_status4 = Status(name="Status4", code="STS4") self.test_status5 = Status(name="Status5", code="STS5") # statuses which are not going to be used self.test_status6 = Status(name="Status6", code="STS6") self.test_status7 = Status(name="Status7", code="STS7") self.test_status8 = Status(name="Status8", code="STS8") # a test StatusList object self.test_status_list1 = StatusList( name="Test Status List 1", statuses=[ self.test_status1, self.test_status2, self.test_status3, self.test_status4, self.test_status5, ], target_entity_type="StatMixClass", ) # another test StatusList object self.test_status_list2 = StatusList( name="Test Status List 2", statuses=[ self.test_status1, self.test_status2, self.test_status3, self.test_status4, self.test_status5, ], target_entity_type="StatMixClass", ) self.kwargs = { "name": "Test Class", "status_list": self.test_status_list1, "status": self.test_status_list1.statuses[0], } self.test_mixed_obj = StatMixClass(**self.kwargs) self.test_mixed_obj.status_list = self.test_status_list1 # create another one without status_list set to something self.test_mixed_obj2 = StatMixClass(**self.kwargs)
def create_entity_statuses(entity_type="", status_names=None, status_codes=None, user=None): """creates the default task statuses """ if not entity_type: raise ValueError("Please supply entity_type") if not status_names: raise ValueError("Please supply status names") if not status_codes: raise ValueError("Please supply status codes") # create statuses for entity from stalker import Status, StatusList logger.debug("Creating %s Statuses" % entity_type) statuses = Status.query.filter(Status.name.in_(status_names)).all() status_names_in_db = map(lambda x: x.name, statuses) for name, code in zip(status_names, status_codes): if name not in status_names_in_db: logger.debug("Creating Status: %s (%s)" % (name, code)) new_status = Status(name=name, code=code, created_by=user, updated_by=user) statuses.append(new_status) DBSession.add(new_status) # create the Status List status_list = StatusList.query.filter(StatusList.target_entity_type == entity_type).first() if status_list is None: logger.debug("No %s Status List found, creating new!" % entity_type) status_list = StatusList( name="%s Statuses" % entity_type, target_entity_type=entity_type, created_by=user, updated_by=user ) else: logger.debug("%s Status List already created, updating statuses" % entity_type) status_list.statuses = statuses DBSession.add(status_list) try: DBSession.commit() except IntegrityError as e: logger.debug("error in DBSession.commit, rolling back: %s" % e) DBSession.rollback() else: logger.debug("Created %s Statuses successfully" % entity_type) DBSession.flush()
def test_update_statuses_is_working_properly_with_patch(self): """testing if PATCH: /api/status_lists/{id}/statuses view is working properly """ from stalker import db, Status, StatusList test_status1 = Status(name='Test Status 1', code='TST1') test_status2 = Status(name='Test Status 2', code='TST2') test_status3 = Status(name='Test Status 3', code='TST3') test_status4 = Status(name='Test Status 4', code='TST4') test_status5 = Status(name='Test Status 5', code='TST5') test_status_list = StatusList( name='Test Status List', target_entity_type='Project', statuses=[test_status1, test_status2, test_status3, test_status4]) db.DBSession.add_all([ test_status1, test_status2, test_status3, test_status4, test_status5, test_status_list ]) db.DBSession.commit() response = self.test_app.patch('/api/status_lists/%s/statuses' % test_status_list.id, params={'status_id': [test_status5.id]}, status=200) self.maxDiff = None self.assertEqual( sorted(test_status_list.statuses), sorted([ test_status1, test_status2, test_status3, test_status4, test_status5 ]))
def test_delete_entity_is_working_properly(self): """testing if the DELETE: /api/status_list/{id} view is working properly """ from stalker import db, Status, StatusList test_status1 = Status(name='Test Status 1', code='TST1') test_status2 = Status(name='Test Status 2', code='TST2') test_status3 = Status(name='Test Status 3', code='TST3') test_status4 = Status(name='Test Status 4', code='TST4') test_status5 = Status(name='Test Status 5', code='TST5') test_status_list = StatusList( name='Status List', statuses=[test_status1, test_status2, test_status3, test_status4], target_entity_type='Project', created_by=self.admin) db.DBSession.add_all([ test_status1, test_status2, test_status3, test_status4, test_status5, test_status_list ]) db.DBSession.commit() self.test_app.delete('/api/status_lists/%s' % test_status_list.id) # normally we shouldn't need a commit db.DBSession.commit() test_status_list_db = StatusList.query.get(test_status_list.id) self.assertIsNone(test_status_list_db)
def test_get_entities_is_working_properly(self): """testing if GET: /api/status_lists view is working properly """ from stalker import db, Status, StatusList test_status1 = Status(name='Test Status 1', code='TST1') test_status2 = Status(name='Test Status 2', code='TST2') test_status3 = Status(name='Test Status 3', code='TST3') test_status4 = Status(name='Test Status 4', code='TST4') test_status5 = Status(name='Test Status 5', code='TST5') test_status_list_1 = StatusList( name='Status List 1', statuses=[test_status1, test_status2, test_status3, test_status4], target_entity_type='Project', created_by=self.admin) db.DBSession.add_all([ test_status1, test_status2, test_status3, test_status4, test_status5, test_status_list_1 ]) db.DBSession.commit() # get the default status lists s_lists = StatusList.query.all() response = self.test_app.get('/api/status_lists', status=200) self.assertEqual(response.json_body, [{ 'id': sl.id, '$ref': '/api/status_lists/%s' % sl.id, 'name': sl.name, 'entity_type': sl.entity_type } for sl in s_lists])
def test_delete_statuses_is_working_properly(self): """testing if delete_statuses() method is working properly """ from stalker import db, Status, StatusList test_status1 = Status(name='Test Status 1', code='TST1') test_status2 = Status(name='Test Status 2', code='TST2') test_status3 = Status(name='Test Status 3', code='TST3') test_status4 = Status(name='Test Status 4', code='TST4') test_status5 = Status(name='Test Status 5', code='TST5') test_status_list = StatusList( name='Test Status List', target_entity_type='Project', statuses=[test_status1, test_status2, test_status3, test_status4]) db.DBSession.add_all([ test_status1, test_status2, test_status3, test_status4, test_status5, test_status_list ]) db.DBSession.commit() from stalker_pyramid.testing import DummyRequest, DummyMultiDict request = DummyRequest() request.matchdict['id'] = test_status_list.id request.params = DummyMultiDict() request.params['status_id'] = [test_status4.id] status_list_view = status.StatusListViews(request) status_list_view.delete_statuses() self.maxDiff = None self.assertEqual(sorted(test_status_list.statuses), sorted([test_status1, test_status2, test_status3]))
def test_get_entities_is_working_properly_with_filters(self): """testing if get_entities() method is working properly with filters """ from stalker import db, Status, StatusList test_status1 = Status(name='Test Status 1', code='TST1') test_status2 = Status(name='Test Status 2', code='TST2') test_status3 = Status(name='Test Status 3', code='TST3') test_status4 = Status(name='Test Status 4', code='TST4') test_status5 = Status(name='Test Status 5', code='TST5') test_status_list_1 = StatusList( name='Status List 1', statuses=[test_status1, test_status2, test_status3, test_status4], target_entity_type='Project', created_by=self.admin) db.DBSession.add_all([ test_status1, test_status2, test_status3, test_status4, test_status5, test_status_list_1 ]) db.DBSession.commit() from stalker_pyramid.testing import DummyRequest, DummyMultiDict request = DummyRequest() request.params = DummyMultiDict() request.params['target_entity_type'] = 'Project' status_list_view = status.StatusListViews(request) response = status_list_view.get_entities() self.assertEqual(response.json_body, [{ 'id': sl.id, '$ref': '/api/status_lists/%s' % sl.id, 'name': sl.name, 'entity_type': sl.entity_type } for sl in [test_status_list_1]])
def test_status_list_attribute_is_skipped_and_there_is_a_db_setup(self): """testing if there will be no error and the status_list attribute is filled with the correct StatusList instance coming from the database if there is already a database setup and there is a StatusList instance defined for the StatusListAutoAddClass. """ # create a StatusList for StatusListAutoAddClass test_status_list = StatusList( name="StatusListAutoAddClass Statuses", statuses=[ Status(name="Status1", code="Sts1"), Status(name="Status2", code="Sts2"), Status(name="Status3", code="Sts3"), ], target_entity_type=StatusListAutoAddClass, ) # add it to the db db.DBSession.add(test_status_list) db.DBSession.commit() # now try to create a StatusListAutoAddClass without a status_list # argument test_StatusListAutoAddClass = StatusListAutoAddClass( name="Test StatusListAutoAddClass", ) # now check if the status_list is equal to test_status_list self.assertEqual( test_StatusListAutoAddClass.status_list, test_status_list )
def test_delete_statuses_is_working_properly(self): """testing if DELETE: /api/status_lists/{id}/statuses view is working properly """ from stalker import db, Status, StatusList test_status1 = Status(name='Test Status 1', code='TST1') test_status2 = Status(name='Test Status 2', code='TST2') test_status3 = Status(name='Test Status 3', code='TST3') test_status4 = Status(name='Test Status 4', code='TST4') test_status5 = Status(name='Test Status 5', code='TST5') test_status_list = StatusList( name='Test Status List', target_entity_type='Project', statuses=[test_status1, test_status2, test_status3, test_status4]) db.DBSession.add_all([ test_status1, test_status2, test_status3, test_status4, test_status5, test_status_list ]) db.DBSession.commit() self.test_app.delete('/api/status_lists/%s/statuses?status_id=%s' % (test_status_list.id, test_status4.id)) test_status_list_db = StatusList.query\ .filter(StatusList.name == test_status_list.name).first() self.maxDiff = None self.assertEqual(sorted(test_status_list_db.statuses), sorted([test_status1, test_status2, test_status3]))
def test_delete_statuses_is_working_properly_with_non_related_statuses( self): """testing if delete_statuses() method is working properly with statuses that is not in the statuses list """ from stalker import db, Status, StatusList test_status1 = Status(name='Test Status 1', code='TST1') test_status2 = Status(name='Test Status 2', code='TST2') test_status3 = Status(name='Test Status 3', code='TST3') test_status4 = Status(name='Test Status 4', code='TST4') test_status5 = Status(name='Test Status 5', code='TST5') test_status_list = StatusList( name='Test Status List', target_entity_type='Project', statuses=[test_status1, test_status2, test_status3, test_status4]) db.DBSession.add_all([ test_status1, test_status2, test_status3, test_status4, test_status5, test_status_list ]) db.DBSession.commit() self.test_app.delete( '/api/status_lists/%s/statuses?status_id=%s&status_id=%s' % (test_status_list.id, test_status4.id, test_status5.id)) self.maxDiff = None self.assertEqual(sorted(test_status_list.statuses), sorted([test_status1, test_status2, test_status3]))
def test_status_list_attribute_is_skipped_and_there_is_a_db_setup_but_no_suitable_StatusList(self): """testing if a TypeError will be raised even a database is setup but there is no suitable StatusList for StatusListNoAutoAddClass in the database """ # create a StatusList for StatusListAutoAddClass test_status_list = StatusList( name="StatusListAutoAddClass Statuses", statuses=[ Status(name="Status1", code="Sts1"), Status(name="Status2", code="Sts2"), Status(name="Status3", code="Sts3"), ], target_entity_type=StatusListAutoAddClass, ) # add it to the db db.DBSession.add(test_status_list) db.DBSession.commit() # now try to create a StatusListAutoAddClass without a status_list # argument with self.assertRaises(TypeError) as cm: StatusListNoAutoAddClass(name="Test StatusListNoAutoAddClass") self.assertEqual( str(cm.exception), "StatusListNoAutoAddClass instances can not be initialized " "without a stalker.models.status.StatusList instance, please pass " "a suitable StatusList " "(StatusList.target_entity_type=StatusListNoAutoAddClass) with " "the 'status_list' argument" )
def test_ProjectMixin_initialization(self): """testing if the ProjectMixin part is initialized correctly """ from stalker import Status, StatusList status1 = Status(name="On Hold", code="OH") project_status_list = StatusList( name="Project Statuses", statuses=[status1], target_entity_type='Project' ) from stalker import Type project_type = Type( name="Commercial", code='comm', target_entity_type='Project' ) from stalker import Project new_project = Project( name="Test Project", code='tp', status=project_status_list[0], status_list=project_status_list, type=project_type, repository=self.test_repository ) from stalker import Sequence self.kwargs["project"] = new_project new_sequence = Sequence(**self.kwargs) self.assertEqual(new_sequence.project, new_project)
def setUp(self): """let's create proper values for the tests """ super(StatusListTest, self).setUp() self.kwargs = { "name": "a status list", "description": "this is a status list for testing purposes", "statuses": [ Status.query.filter_by(code="WFD").first(), Status.query.filter_by(code="RTS").first(), Status.query.filter_by(code="WIP").first(), Status.query.filter_by(code="PREV").first(), Status.query.filter_by(code="HREV").first(), Status.query.filter_by(code="CMPL").first(), Status.query.filter_by(code="OH").first(), ], "target_entity_type": "Project", } self.test_status_list = StatusList(**self.kwargs) from stalker import db db.DBSession.add(self.test_status_list) db.DBSession.commit()
def setUp(self): """set the test up """ from stalker import Status, StatusList, Repository self.test_repo = Repository(name='Test Repo') self.status_new = Status(name='New', code='NEW') self.status_wip = Status(name='Work In Progress', code='WIP') self.status_cmpl = Status(name='Completed', code='CMPL') self.project_statuses = StatusList( name='Project Status List', statuses=[self.status_new, self.status_wip, self.status_cmpl], target_entity_type='Project') from stalker import User self.test_user1 = User(name='Test User 1', login='******', email='*****@*****.**', password='******') from stalker import Project self.test_project = Project(name='Test Project 1', code='TP1', repositories=[self.test_repo], status_list=self.project_statuses) from stalker import Role self.test_role = Role(name='Test User')
def setUp(self): """setup the test """ # create a repository self.repository_type = Type(name="Test Repository Type", code='testproj', target_entity_type=Repository) self.test_repository = Repository( name="Test Repository", type=self.repository_type, ) # statuses self.status1 = Status(name="Status1", code="STS1") self.status2 = Status(name="Status2", code="STS2") self.status3 = Status(name="Status3", code="STS3") # project status list self.project_status_list = StatusList(name="Project Status List", statuses=[ self.status1, self.status2, self.status3, ], target_entity_type=Project) # project type self.test_project_type = Type( name="Test Project Type", code='testproj', target_entity_type=Project, ) # create projects self.test_project1 = Project( name="Test Project 1", code='tp1', type=self.test_project_type, status_list=self.project_status_list, repository=self.test_repository, ) self.test_project2 = Project( name="Test Project 2", code='tp2', type=self.test_project_type, status_list=self.project_status_list, repository=self.test_repository, ) self.kwargs = { "name": "Test Class", "project": self.test_project1, } self.test_foo_obj = ProjMixClass(**self.kwargs)
def setUp(self): """setting up the test """ super(PageTester, self).setUp() # create a repository from stalker import Type self.repository_type = Type(name="Test Repository Type", code='test_repo', target_entity_type='Repository') from stalker import Repository self.test_repository = Repository( name="Test Repository", code="TR", type=self.repository_type, ) # statuses from stalker import Status self.status1 = Status(name="Status1", code="STS1") self.status2 = Status(name="Status2", code="STS2") self.status3 = Status(name="Status3", code="STS3") # project status list from stalker import StatusList self.project_status_list = StatusList(name="Project Status List", statuses=[ self.status1, self.status2, self.status3, ], target_entity_type='Project') # project type self.test_project_type = Type( name="Test Project Type", code='testproj', target_entity_type='Project', ) # create projects from stalker import Project self.test_project1 = Project( name="Test Project 1", code='tp1', type=self.test_project_type, status_list=self.project_status_list, repository=self.test_repository, ) self.kwargs = { 'title': 'Test Page Title', 'content': 'Test content', 'project': self.test_project1 } self.test_page = Page(**self.kwargs)
def setUp(self): """setup the test """ # create a resource self.test_resource1 = User( name="User1", login="******", email="*****@*****.**", password="******", ) self.test_resource2 = User( name="User2", login="******", email="*****@*****.**", password="******" ) self.test_repo = Repository(name="test repository") # create a Project self.test_status1 = Status(name="Status1", code="STS1") self.test_status2 = Status(name="Status2", code="STS2") self.test_status3 = Status(name="Status3", code="STS3") self.test_project_status_list = StatusList( name="Project Statuses", statuses=[self.test_status1], target_entity_type=Project ) self.test_task_status_list = StatusList.query\ .filter_by(target_entity_type='Task').first() self.test_project = Project( name="test project", code='tp', repository=self.test_repo, status_list=self.test_project_status_list ) # create a Task self.test_task = Task( name="test task", project=self.test_project, status_list=self.test_task_status_list ) self.kwargs = { "task": self.test_task, "resource": self.test_resource1, "start": datetime.datetime(2013, 3, 22, 1, 0), "duration": datetime.timedelta(10) } # create a TimeLog # and test it self.test_time_log = TimeLog(**self.kwargs)
def setUpClass(cls): """setup once """ db.setup() db.init() cls.status_new = Status.query.filter_by(code='NEW').first() cls.status_wip = Status.query.filter_by(code='WIP').first() cls.status_cmpl = Status.query.filter_by(code='CMPL').first() cls.test_project_status_list = StatusList( name='Project Statuses', target_entity_type='Project', statuses=[cls.status_new, cls.status_wip, cls.status_cmpl]) cls.test_repo = Repository(name='Test Repository') cls.test_project = Project(name='Test Project', code='TP', repository=cls.test_repo, status_list=cls.test_project_status_list) cls.test_task1 = Task(name='Test Task 1', project=cls.test_project) cls.test_task2 = Task(name='Test Task 2', project=cls.test_project) cls.test_task3 = Task(name='Test Task 3', project=cls.test_project) cls.test_version1 = Version(task=cls.test_task1) db.DBSession.add(cls.test_version1) db.DBSession.commit() cls.test_version2 = Version(task=cls.test_task1) db.DBSession.add(cls.test_version2) db.DBSession.commit() cls.test_version3 = Version(task=cls.test_task1) db.DBSession.add(cls.test_version3) db.DBSession.commit() cls.test_version4 = Version(task=cls.test_task2) db.DBSession.add(cls.test_version4) db.DBSession.commit() cls.test_link1 = Link(original_filename='test_render1.jpg') cls.test_link2 = Link(original_filename='test_render2.jpg') cls.test_link3 = Link(original_filename='test_render3.jpg') cls.test_link4 = Link(original_filename='test_render4.jpg') cls.test_version1.outputs = [ cls.test_link1, cls.test_link2, cls.test_link3 ] cls.test_version4.outputs = [cls.test_link4] db.DBSession.add_all([ cls.test_task1, cls.test_task2, cls.test_task3, cls.test_version1, cls.test_version2, cls.test_version3, cls.test_version4, cls.test_link1, cls.test_link2, cls.test_link3, cls.test_link4 ]) db.DBSession.commit()
def setUp(self): """set up the test """ db.setup() db.init() self.temp_path = tempfile.mkdtemp() self.repo = Repository( name='Test Repository', linux_path=self.temp_path, windows_path=self.temp_path, osx_path=self.temp_path ) self.status_new = Status.query.filter_by(code='NEW').first() self.status_wip = Status.query.filter_by(code='WIP').first() self.status_cmpl = Status.query.filter_by(code='CMPL').first() self.project_status_list = StatusList( target_entity_type='Project', name='Project Statuses', statuses=[self.status_new, self.status_wip, self.status_cmpl] ) self.task_filename_template = FilenameTemplate( name='Task Filename Template', target_entity_type='Task', path='{{project.code}}/{%- for parent_task in parent_tasks -%}' '{{parent_task.nice_name}}/{%- endfor -%}', filename='{{version.nice_name}}' '_v{{"%03d"|format(version.version_number)}}{{extension}}' ) self.project_structure = Structure( name='Project Structure', templates=[self.task_filename_template] ) self.project = Project( name='Test Project', code='TP', status_list=self.project_status_list, repository=self.repo, structure=self.project_structure ) self.task = Task( name='Test Task', project=self.project ) self.version = Version( task=self.task ) self.kwargs = { 'name': 'Photoshop', 'extensions': ['psd'], 'structure': ['Outputs'] } self.external_env = ExternalEnv(**self.kwargs)
def setUp(self): """setup the test """ super(StatusMixinTester, self).setUp() self.test_stat1 = Status(name="On Hold", code="OH") self.test_stat2 = Status(name="Work In Progress", code="WIP") self.test_stat3 = Status(name="Approved", code="APP") self.test_a_statusList = StatusList( name="A Statuses", statuses=[self.test_stat1, self.test_stat3], target_entity_type="DeclStatMixA", ) self.test_b_statusList = StatusList( name="B Statuses", statuses=[self.test_stat2, self.test_stat3], target_entity_type="DeclStatMixB") self.kwargs = {"name": "ozgur", "status_list": self.test_a_statusList}
def test_inequality_operator(self): """testing equality of two status list object """ status_list1 = StatusList(**self.kwargs) status_list2 = StatusList(**self.kwargs) self.kwargs["target_entity_type"] = "SomeOtherClass" status_list3 = StatusList(**self.kwargs) self.kwargs["statuses"] = [ Status(name="Started", code="STRT"), Status(name="Waiting For Approve", code="WAPPR"), Status(name="Approved", code="APPR"), Status(name="Finished", code="FNSH"), ] status_list4 = StatusList(**self.kwargs) self.assertFalse(status_list1 != status_list2) self.assertTrue(status_list1 != status_list3) self.assertTrue(status_list1 != status_list4)
def test_statuses_argument_accepts_statuses_only(self): """testing if statuses list argument accepts list of statuses only """ # the statuses argument should be a list of statuses # can be empty? test_value = "a str" # it should only accept lists of statuses self.kwargs["statuses"] = test_value with self.assertRaises(TypeError) as cm: StatusList(**self.kwargs) self.assertEqual(str(cm.exception), 'Incompatible collection type: str is not list-like')
def test_indexing_get_string_indexes(self): """testing indexing of statuses in the statusList, get with string """ status1 = Status(name="Complete", code="CMPLT") status2 = Status(name="Work in Progress", code="WIP") status3 = Status(name="Pending Review", code="PRev") a_status_list = StatusList(name="Asset Status List", statuses=[status1, status2, status3], target_entity_type="Asset") self.assertEqual(a_status_list[0], a_status_list["complete"]) self.assertEqual(a_status_list[1], a_status_list["wip"])
def test_TaskableEntity_initialization(self): """testing if the TaskableEntity part is initialized correctly """ from stalker import Status, StatusList status1 = Status(name="On Hold", code="OH") project_status_list = StatusList( name="Project Statuses", statuses=[status1], target_entity_type='Project', ) from stalker import Type, Project, Sequence, Task project_type = Type( name="Commercial", code='comm', target_entity_type='Project' ) new_project = Project( name="Commercial", code='comm', status_list=project_status_list, type=project_type, repository=self.test_repository, ) self.kwargs["new_project"] = new_project new_sequence = Sequence(**self.kwargs) task1 = Task( name="Modeling", status=0, project=new_project, parent=new_sequence, ) task2 = Task( name="Lighting", status=0, project=new_project, parent=new_sequence, ) tasks = [task1, task2] self.assertEqual( sorted(new_sequence.tasks, key=lambda x: x.name), sorted(tasks, key=lambda x: x.name) )
def test_statuses_argument_elements_being_status_objects(self): """testing status_list elements against not being derived from Status class """ # every element should be an object derived from Status a_fake_status_list = [1, 2, "a string", 4.5] self.kwargs["statuses"] = a_fake_status_list with pytest.raises(TypeError) as cm: StatusList(**self.kwargs) assert str(cm.value) == \ 'All of the elements in StatusList.statuses must be an instance ' \ 'of stalker.models.status.Status, and not int'
def test_status_list_attribute_is_working_properly(self): """testing if the status_list attribute is working properly """ new_suitable_list = StatusList(name="Suitable Statuses", statuses=[ Status(name="On Hold", code="OH"), Status(name="Complete", code="CMPLT"), ], target_entity_type="StatMixClass") # this shouldn't raise any error self.test_mixed_obj.status_list = new_suitable_list assert self.test_mixed_obj.status_list == new_suitable_list
def test_message_instance_creation(self): """testing message instance creation """ from stalker import Status, StatusList status_unread = Status(name='Unread', code='UR') status_read = Status(name='Read', code='READ') status_replied = Status(name='Replied', code='REP') message_status_list = StatusList( name='Message Statuses', statuses=[status_unread, status_read, status_replied], target_entity_type='Message') new_message = Message(description='This is a test message', status_list=message_status_list) self.assertEqual(new_message.description, 'This is a test message')
def setUp(self): """let's create proper values for the tests """ self.kwargs = { "name": "a status list", "description": "this is a status list for testing purposes", "statuses": [ Status(name="Not Available", code="N/A"), Status(name="Waiting To Start", code="WSTRT"), Status(name="Started", code="STRT"), Status(name="Waiting For Approve", code="WAPPR"), Status(name="Approved", code="APPR"), Status(name="Completed", code="COMP"), Status(name="On Hold", code="OH"), ], "target_entity_type": "Project", } self.test_status_list = StatusList(**self.kwargs)
def test_TaskMixin_initialization(self): """testing if the TaskMixin part is initialized correctly """ status1 = Status(name="On Hold", code="OH") project_status_list = StatusList(name="Project Statuses", statuses=[status1], target_entity_type=Project) project_type = Type(name="Commercial", code='comm', target_entity_type=Project) new_project = Project( name="Commercial1", code='comm1', status_list=project_status_list, type=project_type, repository=self.test_repository, ) self.kwargs["code"] = "SH12314" new_shot = Shot(**self.kwargs) task1 = Task( name="Modeling", status=0, project=new_project, parent=new_shot, ) task2 = Task( name="Lighting", status=0, project=new_project, parent=new_shot, ) tasks = [task1, task2] self.assertEqual(sorted(new_shot.tasks, key=lambda x: x.name), sorted(tasks, key=lambda x: x.name))
def test_status_list_argument_suitable_for_the_current_class(self): """testing if a TypeError will be raised when the Status.target_entity_type is not compatible with the current class """ # create a new status list suitable for another class with different # entity_type new_status_list = StatusList(name="Sequence Statuses", statuses=[ Status(name="On Hold", code="OH"), Status(name="Complete", code="CMPLT"), ], target_entity_type="Sequence") with pytest.raises(TypeError) as cm: self.test_mixed_obj.status_list = new_status_list assert str(cm.value) == \ "The given StatusLists' target_entity_type is Sequence, whereas " \ "the entity_type of this object is StatMixClass"