From 4575c7ea47680e7f589477c917a73353d6faef73 Mon Sep 17 00:00:00 2001 From: Markus Krogh Date: Thu, 10 Mar 2016 11:53:42 +0000 Subject: Manager mail + ceo mail --- test/templates/__init__.py | 0 test/templates/test_ceo_template.py | 19 +++++++++++ test/templates/test_employee_status_template.py | 25 +++++++++++++++ test/templates/test_manager_template.py | 39 +++++++++++++++++++++++ test/templates/test_missing_email_template.py | 13 ++++++++ test/templates/test_unsubmitted_email_template.py | 13 ++++++++ 6 files changed, 109 insertions(+) create mode 100644 test/templates/__init__.py create mode 100644 test/templates/test_ceo_template.py create mode 100644 test/templates/test_employee_status_template.py create mode 100644 test/templates/test_manager_template.py create mode 100644 test/templates/test_missing_email_template.py create mode 100644 test/templates/test_unsubmitted_email_template.py (limited to 'test/templates') diff --git a/test/templates/__init__.py b/test/templates/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/test/templates/test_ceo_template.py b/test/templates/test_ceo_template.py new file mode 100644 index 0000000..6962a20 --- /dev/null +++ b/test/templates/test_ceo_template.py @@ -0,0 +1,19 @@ +from maconomy import CEOEmailTemplate, Timesheet +import unittest + +class CEOEmailTemplateTest(unittest.TestCase): + def setUp(self): + self.template = CEOEmailTemplate() + 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", "markusk@nordu.net", "11", 0, 0, "JKL")) + + def test_ceo_email(self): + result = self.template.build(timesheets=[self.not_approved, self.not_submitted]) + + self.assertIn("Markus Krogh (MKR)", result) + self.assertIn("Markus Krogh (MK)", result) + self.assertIn("has not been approved by JK", result) + self.assertIn("has not been approved by JKL", result) + self.assertIn("has been submitted", result) + self.assertIn("has not been submitted", result) + diff --git a/test/templates/test_employee_status_template.py b/test/templates/test_employee_status_template.py new file mode 100644 index 0000000..0d37d3e --- /dev/null +++ b/test/templates/test_employee_status_template.py @@ -0,0 +1,25 @@ +from maconomy import EmployeeStatusTemplate, Employee, Timesheet +import unittest + +class EmployeeStatusTemplateTest(unittest.TestCase): + + def setUp(self): + self.template = EmployeeStatusTemplate() + self.employee = Employee.from_result(("MK", "Markus Krogh", "markus@nordu.net")) + + def test_substitute(self): + timesheet = Timesheet("11", 0, 0, self.employee, "JK") + result = self.template.build(timesheet) + self.assertIn("Markus Krogh (MK)", result) + self.assertIn("not been submitted", result) + self.assertIn("not been approved", result) + + def test_submitted(self): + timesheet = Timesheet("11", submitted=1, approved=0, employee=self.employee, approver="JK") + result = self.template.build(timesheet) + self.assertIn("has been submitted", result) + + def test_approved(self): + timesheet = Timesheet("11", submitted=1, approved=1, employee=self.employee, approver="JK") + result = self.template.build(timesheet) + self.assertIn("has been approved", result) diff --git a/test/templates/test_manager_template.py b/test/templates/test_manager_template.py new file mode 100644 index 0000000..bdc7387 --- /dev/null +++ b/test/templates/test_manager_template.py @@ -0,0 +1,39 @@ +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) + diff --git a/test/templates/test_missing_email_template.py b/test/templates/test_missing_email_template.py new file mode 100644 index 0000000..60e923a --- /dev/null +++ b/test/templates/test_missing_email_template.py @@ -0,0 +1,13 @@ +from maconomy import MissingEmailTemplate +import unittest + + +class MissingEmailTemplateTest(unittest.TestCase): + + def setUp(self): + self.template = MissingEmailTemplate() + + def test_substitution(self): + result = self.template.build(maconomyurl="http://localhost/", helpurl="http://example.com") + self.assertIn("href=\"http://localhost/\"", result) + self.assertIn("href=\"http://example.com\"", result) diff --git a/test/templates/test_unsubmitted_email_template.py b/test/templates/test_unsubmitted_email_template.py new file mode 100644 index 0000000..ab13700 --- /dev/null +++ b/test/templates/test_unsubmitted_email_template.py @@ -0,0 +1,13 @@ +from maconomy import UnsubmittedEmailTemplate +import unittest + +class UnsubmittedEmailTemplateTest(unittest.TestCase): + + def setUp(self): + self.template = UnsubmittedEmailTemplate() + + def test_substitution(self): + result = self.template.build(week=10, maconomyurl="http://localhost/", helpurl="http://example.com") + self.assertIn("week 10", result) + self.assertIn("href=\"http://localhost/\"", result) + self.assertIn("href=\"http://example.com\"", result) -- cgit v1.1