1
|
|
|
# Copyright 2013 Mathias WOLFF |
2
|
|
|
# This file is part of pyfreebilling. |
3
|
|
|
# |
4
|
|
|
# pyfreebilling is free software: you can redistribute it and/or modify |
5
|
|
|
# it under the terms of the GNU General Public License as published by |
6
|
|
|
# the Free Software Foundation, either version 3 of the License, or |
7
|
|
|
# (at your option) any later version. |
8
|
|
|
# |
9
|
|
|
# pyfreebilling is distributed in the hope that it will be useful, |
10
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
11
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12
|
|
|
# GNU General Public License for more details. |
13
|
|
|
# |
14
|
|
|
# You should have received a copy of the GNU General Public License |
15
|
|
|
# along with pyfreebilling. If not, see <http://www.gnu.org/licenses/> |
16
|
|
|
|
17
|
|
|
|
18
|
|
|
from django.test import TestCase |
19
|
|
|
from django.test import Client |
20
|
|
|
|
21
|
|
|
|
22
|
|
|
from pyfreebill.models import Company |
23
|
|
|
|
24
|
|
|
from did.models import Did |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
class DidViewTest(TestCase): |
28
|
|
|
def setUp(self): |
29
|
|
|
self.client = Client() |
30
|
|
|
|
31
|
|
|
def test_url(self): |
32
|
|
|
urls = [{'url': '/extranet/did/add', |
33
|
|
|
'template': 'did/did.html', |
34
|
|
|
'status': 200}, |
35
|
|
|
{'url': '/extranet/did', |
36
|
|
|
'status': 200}] |
37
|
|
|
for elem in urls: |
38
|
|
|
response = self.client.get(elem['url']) |
39
|
|
|
self.assertEqual(response.status_code, elem['status']) |
40
|
|
|
response = self.client.get(elem['url'], follow=True) |
41
|
|
|
self.assertEqual(response.template.name, elem['template']) |
42
|
|
|
|
43
|
|
|
|
44
|
|
|
class test_Did(TestCase): |
45
|
|
|
def test_create_provider(self): |
46
|
|
|
""" |
47
|
|
|
We need a provider for testing did |
48
|
|
|
""" |
49
|
|
|
provider1 = Company(name="Celea") |
50
|
|
|
provider1.save() |
51
|
|
|
provider = Company.objects.get(name="Celea") |
52
|
|
|
self.assertEqual(provider.name, "Celea") |
53
|
|
|
|
54
|
|
|
def test_create_did(self): |
55
|
|
|
""" |
56
|
|
|
creation of a new did entry |
57
|
|
|
""" |
58
|
|
|
self.test_create_provider() |
59
|
|
|
provider = Company.objects.get(name="Celea") |
60
|
|
|
did = Did(number='33100110011', |
61
|
|
|
provider=provider, |
62
|
|
|
max_channels='10', |
63
|
|
|
description="did created by MW") |
64
|
|
|
did.save() |
65
|
|
|
did = Did.objects.get(number='33100110011') |
66
|
|
|
self.assertEqual(did.description, u'did created by MW') |
67
|
|
|
|