forked from p15670423/monkey
Fixed label cache logic and added to UTs
This commit is contained in:
parent
063a136048
commit
70daf4bfbf
|
@ -115,6 +115,7 @@ class Monkey(Document):
|
||||||
self.hostname = hostname
|
self.hostname = hostname
|
||||||
self.save()
|
self.save()
|
||||||
Monkey.get_hostname_by_id.delete(self.id)
|
Monkey.get_hostname_by_id.delete(self.id)
|
||||||
|
Monkey.get_label_by_id.delete(self.id)
|
||||||
|
|
||||||
def get_network_info(self):
|
def get_network_info(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -140,6 +140,16 @@ class TestMonkey(IslandTestCase):
|
||||||
cache_info_after_query = Monkey.get_label_by_id.storage.backend.cache_info()
|
cache_info_after_query = Monkey.get_label_by_id.storage.backend.cache_info()
|
||||||
self.assertEquals(cache_info_after_query.hits, 1)
|
self.assertEquals(cache_info_after_query.hits, 1)
|
||||||
|
|
||||||
|
linux_monkey.set_hostname("Another hostname")
|
||||||
|
|
||||||
|
# should be a miss
|
||||||
|
label = Monkey.get_label_by_id(linux_monkey.id)
|
||||||
|
cache_info_after_second_query = Monkey.get_label_by_id.storage.backend.cache_info()
|
||||||
|
# still 1 hit only
|
||||||
|
self.assertEquals(cache_info_after_second_query.hits, 1)
|
||||||
|
self.assertEquals(cache_info_after_second_query.misses, 2)
|
||||||
|
|
||||||
|
|
||||||
def test_is_monkey(self):
|
def test_is_monkey(self):
|
||||||
self.fail_if_not_testing_env()
|
self.fail_if_not_testing_env()
|
||||||
self.clean_monkey_db()
|
self.clean_monkey_db()
|
||||||
|
|
Loading…
Reference in New Issue