3
3
from flask import Flask
4
4
from flask .ext .cache import Cache
5
5
from datetime import datetime , timedelta
6
- from app .services .host import HostService
6
+ from discovery . app .services .host import HostService
7
7
8
8
9
9
class HostServiceTestCase (unittest .TestCase ):
@@ -21,8 +21,8 @@ def tearDown(self):
21
21
def _generate_valid_tags (self ):
22
22
return {'az' : 'foo' , 'instance_id' : 'bar' , 'region' : 'baz' }
23
23
24
- @patch ('app.models.host.Host.get' )
25
- @patch ('app.models.host.Host.save' )
24
+ @patch ('discovery. app.models.host.Host.get' )
25
+ @patch ('discovery. app.models.host.Host.save' )
26
26
def test_update_succeeds (self , save , get ):
27
27
save .return_value = Mock (spec = bool )
28
28
get .return_value = Mock (spec = ['port' , 'revision' , 'last_check_in' , 'tags' , 'save' ])
@@ -51,8 +51,8 @@ def test_service_repo_name_optional(self):
51
51
)
52
52
assert success is True
53
53
54
- @patch ('app.models.host.Host.get' )
55
- @patch ('app.models.host.Host.save' )
54
+ @patch ('discovery. app.models.host.Host.get' )
55
+ @patch ('discovery. app.models.host.Host.save' )
56
56
def test_update_invalid_ip (self , save , get ):
57
57
save .return_value = Mock (spec = bool )
58
58
get .return_value = Mock (spec = ['port' , 'revision' , 'last_check_in' , 'tags' , 'save' ])
@@ -78,8 +78,8 @@ def test_update_invalid_ip(self, save, get):
78
78
)
79
79
assert success is False
80
80
81
- @patch ('app.models.host.Host.get' )
82
- @patch ('app.models.host.Host.save' )
81
+ @patch ('discovery. app.models.host.Host.get' )
82
+ @patch ('discovery. app.models.host.Host.save' )
83
83
def test_update_invalid_port (self , save , get ):
84
84
save .return_value = Mock (spec = bool )
85
85
get .return_value = Mock (spec = ['port' , 'revision' , 'last_check_in' , 'tags' , 'save' ])
@@ -108,8 +108,8 @@ def test_update_invalid_port(self, save, get):
108
108
)
109
109
assert success is False
110
110
111
- @patch ('app.models.host.Host.get' )
112
- @patch ('app.models.host.Host.save' )
111
+ @patch ('discovery. app.models.host.Host.get' )
112
+ @patch ('discovery. app.models.host.Host.save' )
113
113
def test_update_invalid_last_check_in (self , save , get ):
114
114
save .return_value = Mock (spec = bool )
115
115
get .return_value = Mock (spec = ['port' , 'revision' , 'last_check_in' , 'tags' , 'save' ])
@@ -126,8 +126,8 @@ def test_update_invalid_last_check_in(self, save, get):
126
126
)
127
127
assert success is False
128
128
129
- @patch ('app.models.host.Host.get' )
130
- @patch ('app.models.host.Host.save' )
129
+ @patch ('discovery. app.models.host.Host.get' )
130
+ @patch ('discovery. app.models.host.Host.save' )
131
131
def test_update_invalid_tags (self , save , get ):
132
132
save .return_value = Mock (spec = bool )
133
133
get .return_value = Mock (spec = ['port' , 'revision' , 'last_check_in' , 'tags' , 'save' ])
@@ -168,8 +168,8 @@ def test_update_invalid_tags(self, save, get):
168
168
)
169
169
assert success is False
170
170
171
- @patch ('app.models.host.Host.query' )
172
- @patch ('app.services.host.HostService._is_expired' )
171
+ @patch ('discovery. app.models.host.Host.query' )
172
+ @patch ('discovery. app.services.host.HostService._is_expired' )
173
173
def test_list (self , expired , query ):
174
174
self .app .cache = Cache (self .app , config = {'CACHE_TYPE' : 'null' })
175
175
service = 'foo'
@@ -224,8 +224,8 @@ def test_list(self, expired, query):
224
224
]
225
225
assert hosts == expected
226
226
227
- @patch ('app.models.host.Host.service_repo_name_index.query' )
228
- @patch ('app.services.host.HostService._is_expired' )
227
+ @patch ('discovery. app.models.host.Host.service_repo_name_index.query' )
228
+ @patch ('discovery. app.services.host.HostService._is_expired' )
229
229
def test_list_by_service_repo_name (self , expired , query ):
230
230
self .app .cache = Cache (self .app , config = {'CACHE_TYPE' : 'null' })
231
231
service = 'foo'
@@ -281,7 +281,7 @@ def test_list_by_service_repo_name(self, expired, query):
281
281
]
282
282
assert hosts == expected
283
283
284
- @patch ('app.models.host.Host.get' )
284
+ @patch ('discovery. app.models.host.Host.get' )
285
285
def test_set_tag (self , get ):
286
286
host = Mock (spec = ['port' , 'revision' , 'last_check_in' , 'tags' , 'save' ])
287
287
host .save .return_value = Mock (spec = bool )
@@ -299,8 +299,8 @@ def test_set_tag(self, get):
299
299
assert host .tags == {'tagname' : 'value' }
300
300
host .save .assert_called_once ()
301
301
302
- @patch ('app.models.host.Host.batch_write' )
303
- @patch ('app.models.host.Host.query' )
302
+ @patch ('discovery. app.models.host.Host.batch_write' )
303
+ @patch ('discovery. app.models.host.Host.query' )
304
304
def test_set_tag_all (self , query , batch_write ):
305
305
enter = MagicMock ()
306
306
ctx_manager = MagicMock ()
@@ -329,7 +329,7 @@ def test_set_tag_all(self, query, batch_write):
329
329
def noop (self ):
330
330
pass
331
331
332
- @patch ('app.models.host.Host.query' )
332
+ @patch ('discovery. app.models.host.Host.query' )
333
333
def test_sweeper (self , query ):
334
334
# have query return hosts, some of which are expired
335
335
# verify that the expired hosts are not returned
0 commit comments