test_cas_callbacks.py 1.67 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
8
from go.cas_callbacks import pfparse, pfinfo, create_user
9 10

class CasCallbacksTest(TestCase):
11
    """
12
        Test cases for the functions in call_callbacks.
13
    """
14 15


16
    def test_pf_peoplefinder_method(self):
17 18 19 20
        """
            Presently enrolled student who has been added to peoplefinder
        """

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

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

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

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

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

    def test_pfinfo_employee_method(self):
45 46 47 48
        """
            student employees will have their staff info return before their student info
        """

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

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

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