test_models.py 3.42 KB
Newer Older
1
2
3
# Future Imports
from __future__ import unicode_literals, absolute_import, print_function, division

David Haynes's avatar
David Haynes committed
4
# Django Imports
David Haynes's avatar
David Haynes committed
5
from django.test import TestCase
6
from django.contrib.auth.models import User
David Haynes's avatar
David Haynes committed
7

David Haynes's avatar
David Haynes committed
8
9
# App Imports
from go.models import URL, RegisteredUser
David Haynes's avatar
David Haynes committed
10

David Haynes's avatar
David Haynes committed
11
class RegisteredUserTest(TestCase):
12
13
14
    """
        Test cases for the RegisteredUser Model
    """
David Haynes's avatar
David Haynes committed
15

16
    def setUp(self):
17
18
19
20
21
        """
            Set up any variables such as dummy objects that will be utilised in
            testing methods
        """

22
        User.objects.create(username='dhaynes', password='password')
23
    
24
    # User ---------------------------------------------------------------------
25
26
27
28
29
30

    def test_registereduser_creation(self):
        """
            check if RegisteredUsers are actually made
        """

31
32
33
        getUser = User.objects.get(username='dhaynes')
        getRegisteredUser = RegisteredUser.objects.get(user=getUser)
        self.assertTrue(getRegisteredUser)
34

35
    # full_name ----------------------------------------------------------------
36

37
    # organization -------------------------------------------------------------
38

39
    # description --------------------------------------------------------------
David Haynes's avatar
David Haynes committed
40

41
42
43
44
45
46
47
48
49
50
51
    def test_description_blank(self):
        """
            - add in description (blank)
        """

        getUser = User.objects.get(username='dhaynes')
        getRegisteredUser = RegisteredUser.objects.get(user=getUser)
        self.assertEqual(getRegisteredUser.description, "")

    def test_description_text(self):
        """
52
            - add in description (text)
53
54
55
56
57
58
59
60
        """

        getUser = User.objects.get(username='dhaynes')
        getRegisteredUser = RegisteredUser.objects.get(user=getUser)
        getRegisteredUser.description = "We're going to build a big beautiful testcase"
        self.assertEqual(getRegisteredUser.description, "We're going to build a big beautiful testcase")


61
    # registered ---------------------------------------------------------------
62

63
    # approved -----------------------------------------------------------------
64

65
    # blocked ------------------------------------------------------------------
66

67
    # __str__ ------------------------------------------------------------------
68
69
70
71
72

    def test_check_str(self):
        """
            check printing
        """
73

74
75
76
77
78
79
80
81
        getUser = User.objects.get(username='dhaynes')
        getRegisteredUser = RegisteredUser.objects.get(user=getUser)
        expected = '<Registered User: dhaynes - Approval Status: False>'
        actual = str(getRegisteredUser)
        self.assertEqual(expected, actual)


class URLTest(TestCase):
82
    """
83
        Test cases for the URL Model
84
    """
85

86
    # owner --------------------------------------------------------------------
87

88
    # date_created -------------------------------------------------------------
89

90
    # target -------------------------------------------------------------------
91

92
    # short --------------------------------------------------------------------
93

94
    # clicks -------------------------------------------------------------------
95

96
    # qrclicks -----------------------------------------------------------------
97

98
    # socialclicks -------------------------------------------------------------
99

100
    # expires ------------------------------------------------------------------
101

102
    # __str__ ------------------------------------------------------------------
103

104
    # generate_valid_short -----------------------------------------------------