Skip to content

Commit

Permalink
Bugfix: correct URLs of project pages (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
akochari authored Apr 11, 2024
1 parent 5db1c4a commit 50b2829
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 101 deletions.
4 changes: 2 additions & 2 deletions apps/tests/test_app_settings_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def test_user_can_edit_true(self):

self.assertEqual(response.status_code, 302)

url = f"/{self.project.slug}/" + f"apps/settings/{self.app_instance.id}"
url = f"/projects/{self.project.slug}/" + f"apps/settings/{self.app_instance.id}"

response = c.get(url)

Expand All @@ -84,7 +84,7 @@ def test_user_can_edit_false(self):
self.app.user_can_edit = True
self.app.save()

url = f"/{self.project.slug}/" + f"apps/settings/{self.app_instance.id}"
url = f"/projects/{self.project.slug}/" + f"apps/settings/{self.app_instance.id}"

response = c.get(url)

Expand Down
40 changes: 20 additions & 20 deletions apps/tests/test_create_app_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def test_has_permission(self):

self.assertEqual(response.status_code, 302)

response = c.get(f"/{project.slug}/apps/create/jupyter-lab")
response = c.get(f"/projects/{project.slug}/apps/create/jupyter-lab")

self.assertEqual(response.status_code, 200)

Expand All @@ -75,11 +75,11 @@ def test_has_reached_app_limit(self):

self.assertEqual(response.status_code, 302)

response = c.get(f"/{project.slug}/apps/create/jupyter-lab")
response = c.get(f"/projects/{project.slug}/apps/create/jupyter-lab")

self.assertEqual(response.status_code, 403)

response = c.post(f"/{project.slug}/apps/create/jupyter-lab")
response = c.post(f"/projects/{project.slug}/apps/create/jupyter-lab")

self.assertEqual(response.status_code, 403)

Expand All @@ -96,11 +96,11 @@ def test_missing_access_to_project(self):

self.assertEqual(response.status_code, 302)

response = c.get(f"/{project.slug}/apps/create/jupyter-lab")
response = c.get(f"/projects/{project.slug}/apps/create/jupyter-lab")

self.assertEqual(response.status_code, 403)

response = c.post(f"/{project.slug}/apps/create/jupyter-lab")
response = c.post(f"/projects/{project.slug}/apps/create/jupyter-lab")

self.assertEqual(response.status_code, 403)

Expand All @@ -119,7 +119,7 @@ def test_has_permission_when_none(self):

self.assertEqual(response.status_code, 302)

response = c.get(f"/{project.slug}/apps/create/jupyter-lab")
response = c.get(f"/projects/{project.slug}/apps/create/jupyter-lab")

self.assertEqual(response.status_code, 200)

Expand All @@ -134,7 +134,7 @@ def test_has_permission_when_not_specified(self):

self.assertEqual(response.status_code, 302)

response = c.get(f"/{project.slug}/apps/create/jupyter-lab")
response = c.get(f"/projects/{project.slug}/apps/create/jupyter-lab")

self.assertEqual(response.status_code, 200)

Expand All @@ -153,13 +153,13 @@ def test_has_permission_project_level(self):

self.assertEqual(response.status_code, 302)

response = c.get(f"/{project.slug}/apps/create/jupyter-lab")
response = c.get(f"/projects/{project.slug}/apps/create/jupyter-lab")

self.assertEqual(response.status_code, 200)

project = self.get_data()

response = c.get(f"/{project.slug}/apps/create/jupyter-lab")
response = c.get(f"/projects/{project.slug}/apps/create/jupyter-lab")

self.assertEqual(response.status_code, 200)

Expand All @@ -171,7 +171,7 @@ def test_has_permission_project_level(self):
project=project,
)

response = c.get(f"/{project.slug}/apps/create/jupyter-lab")
response = c.get(f"/projects/{project.slug}/apps/create/jupyter-lab")

self.assertEqual(response.status_code, 403)

Expand All @@ -186,7 +186,7 @@ def test_permission_overrides_reached_app_limit(self):

self.assertEqual(response.status_code, 302)

response = c.get(f"/{project.slug}/apps/create/jupyter-lab")
response = c.get(f"/projects/{project.slug}/apps/create/jupyter-lab")

self.assertEqual(response.status_code, 403)

Expand All @@ -202,7 +202,7 @@ def test_permission_overrides_reached_app_limit(self):

self.user = User.objects.get(username=test_user["email"])

response = c.get(f"/{project.slug}/apps/create/jupyter-lab")
response = c.get(f"/projects/{project.slug}/apps/create/jupyter-lab")

self.assertEqual(response.status_code, 200)

Expand All @@ -217,7 +217,7 @@ def test_app_limit_is_per_project(self):

self.assertEqual(response.status_code, 302)

