Completed
Push — master ( 5e4583...f8d339 )
by Mathias
35s
created

DialogVarViewTest.test_detail_dialogvar()   A

Complexity

Conditions 1

Size

Total Lines 5

Duplication

Lines 5
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 5
loc 5
rs 9.4285
cc 1
1
import unittest
2
from django.core.urlresolvers import reverse
3
from django.test import Client
4
from .models import Dialog, DialogVar
5
from django.contrib.auth.models import User
6
from django.contrib.auth.models import Group
7
from django.contrib.contenttypes.models import ContentType
8
9
10
def create_django_contrib_auth_models_user(**kwargs):
11
    defaults = {}
12
    defaults["username"] = "username"
13
    defaults["email"] = "[email protected]"
14
    defaults.update(**kwargs)
15
    return User.objects.create(**defaults)
16
17
18
def create_django_contrib_auth_models_group(**kwargs):
19
    defaults = {}
20
    defaults["name"] = "group"
21
    defaults.update(**kwargs)
22
    return Group.objects.create(**defaults)
23
24
25
def create_django_contrib_contenttypes_models_contenttype(**kwargs):
26
    defaults = {}
27
    defaults.update(**kwargs)
28
    return ContentType.objects.create(**defaults)
29
30
31
def create_dialog(**kwargs):
32
    defaults = {}
33
    defaults["hash_entry"] = "hash_entry"
34
    defaults["hash_id"] = "hash_id"
35
    defaults["callid"] = "callid"
36
    defaults["from_uri"] = "from_uri"
37
    defaults["from_tag"] = "from_tag"
38
    defaults["to_uri"] = "to_uri"
39
    defaults["to_tag"] = "to_tag"
40
    defaults["caller_cseq"] = "caller_cseq"
41
    defaults["callee_cseq"] = "callee_cseq"
42
    defaults["caller_route_set"] = "caller_route_set"
43
    defaults["callee_route_set"] = "callee_route_set"
44
    defaults["caller_contact"] = "caller_contact"
45
    defaults["callee_contact"] = "callee_contact"
46
    defaults["caller_sock"] = "caller_sock"
47
    defaults["callee_stock"] = "callee_stock"
48
    defaults["state"] = "state"
49
    defaults["start_time"] = "start_time"
50
    defaults["timeout"] = "timeout"
51
    defaults["sflags"] = "sflags"
52
    defaults["iflags"] = "iflags"
53
    defaults["toroute_name"] = "toroute_name"
54
    defaults["req_uri"] = "req_uri"
55
    defaults["xdata"] = "xdata"
56
    defaults.update(**kwargs)
57
    return Dialog.objects.create(**defaults)
58
59
60
def create_dialogvar(**kwargs):
61
    defaults = {}
62
    defaults["hash_entry"] = "hash_entry"
63
    defaults["hash_id"] = "hash_id"
64
    defaults["dialog_key"] = "dialog_key"
65
    defaults["dialog_value"] = "dialog_value"
66
    defaults.update(**kwargs)
67
    return DialogVar.objects.create(**defaults)
68
69
70 View Code Duplication
class DialogViewTest(unittest.TestCase):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
71
    '''
72
    Tests for Dialog
73
    '''
74
    def setUp(self):
75
        self.client = Client()
76
77
    def test_list_dialog(self):
78
        url = reverse('sipdialog_dialog_list')
79
        response = self.client.get(url)
80
        self.assertEqual(response.status_code, 200)
81
82
    def test_create_dialog(self):
83
        url = reverse('sipdialog_dialog_create')
84
        data = {
85
            "hash_entry": "hash_entry",
86
            "hash_id": "hash_id",
87
            "callid": "callid",
88
            "from_uri": "from_uri",
89
            "from_tag": "from_tag",
90
            "to_uri": "to_uri",
91
            "to_tag": "to_tag",
92
            "caller_cseq": "caller_cseq",
93
            "callee_cseq": "callee_cseq",
94
            "caller_route_set": "caller_route_set",
95
            "callee_route_set": "callee_route_set",
96
            "caller_contact": "caller_contact",
97
            "callee_contact": "callee_contact",
98
            "caller_sock": "caller_sock",
99
            "callee_stock": "callee_stock",
100
            "state": "state",
101
            "start_time": "start_time",
102
            "timeout": "timeout",
103
            "sflags": "sflags",
104
            "iflags": "iflags",
105
            "toroute_name": "toroute_name",
106
            "req_uri": "req_uri",
107
            "xdata": "xdata",
108
        }
109
        response = self.client.post(url, data=data)
110
        self.assertEqual(response.status_code, 302)
111
112
    def test_detail_dialog(self):
113
        dialog = create_dialog()
114
        url = reverse('sipdialog_dialog_detail', args=[dialog.pk,])
115
        response = self.client.get(url)
116
        self.assertEqual(response.status_code, 200)
117
118
    def test_update_dialog(self):
119
        dialog = create_dialog()
120
        data = {
121
            "hash_entry": "hash_entry",
122
            "hash_id": "hash_id",
123
            "callid": "callid",
124
            "from_uri": "from_uri",
125
            "from_tag": "from_tag",
126
            "to_uri": "to_uri",
127
            "to_tag": "to_tag",
128
            "caller_cseq": "caller_cseq",
129
            "callee_cseq": "callee_cseq",
130
            "caller_route_set": "caller_route_set",
131
            "callee_route_set": "callee_route_set",
132
            "caller_contact": "caller_contact",
133
            "callee_contact": "callee_contact",
134
            "caller_sock": "caller_sock",
135
            "callee_stock": "callee_stock",
136
            "state": "state",
137
            "start_time": "start_time",
138
            "timeout": "timeout",
139
            "sflags": "sflags",
140
            "iflags": "iflags",
141
            "toroute_name": "toroute_name",
142
            "req_uri": "req_uri",
143
            "xdata": "xdata",
144
        }
145
        url = reverse('sipdialog_dialog_update', args=[dialog.pk,])
146
        response = self.client.post(url, data)
147
        self.assertEqual(response.status_code, 302)
148
149
150 View Code Duplication
class DialogVarViewTest(unittest.TestCase):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
151
    '''
152
    Tests for DialogVar
153
    '''
154
    def setUp(self):
155
        self.client = Client()
156
157
    def test_list_dialogvar(self):
158
        url = reverse('sipdialog_dialogvar_list')
159
        response = self.client.get(url)
160
        self.assertEqual(response.status_code, 200)
161
162
    def test_create_dialogvar(self):
163
        url = reverse('sipdialog_dialogvar_create')
164
        data = {
165
            "hash_entry": "hash_entry",
166
            "hash_id": "hash_id",
167
            "dialog_key": "dialog_key",
168
            "dialog_value": "dialog_value",
169
        }
170
        response = self.client.post(url, data=data)
171
        self.assertEqual(response.status_code, 302)
172
173
    def test_detail_dialogvar(self):
174
        dialogvar = create_dialogvar()
175
        url = reverse('sipdialog_dialogvar_detail', args=[dialogvar.pk,])
176
        response = self.client.get(url)
177
        self.assertEqual(response.status_code, 200)
178
179
    def test_update_dialogvar(self):
180
        dialogvar = create_dialogvar()
181
        data = {
182
            "hash_entry": "hash_entry",
183
            "hash_id": "hash_id",
184
            "dialog_key": "dialog_key",
185
            "dialog_value": "dialog_value",
186
        }
187
        url = reverse('sipdialog_dialogvar_update', args=[dialogvar.pk,])
188
        response = self.client.post(url, data)
189
        self.assertEqual(response.status_code, 302)
190
191
192