from maconomy import ManagerEmailTemplate, Employee, Timesheet import unittest class ManagerEmailTemplateTest(unittest.TestCase): def setUp(self): self.template = ManagerEmailTemplate() self.not_approved = Timesheet.from_result(("MK", "Markus Krogh", "markus@nordu.net", "11", 1, 0, "JK")) self.not_submitted = Timesheet.from_result(("MKR", "Markus Krogh", "markus@nordu.net", "11", 0, 0, "JK")) def test_not_approved(self): result = self.template.build( timesheets=[self.not_approved], maconomyurl="http://localhost/") self.assertIn("Markus Krogh (MK)", result) self.assertIn("has not been approved", result) self.assertIn("has been submitted", result) self.assertIn("href=\"http://localhost/\"", result) def test_not_submitted(self): result = self.template.build( timesheets=[self.not_submitted], maconomyurl="http://localhost/") self.assertIn("Markus Krogh (MKR)", result) self.assertIn("has not been approved", result) self.assertIn("has not been submitted", result) self.assertIn("href=\"http://localhost/\"", result) def test_multiple_timesheets(self): result = self.template.build( timesheets=[self.not_submitted, self.not_approved], maconomyurl="http://localhost/") self.assertIn("Markus Krogh (MKR)", result) self.assertIn("Markus Krogh (MK)", result) self.assertIn("has not been approved", result) self.assertIn("has been submitted", result) self.assertIn("has not been submitted", result) self.assertIn("href=\"http://localhost/\"", result)