response = c.get(f"/{project.slug}/apps/create/jupyter-lab")
response = c.get(f"/projects/{project.slug}/apps/create/jupyter-lab")

self.assertEqual(response.status_code, 200)

Expand All @@ -226,7 +226,7 @@ def test_app_limit_is_per_project(self):
project.authorized.add(user2)
project.save()

response = c.get(f"/{project.slug}/apps/create/jupyter-lab")
response = c.get(f"/projects/{project.slug}/apps/create/jupyter-lab")

self.assertEqual(response.status_code, 200)

Expand All @@ -238,11 +238,11 @@ def test_app_limit_is_per_project(self):
project=project,
)

response = c.get(f"/{project.slug}/apps/create/jupyter-lab")
response = c.get(f"/projects/{project.slug}/apps/create/jupyter-lab")

self.assertEqual(response.status_code, 403)

response = c.get(f"/{project.slug}/apps/create/jupyter-lab")
response = c.get(f"/projects/{project.slug}/apps/create/jupyter-lab")

self.assertEqual(response.status_code, 403)

Expand All @@ -261,7 +261,7 @@ def test_app_limit_altered_for_project(self):

project.save()

response = c.get(f"/{project.slug}/apps/create/jupyter-lab")
response = c.get(f"/projects/{project.slug}/apps/create/jupyter-lab")

self.assertEqual(response.status_code, 403)

Expand All @@ -276,7 +276,7 @@ def test_app_limit_altered_for_project_v2(self):

self.assertEqual(response.status_code, 302)

response = c.get(f"/{project.slug}/apps/create/jupyter-lab")
response = c.get(f"/projects/{project.slug}/apps/create/jupyter-lab")

self.assertEqual(response.status_code, 200)

Expand All @@ -288,14 +288,14 @@ def test_app_limit_altered_for_project_v2(self):
project=project,
)

response = c.get(f"/{project.slug}/apps/create/jupyter-lab")
response = c.get(f"/projects/{project.slug}/apps/create/jupyter-lab")

self.assertEqual(response.status_code, 403)

project.apps_per_project["jupyter-lab"] = 2

project.save()

response = c.get(f"/{project.slug}/apps/create/jupyter-lab")
response = c.get(f"/projects/{project.slug}/apps/create/jupyter-lab")

self.assertEqual(response.status_code, 200)
4 changes: 2 additions & 2 deletions apps/tests/test_delete_app_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def test_user_can_delete_false(self):

self.assertEqual(response.status_code, 302)

url = f"/{self.project.slug}/apps/delete/" + f"{self.category.slug}/{self.app_instance.id}"
url = f"/projects/{self.project.slug}/apps/delete/" + f"{self.category.slug}/{self.app_instance.id}"

response = c.get(url)

Expand All @@ -83,7 +83,7 @@ def test_user_can_delete_true(self):
self.app.save()

with patch("apps.tasks.delete_resource.delay") as mock_task:
url = f"/{self.project.slug}/apps/delete/" + f"{self.category.slug}/{self.app_instance.id}"
url = f"/projects/{self.project.slug}/apps/delete/" + f"{self.category.slug}/{self.app_instance.id}"

response = c.get(url)

Expand Down
8 changes: 4 additions & 4 deletions apps/tests/test_get_status_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_user_has_access(self):

self.assertEqual(response.status_code, 302)

url = f"/{self.project.slug}/apps/status"
url = f"/projects/{self.project.slug}/apps/status"

response = c.post(url, {"apps": [self.app_instance.id]})

Expand All @@ -51,7 +51,7 @@ def test_user_has_access(self):
def test_user_has_no_access(self):
c = Client()

url = f"/{self.project.slug}/apps/status"
url = f"/projects/{self.project.slug}/apps/status"

response = c.post(url, {"apps": [self.app_instance.id]})

Expand All @@ -62,7 +62,7 @@ def test_user_has_no_access(self):

self.assertEqual(response.status_code, 200)

url = f"/{self.project.slug}/apps/status"
url = f"/projects/{self.project.slug}/apps/status"

response = c.post(url, {"apps": [self.app_instance.id]})

Expand All @@ -76,7 +76,7 @@ def test_apps_empty(self):

self.assertEqual(response.status_code, 302)

url = f"/{self.project.slug}/apps/status"
url = f"/projects/{self.project.slug}/apps/status"

response = c.post(url, {"apps": []})

Expand Down
1 change: 0 additions & 1 deletion cypress/e2e/ui-tests/test-public-webpages.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ describe("Tests of the public pages of the website", () => {
cy.get("li.nav-item a").contains("User guide").click()
cy.url().should("include", "/docs/")
cy.get('[data-cy="sidebar-title"]').should('contain', 'user guide') // check that the sidebar title is there, comes from our templates
cy.get('.col-lg-8 > h1').should('contain', 'Congratulations') // check that the page content is there, comes from django-wiki templates
})

