Ejemplo n.º 1
0
def test_list_all_permissions(db, test_client, user_type, expected):
    """
    ADMIN - Can query all releases
    DEV - Can query all releases
    USER - Can query published releases and releases that their studies are in
    anonomous - Can only query published releases
    """

    releases = ReleaseFactory.create_batch(10, state='staged')
    releases = ReleaseFactory.create_batch(10, state='published')

    client = test_client(user_type)
    resp = client.post("/graphql", data={"query": ALL_RELEASES})
    # Test that the correct number of releases are returned
    assert len(resp.json()["data"]["allReleases"]["edges"]) == expected
Ejemplo n.º 2
0
def test_list_all_tasks_permissions(db, test_client, user_type, expected):
    """
    ADMIN - Can query all tasks
    DEV - Can query all tasks
    USER - Can query tasks from published releases, or releases that they
           have a study in.
    anonomous - Can query tasks from published releases
    """
    study = Study(kf_id="SD_00000001")
    study.save()

    releases = ReleaseFactory.create_batch(10, state="staged")
    releases = ReleaseFactory.create_batch(10, state="published")
    releases = ReleaseFactory.create_batch(
        10, state="staging", studies=[study]
    )

    client = test_client(user_type)
    resp = client.post("/graphql", data={"query": ALL_TASKS})
    # Test that the correct number of releases are returned
    assert len(resp.json()["data"]["allTasks"]["edges"]) == expected()
def test_list_all_tasks_permissions(db, test_client, user_type, expected):
    """
    ADMIN - Can query all task services
    DEV - Can query all task services
    USER - Cannot query any task services
    anonomous - Cannot query any task services

    The TaskServiceFactory maxes at 3 unique task services, so we should never
    expect more than than.
    """
    study = Study(kf_id="SD_00000001")
    study.save()

    releases = ReleaseFactory.create_batch(10, state="staged")
    releases = ReleaseFactory.create_batch(10, state="published")
    releases = ReleaseFactory.create_batch(10,
                                           state="staging",
                                           studies=[study])

    client = test_client(user_type)
    resp = client.post("/graphql", data={"query": ALL_TASK_SERVICES})
    # Test that the correct number of releases are returned
    assert len(resp.json()["data"]["allTaskServices"]["edges"]) == expected()
Ejemplo n.º 4
0
 def handle(self, *args, **options):
     ReleaseFactory.create_batch(100)
     self.stdout.write(self.style.SUCCESS("Created releases"))