예제 #1
0
def test_update_membership_timeline():
    user_1 = factories.UserFactory.create()
    user_2 = factories.UserFactory.create()
    membership = factories.MembershipFactory.create(user=user_1)
    membership.user = user_2
    membership.save()
    project_timeline = service.get_project_timeline(membership.project)
    user_1_timeline = service.get_user_timeline(user_1)
    user_2_timeline = service.get_user_timeline(user_2)
    assert project_timeline[0].event_type == "projects.membership.delete"
    assert project_timeline[0].data["project"]["id"] == membership.project.id
    assert project_timeline[0].data["user"]["id"] == user_1.id
    assert project_timeline[0].data["user"]["name"] == user_1.get_full_name()
    assert project_timeline[1].event_type == "projects.membership.create"
    assert project_timeline[1].data["project"]["id"] == membership.project.id
    assert project_timeline[1].data["user"]["id"] == user_2.id
    assert project_timeline[1].data["user"]["name"] == user_2.get_full_name()
    assert user_1_timeline[0].event_type == "projects.membership.delete"
    assert user_1_timeline[0].data["project"]["id"] == membership.project.id
    assert user_1_timeline[0].data["user"]["id"] == user_1.id
    assert user_1_timeline[0].data["user"]["name"] == user_1.get_full_name()
    assert user_2_timeline[0].event_type == "projects.membership.create"
    assert user_2_timeline[0].data["project"]["id"] == membership.project.id
    assert user_2_timeline[0].data["user"]["id"] == user_2.id
    assert user_2_timeline[0].data["user"]["name"] == user_2.get_full_name()
예제 #2
0
def test_update_membership_timeline():
    user_1 = factories.UserFactory.create()
    user_2 = factories.UserFactory.create()
    membership = factories.MembershipFactory.create(user=user_1)
    membership.user = user_2
    membership.save()
    project_timeline = service.get_project_timeline(membership.project)
    user_1_timeline = service.get_user_timeline(user_1)
    user_2_timeline = service.get_user_timeline(user_2)
    assert project_timeline[0].event_type == "projects.membership.delete"
    assert project_timeline[0].data["project"]["id"] == membership.project.id
    assert project_timeline[0].data["user"]["id"] == user_1.id
    assert project_timeline[0].data["user"]["name"] == user_1.get_full_name()
    assert project_timeline[1].event_type == "projects.membership.create"
    assert project_timeline[1].data["project"]["id"] == membership.project.id
    assert project_timeline[1].data["user"]["id"] == user_2.id
    assert project_timeline[1].data["user"]["name"] == user_2.get_full_name()
    assert user_1_timeline[0].event_type == "projects.membership.delete"
    assert user_1_timeline[0].data["project"]["id"] == membership.project.id
    assert user_1_timeline[0].data["user"]["id"] == user_1.id
    assert user_1_timeline[0].data["user"]["name"] == user_1.get_full_name()
    assert user_2_timeline[0].event_type == "projects.membership.create"
    assert user_2_timeline[0].data["project"]["id"] == membership.project.id
    assert user_2_timeline[0].data["user"]["id"] == user_2.id
    assert user_2_timeline[0].data["user"]["name"] == user_2.get_full_name()
예제 #3
0
def _helper_get_timelines_for_accessing_users(project, users):
    """
    Get the number of timeline entries (of 'epics.relateduserstory' type) that the accessing users are able to see,
    for both a given project's timeline and the user's timelines
    :param project: the project with the epic which contains the related user stories
    :param users: both the accessing users, and the users from which recover their (user) timelines
    :return: Dict with counters for 'epics.relateduserstory' entries for both the (project) and (users)
    timelines, according to the accessing users privileges
    """
    timeline_counts = {'project_timelines': [], 'user_timelines': {}}
    # An anonymous user doesn't have a timeline to be recovered
    timeline_users = list(filter(lambda au: au != AnonymousUser(), users))

    for accessing_user in users:
        project_timeline = service.get_project_timeline(
            project, accessing_user)
        project_timeline = project_timeline.exclude(
            event_type__in=["projects.membership.create"])

        timeline_counts['project_timelines'].append(project_timeline.count())
        timeline_counts['user_timelines'][users.index(accessing_user)] = []

        for user in timeline_users:
            user_timeline = service.get_user_timeline(user, accessing_user)
            user_timeline = user_timeline.exclude(event_type__in=[
                "users.user.create", "projects.membership.create"
            ])

            timeline_counts['user_timelines'][users.index(
                accessing_user)].append(user_timeline.count())

    return timeline_counts
예제 #4
0
def test_create_membership_timeline():
    membership = factories.MembershipFactory.create()
    project_timeline = service.get_project_timeline(membership.project)
    user_timeline = service.get_user_timeline(membership.user)
    assert project_timeline[0].event_type == "projects.membership.create"
    assert project_timeline[0].data["project"]["id"] == membership.project.id
    assert project_timeline[0].data["user"]["id"] == membership.user.id
    assert user_timeline[0].event_type == "projects.membership.create"
    assert user_timeline[0].data["project"]["id"] == membership.project.id
    assert user_timeline[0].data["user"]["id"] == membership.user.id
예제 #5
0
def test_create_membership_timeline():
    membership = factories.MembershipFactory.create()
    project_timeline = service.get_project_timeline(membership.project)
    user_timeline = service.get_user_timeline(membership.user)
    assert project_timeline[0].event_type == "projects.membership.create"
    assert project_timeline[0].data["project"]["id"] == membership.project.id
    assert project_timeline[0].data["user"]["id"] == membership.user.id
    assert user_timeline[0].event_type == "projects.membership.create"
    assert user_timeline[0].data["project"]["id"] == membership.project.id
    assert user_timeline[0].data["user"]["id"] == membership.user.id
예제 #6
0
def test_owner_user_story_timeline():
    user_story = factories.UserStoryFactory.create(subject="test us timeline")
    history_services.take_snapshot(user_story, user=user_story.owner)
    user_timeline = service.get_user_timeline(user_story.owner)
    assert user_timeline[0].event_type == "userstories.userstory.create"
    assert user_timeline[0].data["userstory"]["subject"] == "test us timeline"
예제 #7
0
def test_owner_user_story_timeline():
    user_story = factories.UserStoryFactory.create(subject="test us timeline")
    history_services.take_snapshot(user_story, user=user_story.owner)
    user_timeline = service.get_user_timeline(user_story.owner)
    assert user_timeline[0].event_type == "userstories.userstory.create"
    assert user_timeline[0].data["userstory"]["subject"] == "test us timeline"