-
Notifications
You must be signed in to change notification settings - Fork 2
/
tests.py
127 lines (103 loc) · 4.35 KB
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
from __future__ import absolute_import
__author__ = 'diging_yogi'
import unittest
from requests.auth import HTTPBasicAuth
#from httmock import with_httmock
import mock
from . import mocks.mock_conceptpower
from . import conceptpower
class TestConceptpower(unittest.TestCase):
@mock.patch('requests.get', side_effect=mocks.mock_conceptpower.mocked_requests_search)
def test_search_no_concepts(self,mock_search):
"""
testing the "search" method when there is no concept for
the lemma we are searching
"""
conceptPower = conceptpower.Conceptpower()
val = conceptPower.search('abcdef')
self.assertIsInstance(val, list)
self.assertEqual(len(val), 0)
@mock.patch('requests.get', side_effect=mocks.mock_conceptpower.mocked_requests_search)
def test_search_no_type(self,mock_search):
"""
testing the "search" method when there are concepts for
the lemma and there is no type tag for those concepts
"""
conceptPower = conceptpower.Conceptpower()
val = conceptPower.search('notypetag')
self.assertIsInstance(val, list)
self.assertEqual(len(val), 1)
self.assertEqual(len(val[0]),12)
@mock.patch('requests.get', side_effect=mocks.mock_conceptpower.mocked_requests_search)
def test_search(self,mock_search):
"""
testing the "search" method when there are concepts for
the lemma we are searching with type tag present
"""
conceptPower = conceptpower.Conceptpower()
val = conceptPower.search('Bradshaw')
self.assertIsInstance(val, list)
self.assertEqual(len(val), 1)
self.assertEqual(len(val[0]),15)
@mock.patch('requests.get', side_effect=mocks.mock_conceptpower.mocked_requests_get)
def test_get_no_concept(self,mock_get):
"""
testing the "get" method when there is no concept for
the Concept URI we are searching
:param mock_get:
:return:
"""
conceptPower = conceptpower.Conceptpower()
val = conceptPower.get('http://www.digitalhps.org/concepts/abcdefg')
self.assertIsInstance(val,dict)
self.assertEqual(len(val),0)
@mock.patch('requests.get', side_effect=mocks.mock_conceptpower.mocked_requests_get)
def test_get_no_type(self,mock_get):
"""
testing the "get" method when there is concept for
the Concept URI we are searching with no type tag
:param mock_get:
:return:
"""
conceptPower = conceptpower.Conceptpower()
val = conceptPower.get('http://www.digitalhps.org/concepts/notype')
self.assertIsInstance(val,dict)
self.assertEqual(len(val),12)
@mock.patch('requests.get', side_effect=mocks.mock_conceptpower.mocked_requests_get)
def test_get(self,mock_get):
"""
testing the "get" method when there is concept for
the Concept URI we are searching with type tag
:param mock_get:
:return:
"""
conceptPower = conceptpower.Conceptpower()
val = conceptPower.get('http://www.digitalhps.org/concepts/CON536b243d-3c71-4a5c-ab79-3c7f12765b3f')
self.assertIsInstance(val,dict)
self.assertEqual(len(val),15)
@mock.patch('requests.get', side_effect=mocks.mock_conceptpower.mocked_requests_get_type)
def test_get_type_no_concept(self,mock_get_type):
"""
testing the "get_type" method when there is no concept for
the Concept URI we are searching
:param mock_get_type:
:return:
"""
conceptPower = conceptpower.Conceptpower()
val = conceptPower.get_type('http://www.digitalhps.org/types/TYPE_abadf')
self.assertIsInstance(val,dict)
self.assertEqual(len(val),0)
@mock.patch('requests.get', side_effect=mocks.mock_conceptpower.mocked_requests_get_type)
def test_get_type_concept(self,mock_get_type):
"""
testing the "get_type" method when there is concept for
the Concept URI we are searching
:param mock_get_type:
:return:
"""
conceptPower = conceptpower.Conceptpower()
val = conceptPower.get_type('ttp://www.digitalhps.org/types/TYPE_986a7cc9-c0c1-4720-b344-853f08c136ab')
self.assertIsInstance(val,dict)
self.assertEqual(len(val),5)
if __name__ == '__main__':
unittest.main()