it("should open the signup page on link click", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,4 +363,35 @@ describe("Test superuser access", () => {

})

it("can add pages to user docs", () => {

const root_article_name = "user-documentation"
const root_article_content = "user-documentation-homepage"
const regular_article_name ="regular-article"
const regular_article_slug ="regular-article"
const regular_article_content = "regular-article-content"

cy.log("Creating the root article")
cy.visit("/docs/")
cy.get('h1').should('contain', 'Congratulations') // check that django-wiki was correctly installed
cy.get('#id_title').clear().type(root_article_name)
cy.get('#id_content').clear().type(root_article_content)
cy.get('button[name="save_changes"]').click()
cy.log("Checking that the root article was successfully created")
cy.get('h1#article-title').contains(root_article_name)
cy.get('div.wiki-article').contains(root_article_content)

cy.log("Adding a regular article")
cy.get(".btn-group").get(".btn").contains("Add a new article").click()
cy.get(".btn-group").get("a.dropdown-item").contains("New article below").click()
cy.url().should("include", "/docs/_create/")
cy.get('#id_title').clear().type(regular_article_name)
cy.get('#id_content').clear().type(regular_article_content)
cy.get('button[name="save_changes"]').click()
cy.log("Checking that the regular article was successfully created")
cy.url().should("include", regular_article_slug)
cy.get('h1#article-title').contains(regular_article_name)
cy.get('div.wiki-article').contains(regular_article_content)
})

})
6 changes: 3 additions & 3 deletions projects/tests/test_grant_access_to_project_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_grant_access_to_user(self):
project = self.get_data()

response = self.client.post(
f"/{project.slug}/project/access/grant/",
f"/projects/{project.slug}/project/access/grant/",
{"selected_user": test_user_2["email"]},
)

Expand Down Expand Up @@ -72,7 +72,7 @@ def test_grant_access_to_user_no_access(self):
project = self.get_data(user=self.user2)

response = self.client.post(
f"/{project.slug}/project/access/grant/",
f"/projects/{project.slug}/project/access/grant/",
{"selected_user": test_user_2["email"]},
)

Expand All @@ -89,7 +89,7 @@ def test_grant_access_to_non_existing_user(self):
project = self.get_data()

response = self.client.post(
f"/{project.slug}/project/access/grant/",
f"/projects/{project.slug}/project/access/grant/",
{"selected_user": "non_existing_user"},
)

Expand Down
8 changes: 4 additions & 4 deletions projects/tests/test_revoke_access_to_project_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_revoke_access_to_user(self):
project = self.get_data()

response = self.client.post(
f"/{project.slug}/project/access/revoke/",
f"/projects/{project.slug}/project/access/revoke/",
{"selected_user": test_user_2["email"]},
)

Expand Down Expand Up @@ -71,7 +71,7 @@ def test_revoke_access_non_existing_user(self):
project = self.get_data()

response = self.client.post(
f"/{project.slug}/project/access/revoke/",
f"/projects/{project.slug}/project/access/revoke/",
{"selected_user": "non_existing_user"},
)

Expand All @@ -88,7 +88,7 @@ def test_revoke_access_user_no_access_to_project(self):
project = self.get_data()

response = self.client.post(
f"/{project.slug}/project/access/revoke/",
f"/projects/{project.slug}/project/access/revoke/",
{"selected_user": test_user_3["email"]},
)

Expand All @@ -107,7 +107,7 @@ def test_revoke_access_can_not_remove_if_not_owner(self):
project.authorized.add(self.user3)

response = self.client.post(
f"/{project.slug}/project/access/revoke/",
f"/projects/{project.slug}/project/access/revoke/",
{"selected_user": test_user_3["email"]},
)

Expand Down
6 changes: 3 additions & 3 deletions projects/tests/test_update_pattern_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ def test_update_pattern_view(self):

# Test with valid pattern
response = self.client.post(
f"/{project.slug}/pattern/update/",
f"/projects/{project.slug}/pattern/update/",
{"pattern": "pattern-1"},
)

self.assertEqual(response.status_code, 200)

# Test with invalid pattern
response = self.client.post(
f"/{project.slug}/pattern/update/",
f"/projects/{project.slug}/pattern/update/",
{"pattern": "pattern-0"},
)

Expand All @@ -55,7 +55,7 @@ def test_update_pattern_view_no_access(self):
project = self.get_data()

response = self.client.post(
f"/{project.slug}/pattern/update/",
f"/projects/{project.slug}/pattern/update/",
{"pattern": "pattern-1"},
)

Expand Down
Loading

0 comments on commit 50b2829

Please sign in to comment.