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" ) self.assertRaises( TypeError, setattr, self.test_mixed_obj, "status_list", new_status_list ) 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
def setUp(self): """setup the test """ super(ProjectMixinTester, 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_status_list_1 = StatusList( name="A Statuses", statuses=[self.test_stat1, self.test_stat3], target_entity_type=DeclProjMixA, ) self.test_status_list_2 = StatusList( name="B Statuses", statuses=[self.test_stat2, self.test_stat3], target_entity_type=DeclProjMixB ) self.test_project_statuses = StatusList( name="Project Statuses", statuses=[self.test_stat2, self.test_stat3], target_entity_type='Project' ) self.test_project_type = Type( name='Test Project Type', code='testproj', target_entity_type='Project', ) self.test_repository = Repository( name="Test Repo", code='TR', ) self.test_project = Project( name="Test Project", code='tp', type=self.test_project_type, status_list=self.test_project_statuses, repository=self.test_repository, ) self.kwargs = { "name": "ozgur", "status_list": self.test_status_list_1, "project": self.test_project, } self.test_a_obj = DeclProjMixA(**self.kwargs)
def setUp(self): """setup the test """ 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 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 DBSession.add(test_status_list) DBSession.commit() # now try to create a StatusListAutoAddClass without a status_list # argument self.assertRaises( TypeError, StatusListNoAutoAddClass, **{"name": "Test StatusListNoAutoAddClass"} )
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 DBSession.add(test_status_list) 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 setUp(self): """setup the test """ 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}
from stalker.db.session import DBSession from stalker.models.status import Status, StatusList from stalker.models.task import Task from stalker.models.type import Type DBSession.remove() DBSession.configure(extension=None) db.setup() status1 = Status(name="Complete", code="CMPLT") status2 = Status(name="Pending Review", code="PRev") repo1 = Repository(name="TestRepo") project_status_list = StatusList(name="test", target_entity_type=Project, statuses=[status1]) project_type = Type(name="test", code='test', target_entity_type=Project) new_project1 = Project(name="test project1", code='tp1', type=project_type, status_list=project_status_list, repository=repo1) new_project2 = Project(name="test project2", code='tp2', type=project_type, status_list=project_status_list, repository=repo1)