test_cas_callbacks.py 1.63 KB
Newer Older
1 2 3 4 5 6 7
# Future Imports
from __future__ import unicode_literals, absolute_import, print_function, division

# Django Imports
from django.test import TestCase

# App Imports
David Haynes's avatar
David Haynes committed
8
from go.cas_callbacks import pfparse, pfinfo
9 10

class CasCallbacksTest(TestCase):
11
    """
David Haynes's avatar
David Haynes committed
12
    Test cases for the functions in call_callbacks.
13
    """
14 15


16
    def test_pf_peoplefinder_method(self):
17
        """
David Haynes's avatar
David Haynes committed
18
        Presently enrolled student who has been added to peoplefinder
19 20
        """

21 22 23
        actual = pfinfo('dhaynes3')
        expected = ['David', 'Haynes']
        self.assertEqual(expected, actual)
24

25
    def test_pfparse_peoplefinder_method(self):
26
        """
David Haynes's avatar
David Haynes committed
27 28
        Test the parsing method to ensure that first and last names are seperated
        accordingly and correctly.
29 30
        """

31 32 33 34 35
        actual = pfparse("Haynes, David M")
        expected = ['David', 'Haynes']
        self.assertEqual(expected, actual)

    def test_pfinfo_ldap_method(self):
36
        """
David Haynes's avatar
David Haynes committed
37
        student no longer in peoplefinder, or who hasn't yet been added
38 39
        """

40 41 42 43 44
        actual = pfinfo('lfaraone')
        expected = ['Luke W', 'Faraone']
        self.assertEqual(expected, actual)

    def test_pfinfo_employee_method(self):
45
        """
David Haynes's avatar
David Haynes committed
46
        student employees will have their staff info return before their student info
47 48
        """

49 50 51 52 53
        actual = pfinfo('nander13')
        expected = ['Nicholas', 'Anderson']
        self.assertEqual(expected, actual)

    def test_pfinfo_dne(self):
54
        """
David Haynes's avatar
David Haynes committed
55
        a name not found for either (should never happen, but gracefully handle anyway)
56 57
        """

58 59 60
        actual = pfinfo('bobama')
        expected = ['', '']
        self.assertEqual(expected, actual)