def test_get_watched_list_valid_info_for_not_project_types(): fav_user = f.UserFactory() viewer_user = f.UserFactory() assigned_to_user = f.UserFactory() project = f.ProjectFactory(is_private=False, name="Testing project") factories = { "userstory": f.UserStoryFactory, "task": f.TaskFactory, "issue": f.IssueFactory } for object_type in factories: instance = factories[object_type](project=project, subject="Testing", tags=["test1", "test2"], assigned_to=assigned_to_user) instance.add_watcher(fav_user) raw_instance_watch_info = get_watched_list(fav_user, viewer_user, type=object_type)[0] instance_watch_info = VotedObjectSerializer( raw_instance_watch_info).data assert instance_watch_info["type"] == object_type assert instance_watch_info["id"] == instance.id assert instance_watch_info["ref"] == instance.ref assert instance_watch_info["slug"] == None assert instance_watch_info["name"] == None assert instance_watch_info["subject"] == instance.subject assert instance_watch_info["description"] == None assert instance_watch_info["assigned_to"] == instance.assigned_to.id assert instance_watch_info["status"] == instance.status.name assert instance_watch_info["status_color"] == instance.status.color tags_colors = { tc["name"]: tc["color"] for tc in instance_watch_info["tags_colors"] } assert "test1" in tags_colors assert "test2" in tags_colors assert instance_watch_info["is_private"] == None assert instance_watch_info["logo_small_url"] == None assert instance_watch_info["is_voter"] == False assert instance_watch_info["is_watcher"] == False assert instance_watch_info["total_watchers"] == 1 assert instance_watch_info["total_voters"] == 0 assert instance_watch_info["project"] == instance.project.id assert instance_watch_info["project_name"] == instance.project.name assert instance_watch_info["project_slug"] == instance.project.slug assert instance_watch_info[ "project_is_private"] == instance.project.is_private assert instance_watch_info[ "assigned_to_username"] == instance.assigned_to.username assert instance_watch_info[ "assigned_to_full_name"] == instance.assigned_to.full_name assert instance_watch_info["assigned_to_photo"] != ""
def test_get_voted_list_valid_info(): fav_user = f.UserFactory() viewer_user = f.UserFactory() assigned_to_user = f.UserFactory() project = f.ProjectFactory(is_private=False, name="Testing project") factories = { "epic": f.EpicFactory, "userstory": f.UserStoryFactory, "task": f.TaskFactory, "issue": f.IssueFactory } for object_type in factories: instance = factories[object_type](project=project, subject="Testing", tags=["test1", "test2"], assigned_to=assigned_to_user) content_type = ContentType.objects.get_for_model(instance) vote = f.VoteFactory(content_type=content_type, object_id=instance.id, user=fav_user) f.VotesFactory(content_type=content_type, object_id=instance.id, count=3) raw_instance_vote_info = get_voted_list(fav_user, viewer_user, type=object_type)[0] instance_vote_info = VotedObjectSerializer(into_namedtuple(raw_instance_vote_info)).data assert instance_vote_info["type"] == object_type assert instance_vote_info["id"] == instance.id assert instance_vote_info["ref"] == instance.ref assert instance_vote_info["slug"] == None assert instance_vote_info["name"] == None assert instance_vote_info["subject"] == instance.subject assert instance_vote_info["description"] == None assert instance_vote_info["assigned_to"] == instance.assigned_to.id assert instance_vote_info["status"] == instance.status.name assert instance_vote_info["status_color"] == instance.status.color tags_colors = {tc["name"]:tc["color"] for tc in instance_vote_info["tags_colors"]} assert "test1" in tags_colors assert "test2" in tags_colors assert instance_vote_info["is_private"] == None assert instance_vote_info["logo_small_url"] == None assert instance_vote_info["is_voter"] == False assert instance_vote_info["is_watcher"] == False assert instance_vote_info["total_watchers"] == 0 assert instance_vote_info["total_voters"] == 3 assert instance_vote_info["project"] == instance.project.id assert instance_vote_info["project_name"] == instance.project.name assert instance_vote_info["project_slug"] == instance.project.slug assert instance_vote_info["project_is_private"] == instance.project.is_private assert instance_vote_info["project_blocked_code"] == instance.project.blocked_code assert instance_vote_info["assigned_to"] != None assert instance_vote_info["assigned_to_extra_info"]["username"] == instance.assigned_to.username assert instance_vote_info["assigned_to_extra_info"]["full_name_display"] == instance.assigned_to.get_full_name() assert instance_vote_info["assigned_to_extra_info"]["photo"] == None assert instance_vote_info["assigned_to_extra_info"]["gravatar_id"] != None