summaryrefslogtreecommitdiff
path: root/test/test_templates.py
blob: ee05ac6f864af2141bb6a542935b06448d4a8e1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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)