def test_gets_by_target_id(self): tags = Tag.gets() for tag in tags: tag.delete() name = "tag" author = "test" type = target_type = TAG_TYPE_PROJECT_ISSUE target_id = 3 tag_name = TagName.add(name, author, target_type, target_id) assert tag_name.name == name author_id = 2 type_id1 = 1 type_id2 = 2 type_id3 = 3 tag1 = Tag.add(tag_name.id, type, type_id1, author_id, target_id) tag2 = Tag.add(tag_name.id, type, type_id2, author_id, target_id) tag3 = Tag.add(tag_name.id, type, type_id3, author_id, target_id) assert tag1.tag_id == tag2.tag_id == tag3.tag_id tags = Tag.gets_by_target_id(type, target_id) assert len(tags) == 3 type_ids = [t.type_id for t in tags] assert type_id1 in type_ids assert type_id2 in type_ids assert type_id3 in type_ids
def test_get(self): tags = Tag.gets() for tag in tags: tag.delete() Tag.add(1, TAG_TYPE_PROJECT_ISSUE, 1, 'test1', 3) Tag.add(2, TAG_TYPE_PROJECT_ISSUE, 1, 'test2', 3) Tag.add(1, TAG_TYPE_PROJECT_ISSUE, 2, 'test3', 3) tag = Tag.get_by_type_id_and_tag_id(TAG_TYPE_PROJECT_ISSUE, 1, 1) assert isinstance(tag, Tag) assert tag.tag_id == 1 assert tag.type == TAG_TYPE_PROJECT_ISSUE assert tag.type_id == 1 assert tag.author_id == 'test1' assert tag.target_id == 3 tags = Tag.gets_by_issue_id(1, TAG_TYPE_PROJECT_ISSUE) assert all([isinstance(t, Tag) for t in tags]) assert len(tags) == 2