def setUp(self): ExpenseTest.setUp(self) other_expense_type = ExpenseType(name="Other Type") other_expense_type.add() self.other_expense = Expense(concept="Other Expense", type_id=other_expense_type.id) self.other_expense.add()
def setUp(self): Test.setUp(self) self.expense_type = ExpenseType( name="Test Type" ) self.expense_type.add() self.expense = Expense( concept="Test Expense", type_id=self.expense_type.id ) self.expense.add()
def test_should_add_expense_type_given_valid_type_input_and_LUHP(self): self.login_user(self.dev_user) type_input = dict(name="New Expense Type") with self.client as client: client.post(url_for('expense.add_type'), data=type_input) self.assertTrue(ExpenseType.search("New Expense Type"))
def test_should_add_expense_type_given_valid_expense_type(self): expense_type = ExpenseType(name="Valid Type") expense_type.request.add() self.assertIn(expense_type, self.db.session)
def test_should_not_add_expense_type_given_invalid_expense_type(self): expense_type = ExpenseType(name="") expense_type.request.add() self.assertNotIn(expense_type, self.db.session)
def test_should_return_error_given_empty_value(self): expense_type = ExpenseType(name="") error = expense_type.validation.validate_empty_values() self.assertNotEqual(error, None)
def test_should_not_return_error_given_valid_expense_type(self): expense_type = ExpenseType(name="Valid Type") error = expense_type.validation.validate() self.assertEqual(error, None)
def test_should_return_error_given_repeated_value(self): expense_type = ExpenseType(name="Test Type") error = expense_type.validation.validate_unique_values() self.assertNotEqual(error, None)
def init_expense_types(): expense_types = ['Consumible', 'Materia Prima', 'Fijo'] from EnGo.models.expense import ExpenseType for type_name in expense_types: expense_type = ExpenseType(name=type_name) expense_type.add()