def test_create_bulk(self): project = self.get_project() with self.recorder.use_cassette("TestProjectExpense.test_create_bulk"): gen = ProjectExpenseGenerator() items = [ gen.generate( date(2020, 1, 1), "dummy project expense, test create bulk (1)", 1, "stk", 2, 3, ), gen.generate( date(2021, 1, 1), "dummy project expense, test create bulk (2)", 1, "stk", 2, 3, ) ] ex_bulk = self.moco.ProjectExpense.create_bulk(project.id, items) assert ex_bulk.response.status_code == 200 assert isinstance(ex_bulk, ListingResponse)
def test_create_bulk(self): project = self.get_project() with self.recorder.use_cassette("TestProjectExpense.test_create_bulk"): gen = ProjectExpenseGenerator() items = [ gen.generate( expense_date=date(2020, 1, 1), title="TestProjectExpense.test_create_bulk_create_1", quantity=1, unit="stk", unit_price=2, unit_cost=3, ), gen.generate( expense_date=date(2021, 1, 1), title="TestProjectExpense.test_create_bulk_create_2", quantity=1, unit="stk", unit_price=2, unit_cost=3, ) ] ex_bulk = self.moco.ProjectExpense.create_bulk( project_id=project.id, items=items) assert ex_bulk.response.status_code == 200 assert type(ex_bulk) is ListResponse
def test_disregard_items(self): project = self.get_project() with self.recorder.use_cassette("TestProjectExpense.test_disregard"): gen = ProjectExpenseGenerator() items = [ gen.generate( date(2020, 1, 1), "dummy project expense, test create bulk (1)", 1, "stk", 2, 3, ), gen.generate( date(2021, 1, 1), "dummy project expense, test create bulk (2)", 1, "stk", 2, 3, ) ] ex_bulk = self.moco.ProjectExpense.create_bulk( project.id, items ) disregard_expense_ids = [x.id for x in ex_bulk.items] ex_disregard = self.moco.ProjectExpense.disregard( project.id, disregard_expense_ids, "disregard dummy expenses" ) assert ex_bulk.response.status_code == 200 assert ex_disregard.response.status_code == 204 assert isinstance(ex_bulk, ListingResponse) assert isinstance(ex_disregard, EmptyResponse)
def test_disregard_items(self): project = self.get_project() with self.recorder.use_cassette("TestProjectExpense.test_disregard"): gen = ProjectExpenseGenerator() items = [ gen.generate( expense_date=date(2020, 1, 1), title="TestProjectExpense.test_create_bulk_create_1", quantity=1, unit="stk", unit_price=2, unit_cost=3, ), gen.generate( expense_date=date(2021, 1, 1), title="TestProjectExpense.test_create_bulk_create_2", quantity=1, unit="stk", unit_price=2, unit_cost=3, ) ] ex_bulk = self.moco.ProjectExpense.create_bulk( project_id=project.id, items=items) disregard_expense_ids = [x.id for x in ex_bulk.items] ex_disregard = self.moco.ProjectExpense.disregard( project_id=project.id, expense_ids=disregard_expense_ids, reason="disregard dummy expenses") assert ex_bulk.response.status_code == 200 assert ex_disregard.response.status_code == 204 assert type(ex_bulk) is ListResponse assert type(ex_disregard) is EmptyResponse
def setup(self): self.generator = ProjectExpenseGenerator()
class TestProjectExpenseGenerator(object): def setup(self): self.generator = ProjectExpenseGenerator() def test_generate(self): date = '2019-10-10' title = "more title stuff" quantity = 5 unit = "the unit" unit_price = 200 unit_cost = 150 description = "the description" billable = False budget_relevant = True data = self.generator.generate(date, title, quantity, unit, unit_price, unit_cost, description=description, billable=billable, budget_relevant=budget_relevant) assert data["date"] == date assert data["title"] == title assert data["quantity"] == quantity assert data["unit"] == unit assert data["unit_price"] == unit_price assert data["unit_cost"] == unit_cost assert data["description"] == description assert data["billable"] == billable assert data["budget_relevant"] == budget_relevant def test_generate_default_billable(self): billable_default = True date = '2019-10-10' title = "more title stuff" quantity = 5 unit = "the unit" unit_price = 200 unit_cost = 150 data = self.generator.generate(date, title, quantity, unit, unit_price, unit_cost) assert data["billable"] == billable_default def test_generate_default_budget_relevant(self): budget_relevant_default = False date = '2019-10-10' title = "more title stuff" quantity = 5 unit = "the unit" unit_price = 200 unit_cost = 150 data = self.generator.generate(date, title, quantity, unit, unit_price, unit_cost) assert data["budget_relevant"] == budget_relevant_default