def test_get_watched_list_valid_info_for_project():
    fav_user = f.UserFactory()
    viewer_user = f.UserFactory()

    project = f.ProjectFactory(is_private=False, name="Testing project")
    role = f.RoleFactory(project=project, permissions=["view_project", "view_epic", "view_us", "view_tasks", "view_issues"])
    project.add_watcher(fav_user)

    raw_project_watch_info = get_watched_list(fav_user, viewer_user)[0]

    project_watch_info = LikedObjectSerializer(into_namedtuple(raw_project_watch_info)).data

    assert project_watch_info["type"] == "project"
    assert project_watch_info["id"] == project.id
    assert project_watch_info["ref"] == None
    assert project_watch_info["slug"] == project.slug
    assert project_watch_info["name"] == project.name
    assert project_watch_info["subject"] == None
    assert project_watch_info["description"] == project.description
    assert project_watch_info["assigned_to"] == None
    assert project_watch_info["status"] == None
    assert project_watch_info["status_color"] == None
    assert project_watch_info["is_private"] == project.is_private
    assert project_watch_info["logo_small_url"] ==  get_thumbnail_url(project.logo, settings.THN_LOGO_SMALL)
    assert project_watch_info["is_fan"] == False
    assert project_watch_info["is_watcher"] == False
    assert project_watch_info["total_watchers"] == 1
    assert project_watch_info["total_fans"] == 0
    assert project_watch_info["project"] == None
    assert project_watch_info["project_name"] == None
    assert project_watch_info["project_slug"] == None
    assert project_watch_info["project_is_private"] == None
    assert project_watch_info["project_blocked_code"] == None
    assert project_watch_info["assigned_to"] == None
    assert project_watch_info["assigned_to_extra_info"] == None
Example #2
0
def test_get_liked_list_valid_info():
    fan_user = f.UserFactory()
    viewer_user = f.UserFactory()

    project = f.ProjectFactory(is_private=False,
                               name="Testing project",
                               tags=['test', 'tag'])
    content_type = ContentType.objects.get_for_model(project)
    like = f.LikeFactory(content_type=content_type,
                         object_id=project.id,
                         user=fan_user)
    project.refresh_totals()

    raw_project_like_info = get_liked_list(fan_user, viewer_user)[0]
    project_like_info = LikedObjectSerializer(raw_project_like_info).data

    assert project_like_info["type"] == "project"
    assert project_like_info["id"] == project.id
    assert project_like_info["ref"] == None
    assert project_like_info["slug"] == project.slug
    assert project_like_info["name"] == project.name
    assert project_like_info["subject"] == None
    assert project_like_info["description"] == project.description
    assert project_like_info["assigned_to"] == None
    assert project_like_info["status"] == None
    assert project_like_info["status_color"] == None

    tags_colors = {
        tc["name"]: tc["color"]
        for tc in project_like_info["tags_colors"]
    }
    assert "test" in tags_colors
    assert "tag" in tags_colors

    assert project_like_info["is_private"] == project.is_private
    assert project_like_info["logo_small_url"] == get_thumbnail_url(
        project.logo, settings.THN_LOGO_SMALL)

    assert project_like_info["is_fan"] == False
    assert project_like_info["is_watcher"] == False
    assert project_like_info["total_watchers"] == 0
    assert project_like_info["total_fans"] == 1
    assert project_like_info["project"] == None
    assert project_like_info["project_name"] == None
    assert project_like_info["project_slug"] == None
    assert project_like_info["project_is_private"] == None
    assert project_like_info["project_blocked_code"] == None
    assert project_like_info["assigned_to_username"] == None
    assert project_like_info["assigned_to_full_name"] == None
    assert project_like_info["assigned_to_photo"] == None
Example #3
0
def test_get_watched_list_valid_info_for_project():
    fav_user = f.UserFactory()
    viewer_user = f.UserFactory()

    project = f.ProjectFactory(is_private=False,
                               name="Testing project",
                               tags=['test', 'tag'])
    role = f.RoleFactory(
        project=project,
        permissions=["view_project", "view_us", "view_tasks", "view_issues"])
    project.add_watcher(fav_user)

    raw_project_watch_info = get_watched_list(fav_user, viewer_user)[0]

    project_watch_info = LikedObjectSerializer(raw_project_watch_info).data

    assert project_watch_info["type"] == "project"
    assert project_watch_info["id"] == project.id
    assert project_watch_info["ref"] == None
    assert project_watch_info["slug"] == project.slug
    assert project_watch_info["name"] == project.name
    assert project_watch_info["subject"] == None
    assert project_watch_info["description"] == project.description
    assert project_watch_info["assigned_to"] == None
    assert project_watch_info["status"] == None
    assert project_watch_info["status_color"] == None

    tags_colors = {
        tc["name"]: tc["color"]
        for tc in project_watch_info["tags_colors"]
    }
    assert "test" in tags_colors
    assert "tag" in tags_colors

    assert project_watch_info["is_private"] == project.is_private
    assert project_watch_info["logo_small_url"] == get_thumbnail_url(
        project.logo, settings.THN_LOGO_SMALL)
    assert project_watch_info["is_fan"] == False
    assert project_watch_info["is_watcher"] == False
    assert project_watch_info["total_watchers"] == 1
    assert project_watch_info["total_fans"] == 0
    assert project_watch_info["project"] == None
    assert project_watch_info["project_name"] == None
    assert project_watch_info["project_slug"] == None
    assert project_watch_info["project_is_private"] == None
    assert project_watch_info["assigned_to_username"] == None
    assert project_watch_info["assigned_to_full_name"] == None
    assert project_watch_info["assigned_to_photo"] == None