def test_get_tag_ids__m_get_from_empty(self): tag_engine = TagEngine() test_range = 1000 tags = [] for i in range(test_range): tags.append('tag' + str(i)) tag_id = tag_engine.get_tag_ids(tags) self.assertEqual(tag_id, [])
def test_get_tag_ids__m_get_wrong(self): tag_engine = TagEngine() test_range = 1000 tags = [] for i in range(test_range): tag_engine.storage['tag' + str(i)] = 2**(i - 1) for i in range(test_range, int(test_range / 2)): tag = 'tag' + str(i) tags.append(tag) tag_ids = tag_engine.get_tag_ids(tags) self.assertEqual(tag_ids, [])
def test_get_tag_ids__m_get(self): tag_engine = TagEngine() test_range = 30 tags = [] for i in range(test_range): tag = 'tag' + str(i) tags.append(tag) tag_engine.storage[tag] = 2**(i - 1) tag_ids = tag_engine.get_tag_ids(tags) for tag_id, i in zip(tag_ids, range(test_range)): self.assertEqual(tag_id, 2**(i - 1))
def test_get_tag_ids__partial_get_wrong(self): tag_engine = TagEngine() tag_engine.storage['tag1'] = 2**(1 - 1) tag_engine.storage['tag2'] = 2**(2 - 1) tag_engine.storage['tag3'] = 2**(3 - 1) tag_engine.storage['tag4'] = 2**(4 - 1) tag_engine.storage['tag5'] = 2**(5 - 1) tag_engine.storage['tag6'] = 2**(6 - 1) tags_requested = ['tag2', 'tag5', 'tag7', 'tag8', 'tag9'] tag_ids_expected = [2**(2 - 1), 2**(5 - 1)] tag_ids_output = tag_engine.get_tag_ids(tags_requested) self.assertEqual(tag_ids_expected, tag_ids_output)
def test_get_tag_ids__1_get(self): tag_engine = TagEngine() tag_engine.storage['tag1'] = 2**(1 - 1) tag_id = tag_engine.get_tag_ids('tag1') self.assertEqual(tag_id, 2**(1 - 1))
def test_get_tag_ids__1_get_from_empty(self): tag_engine = TagEngine() tag_id = tag_engine.get_tag_ids('tag1') self.assertEqual(tag_id, [])