diff options
author | Markus Krogh <markus@nordu.net> | 2016-03-10 11:53:42 +0000 |
---|---|---|
committer | Markus Krogh <markus@nordu.net> | 2016-03-10 11:53:42 +0000 |
commit | 4575c7ea47680e7f589477c917a73353d6faef73 (patch) | |
tree | 5f1fb1d8d120b8d609b2018a5eb8e8ad30183952 /test | |
parent | 67abade3147d6d706c18beaac219d549fb71c35e (diff) |
Manager mail + ceo mail
Diffstat (limited to 'test')
-rw-r--r-- | test/templates/__init__.py | 0 | ||||
-rw-r--r-- | test/templates/test_ceo_template.py | 19 | ||||
-rw-r--r-- | test/templates/test_employee_status_template.py | 25 | ||||
-rw-r--r-- | test/templates/test_manager_template.py | 39 | ||||
-rw-r--r-- | test/templates/test_missing_email_template.py | 13 | ||||
-rw-r--r-- | test/templates/test_unsubmitted_email_template.py | 13 | ||||
-rw-r--r-- | test/test_templates.py | 61 | ||||
-rw-r--r-- | test/views/__init__.py | 0 | ||||
-rw-r--r-- | test/views/test_employee_email.py | 25 |
9 files changed, 134 insertions, 61 deletions
diff --git a/test/templates/__init__.py b/test/templates/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/templates/__init__.py 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) diff --git a/test/test_templates.py b/test/test_templates.py deleted file mode 100644 index ee05ac6..0000000 --- a/test/test_templates.py +++ /dev/null @@ -1,61 +0,0 @@ -from maconomy import UnsubmittedEmailTemplate, MissingEmailTemplate, ManagerEmailTemplate, Employee -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) - -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) - -class ManagerEmailTemplateTest(unittest.TestCase): - - def setUp(self): - self.template = ManagerEmailTemplate() - self.employee = Employee(("MK", "Markus Krogh", "markus@nordu.net")) - - def test_substitute(self): - result = self.template.build( - employee=self.employee, - week=11, - maconomyurl="http://localhost/", - ) - self.assertIn("Markus Krogh (MK)", result) - self.assertIn("Week 11", result) - self.assertIn("not been submitted", result) - self.assertIn("not been approved", result) - self.assertIn("href=\"http://localhost/\"", result) - - def test_submitted(self): - result = self.template.build( - employee=self.employee, - week=11, - maconomyurl="http://localhost/", - submitted = True, - ) - self.assertIn("has been submitted", result) - def test_approved(self): - result = self.template.build( - employee=self.employee, - week=11, - maconomyurl="http://localhost/", - approved = True, - ) - self.assertIn("has been approved", result) - - - diff --git a/test/views/__init__.py b/test/views/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/views/__init__.py diff --git a/test/views/test_employee_email.py b/test/views/test_employee_email.py new file mode 100644 index 0000000..75ebbd6 --- /dev/null +++ b/test/views/test_employee_email.py @@ -0,0 +1,25 @@ +from maconomy import EmployeeEmailView, Timesheet +from ConfigParser import SafeConfigParser +import unittest + +class EmployeeEmailViewTest(unittest.TestCase): + def setUp(self): + self.config = SafeConfigParser() + self.config.add_section("view") + self.config.set("view", "maconomyurl", "http://localhost/maconomy") + self.config.set("view", "helpurl", "http://localhost/help") + self.view = EmployeeEmailView(self.config) + self.timesheet = Timesheet.from_result(("Markus Krogh", "MK", "markus@nordu.net", 11, 0, 0, "JK")) + + def test_missing_timereg(self): + self.timesheet.submitted=None + result = self.view.render(self.timesheet) + self.assertIn("href=\"http://localhost/maconomy\"", result) + self.assertIn("href=\"http://localhost/help\"", result) + + def test_unsubmitted_timereg(self): + self.timesheet.submitted=0 + result = self.view.render(self.timesheet) + self.assertIn("week 11", result) + self.assertIn("href=\"http://localhost/maconomy\"", result) + self.assertIn("href=\"http://localhost/help\"", result) |