This repository has been archived by the owner on Feb 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #417 from multinet-app/user-test-context
- Loading branch information
Showing
4 changed files
with
73 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,42 @@ | ||
"""Tests that ensure fixtures act properly.""" | ||
|
||
from multinet.user import MULTINET_COOKIE | ||
|
||
|
||
def test_generated_workspace(handled_workspace, handled_user, server): | ||
def test_generated_workspace(managed_workspace, managed_user, server): | ||
"""Test that a generated workspace exists when querying the API.""" | ||
|
||
with server.session_transaction() as session: | ||
session[MULTINET_COOKIE] = handled_user.multinet.session | ||
with managed_user.login(server): | ||
resp = server.get(f"/api/workspaces/{managed_workspace}") | ||
assert resp.status_code == 200 | ||
|
||
|
||
resp = server.get(f"/api/workspaces/{handled_workspace}") | ||
assert resp.status_code == 200 | ||
def test_user_context(managed_workspace, managed_user, server): | ||
"""Test that the user context properly controls login.""" | ||
with managed_user.login(server): | ||
resp = server.get(f"/api/workspaces/{managed_workspace}/tables") | ||
assert resp.status_code == 200 | ||
|
||
resp = server.get(f"/api/workspaces/{managed_workspace}/tables") | ||
assert resp.status_code == 401 | ||
|
||
def test_populated_workspace(populated_workspace, handled_user, server): | ||
|
||
def test_populated_workspace(populated_workspace, managed_user, server): | ||
"""Test that the populated workspace has a graph, an edge and node table.""" | ||
workspace, graphs, *tables = populated_workspace | ||
|
||
with server.session_transaction() as session: | ||
session[MULTINET_COOKIE] = handled_user.multinet.session | ||
|
||
# Graphs | ||
resp = server.get(f"/api/workspaces/{workspace}/graphs") | ||
assert resp.status_code == 200 | ||
with managed_user.login(server): | ||
# Graphs | ||
resp = server.get(f"/api/workspaces/{workspace}/graphs") | ||
assert resp.status_code == 200 | ||
|
||
graphs = resp.json | ||
assert len(graphs) == 1 | ||
assert graphs[0] == "miserables" | ||
graphs = resp.json | ||
assert len(graphs) == 1 | ||
assert graphs[0] == "miserables" | ||
|
||
# Tables | ||
resp = server.get(f"/api/workspaces/{workspace}/tables") | ||
assert resp.status_code == 200 | ||
# Tables | ||
resp = server.get(f"/api/workspaces/{workspace}/tables") | ||
assert resp.status_code == 200 | ||
|
||
tables = resp.json | ||
assert len(tables) == 2 | ||
assert "miserables_nodes" in tables | ||
assert "miserables_links" in tables | ||
tables = resp.json | ||
assert len(tables) == 2 | ||
assert "miserables_nodes" in tables | ||
assert "miserables_links" in tables |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters