def test_client_attribute_is_working_properly(self): """testing if the client attribute value an be changed properly """ from stalker import Invoice test_invoice = Invoice(budget=self.test_budget, client=self.test_client, amount=100, unit='TRY') from stalker import Client test_client = Client(name='Test Client 2') self.assertNotEqual(test_invoice.client, test_client) test_invoice.client = test_client self.assertEqual(test_invoice.client, test_client)
def test_client_attribute_is_set_to_None(self): """testing if a TypeError will be raised when the client attribute is set to None """ from stalker import Invoice test_invoice = Invoice(budget=self.test_budget, client=self.test_client, amount=100, unit='TRY') with pytest.raises(TypeError) as cm: test_invoice.client = None assert str(cm.value) == \ 'Invoice.client should be a Client instance, not NoneType'
def test_budget_attribute_is_set_to_None(self): """testing if a TypeError will ve raised when the budget attribute is set to None """ from stalker import Invoice test_invoice = Invoice(budget=self.test_budget, client=self.test_client, amount=1500, unit='TRY') with self.assertRaises(TypeError) as cm: test_invoice.budget = None self.assertEqual( str(cm.exception), 'Invoice.budget should be a Budget instance, not NoneType')
def test_budget_attribute_is_set_to_a_value_other_than_a_budget_instance( self): """testing if a TypeError will be raised when the Budget attribute is set to a value other than a Budget instance """ from stalker import Invoice test_invoice = Invoice(budget=self.test_budget, client=self.test_client, amount=1500, unit='TRY') with pytest.raises(TypeError) as cm: test_invoice.budget = 'Not a budget instance' assert str(cm.value) == \ 'Invoice.budget should be a Budget instance, not str'
def test_client_attribute_is_set_to_a_value_other_than_a_client_instance( self): """testing if a TypeError will be raised when the client attribute is set to a value other than a Client instance """ from stalker import Invoice test_invoice = Invoice(budget=self.test_budget, client=self.test_client, amount=100, unit='TRY') with self.assertRaises(TypeError) as cm: test_invoice.client = 'not a client instance' self.assertEqual( str(cm.exception), 'Invoice.client should be a Client instance, not str')
def test_client_argument_is_working_properly(self): """testing if the client argument value is correctly passed to the client attribute """ from stalker import Invoice test_invoice = Invoice(budget=self.test_budget, client=self.test_client, amount=100, unit='TRY') self.assertEqual(test_invoice.client, self.test_client)
def test_client_argument_is_skipped(self): """testing if a TypeError will be raised when the client argument is skipped """ from stalker import Invoice with pytest.raises(TypeError) as cm: Invoice(budget=self.test_budget, amount=100, unit='TRY') assert str(cm.value) == \ 'Invoice.client should be a Client instance, not NoneType'
def test_budget_argument_is_working_properly(self): """testing if the budget argument value is properly passed to the budget attribute """ from stalker import Invoice test_invoice = Invoice(budget=self.test_budget, client=self.test_client, amount=1500, unit='TRY') assert test_invoice.budget == self.test_budget
def test_invoice_attribute_is_working_properly(self): """testing if the invoice attribute value can be correctly changed """ from stalker import Payment, Invoice p = Payment(invoice=self.test_invoice, amount=1499, unit='TRY') new_invoice = Invoice(budget=self.test_budget, client=self.test_client, amount=2500, unit='TRY') self.assertNotEqual(p.invoice, new_invoice) p.invoice = new_invoice self.assertEqual(p.invoice, new_invoice)
def test_budget_argument_is_not_a_budget_instance(self): """testing if a TypeError will be raised when the Budget argument is not a Budget instance """ from stalker import Invoice with pytest.raises(TypeError) as cm: Invoice(budget='Not a budget instance', client=self.test_client, amount=1500, unit='TRY') assert str(cm.value) == \ 'Invoice.budget should be a Budget instance, not str'
def test_client_argument_is_skipped(self): """testing if a TypeError will be raised when the client argument is skipped """ from stalker import Invoice with self.assertRaises(TypeError) as cm: test_invoice = Invoice(budget=self.test_budget, amount=100, unit='TRY') self.assertEqual( str(cm.exception), 'Invoice.client should be a Client instance, not NoneType')
def test_creating_an_invoice_instance(self): """testing creation of an Invoice instance """ from stalker import Invoice import datetime invoice = Invoice( budget=self.test_budget, amount=1500, unit='TL', client=self.test_client, date_created=datetime.datetime.today(), ) self.assertIsInstance(invoice, Invoice)
def test_client_argument_is_not_a_client_instance(self): """testing if a TypeError will be raised when the client argument is not a Client instance """ from stalker import Invoice with pytest.raises(TypeError) as cm: test_invoice = Invoice(budget=self.test_budget, client='not a client instance', amount=100, unit='TRY') assert str(cm.value) == \ 'Invoice.client should be a Client instance, not str'
def test_creating_an_invoice_instance(self): """testing creation of an Invoice instance """ from stalker import Invoice import datetime import pytz invoice = Invoice( budget=self.test_budget, amount=1500, unit='TL', client=self.test_client, date_created=datetime.datetime(2016, 11, 7, tzinfo=pytz.utc), ) assert isinstance(invoice, Invoice)
def test_budget_argument_is_not_a_budget_instance(self): """testing if a TypeError will be raised when the Budget argument is not a Budget instance """ from stalker import Invoice with self.assertRaises(TypeError) as cm: test_invoice = Invoice(budget='Not a budget instance', client=self.test_client, amount=1500, unit='TRY') self.assertEqual( str(cm.exception), 'Invoice.budget should be a Budget instance, not str')
def setUp(self): """run once """ from stalker import defaults import datetime defaults.timing_resolution = datetime.timedelta(hours=1) # create a new session from stalker import db db.setup({'sqlalchemy.url': 'sqlite://', 'sqlalchemy.echo': False}) db.init() from stalker import Status self.status_wfd = Status.query.filter_by(code="WFD").first() self.status_rts = Status.query.filter_by(code="RTS").first() self.status_wip = Status.query.filter_by(code="WIP").first() self.status_prev = Status.query.filter_by(code="PREV").first() self.status_hrev = Status.query.filter_by(code="HREV").first() self.status_drev = Status.query.filter_by(code="DREV").first() self.status_oh = Status.query.filter_by(code="OH").first() self.status_stop = Status.query.filter_by(code="STOP").first() self.status_cmpl = Status.query.filter_by(code="CMPL").first() self.status_new = Status.query.filter_by(code='NEW').first() self.status_app = Status.query.filter_by(code='APP').first() from stalker import StatusList self.budget_status_list = StatusList( name='Budget Statuses', target_entity_type='Budget', statuses=[self.status_new, self.status_prev, self.status_app]) db.DBSession.add(self.budget_status_list) self.task_status_list = StatusList.query\ .filter_by(target_entity_type='Task').first() from stalker import Project self.test_project_status_list = StatusList( name="Project Statuses", statuses=[self.status_wip, self.status_prev, self.status_cmpl], target_entity_type=Project, ) from stalker import Type self.test_movie_project_type = Type( name="Movie Project", code='movie', target_entity_type=Project, ) from stalker import Repository self.test_repository_type = Type( name="Test Repository Type", code='test', target_entity_type=Repository, ) self.test_repository = Repository( name="Test Repository", type=self.test_repository_type, ) from stalker import User self.test_user1 = User(name="User1", login="******", email="*****@*****.**", password="******") self.test_user2 = User(name="User2", login="******", email="*****@*****.**", password="******") self.test_user3 = User(name="User3", login="******", email="*****@*****.**", password="******") self.test_user4 = User(name="User4", login="******", email="*****@*****.**", password="******") self.test_user5 = User(name="User5", login="******", email="*****@*****.**", password="******") from stalker import Client self.test_client = Client(name='Test Client', ) self.test_project = Project(name="Test Project1", code='tp1', type=self.test_movie_project_type, status_list=self.test_project_status_list, repository=self.test_repository, clients=[self.test_client]) from stalker import Budget self.test_budget = Budget( project=self.test_project, name='Test Budget 1', ) from stalker import Invoice self.test_invoice = Invoice(budget=self.test_budget, client=self.test_client, amount=1500, unit='TRY')
def setUp(self): """run once """ super(PaymentTestCase, self).setUp() from stalker import db, Status self.status_wfd = Status.query.filter_by(code="WFD").first() self.status_rts = Status.query.filter_by(code="RTS").first() self.status_wip = Status.query.filter_by(code="WIP").first() self.status_prev = Status.query.filter_by(code="PREV").first() self.status_hrev = Status.query.filter_by(code="HREV").first() self.status_drev = Status.query.filter_by(code="DREV").first() self.status_oh = Status.query.filter_by(code="OH").first() self.status_stop = Status.query.filter_by(code="STOP").first() self.status_cmpl = Status.query.filter_by(code="CMPL").first() self.status_new = Status.query.filter_by(code='NEW').first() self.status_app = Status.query.filter_by(code='APP').first() from stalker import StatusList self.budget_status_list = StatusList( name='Budget Statuses', target_entity_type='Budget', statuses=[self.status_new, self.status_prev, self.status_app]) db.DBSession.add(self.budget_status_list) self.task_status_list = StatusList.query\ .filter_by(target_entity_type='Task').first() from stalker import Project self.test_project_status_list = StatusList( name="Project Statuses", statuses=[self.status_wip, self.status_prev, self.status_cmpl], target_entity_type=Project, ) db.DBSession.add(self.test_project_status_list) from stalker import Type self.test_movie_project_type = Type( name="Movie Project", code='movie', target_entity_type=Project, ) db.DBSession.add(self.test_movie_project_type) from stalker import Repository self.test_repository_type = Type( name="Test Repository Type", code='test', target_entity_type=Repository, ) db.DBSession.add(self.test_repository_type) self.test_repository = Repository( name="Test Repository", type=self.test_repository_type, ) db.DBSession.add(self.test_repository) from stalker import User self.test_user1 = User(name="User1", login="******", email="*****@*****.**", password="******") db.DBSession.add(self.test_user1) self.test_user2 = User(name="User2", login="******", email="*****@*****.**", password="******") db.DBSession.add(self.test_user2) self.test_user3 = User(name="User3", login="******", email="*****@*****.**", password="******") db.DBSession.add(self.test_user3) self.test_user4 = User(name="User4", login="******", email="*****@*****.**", password="******") db.DBSession.add(self.test_user4) self.test_user5 = User(name="User5", login="******", email="*****@*****.**", password="******") db.DBSession.add(self.test_user5) from stalker import Client self.test_client = Client(name='Test Client', ) db.DBSession.add(self.test_client) self.test_project = Project(name="Test Project1", code='tp1', type=self.test_movie_project_type, status_list=self.test_project_status_list, repository=self.test_repository, clients=[self.test_client]) db.DBSession.add(self.test_project) from stalker import Budget self.test_budget = Budget( project=self.test_project, name='Test Budget 1', ) db.DBSession.add(self.test_budget) from stalker import Invoice self.test_invoice = Invoice(budget=self.test_budget, client=self.test_client, amount=1500, unit='TRY') db.DBSession.add(self.test_invoice) db.DBSession.commit()
def setUp(self): """run once """ super(PaymentTestCase, self).setUp() from stalker import Status self.status_new = Status(name='Mew', code='NEW') self.status_wfd = Status(name='Waiting For Dependency', code='WFD') self.status_rts = Status(name='Ready To Start', code='RTS') self.status_wip = Status(name='Work In Progress', code='WIP') self.status_prev = Status(name='Pending Review', code='PREV') self.status_hrev = Status(name='Has Revision', code='HREV') self.status_drev = Status(name='Dependency Has Revision', code='DREV') self.status_oh = Status(name='On Hold', code='OH') self.status_stop = Status(name='Stopped', code='STOP') self.status_cmpl = Status(name='Completed', code='CMPL') self.status_new = Status(name='New', code='NEW') self.status_app = Status(name='Approved', code='APP') from stalker import StatusList self.budget_status_list = StatusList( name='Budget Statuses', target_entity_type='Budget', statuses=[self.status_new, self.status_prev, self.status_app]) self.task_status_list = StatusList( name='Task Statses', statuses=[ self.status_wfd, self.status_rts, self.status_wip, self.status_prev, self.status_hrev, self.status_drev, self.status_oh, self.status_stop, self.status_cmpl ], target_entity_type='Task') from stalker import Project self.test_project_status_list = StatusList( name="Project Statuses", statuses=[self.status_wip, self.status_prev, self.status_cmpl], target_entity_type=Project, ) from stalker import Type self.test_movie_project_type = Type( name="Movie Project", code='movie', target_entity_type=Project, ) from stalker import Repository self.test_repository_type = Type( name="Test Repository Type", code='test', target_entity_type=Repository, ) self.test_repository = Repository( name="Test Repository", type=self.test_repository_type, ) from stalker import User self.test_user1 = User(name="User1", login="******", email="*****@*****.**", password="******") self.test_user2 = User(name="User2", login="******", email="*****@*****.**", password="******") self.test_user3 = User(name="User3", login="******", email="*****@*****.**", password="******") self.test_user4 = User(name="User4", login="******", email="*****@*****.**", password="******") self.test_user5 = User(name="User5", login="******", email="*****@*****.**", password="******") from stalker import Client self.test_client = Client(name='Test Client', ) self.test_project = Project(name="Test Project1", code='tp1', type=self.test_movie_project_type, status_list=self.test_project_status_list, repository=self.test_repository, clients=[self.test_client]) from stalker import Budget self.test_budget = Budget(project=self.test_project, name='Test Budget 1', status_list=self.budget_status_list) from stalker import Invoice self.test_invoice = Invoice(budget=self.test_budget, client=self.test_client, amount=1500, unit='TRY')