diff --git a/requirements.txt b/requirements.txt index 1ab899f096..23179d900d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1,9 @@ # App dependencies -canonicalwebteam.flask-base==1.1.0 +canonicalwebteam.flask-base==2.0.0 canonicalwebteam.candid==0.9.0 canonicalwebteam.discourse==5.6.1 canonicalwebteam.blog==6.4.2 -canonicalwebteam.search==1.3.0 +canonicalwebteam.search==2.1.0 canonicalwebteam.image-template==1.3.1 canonicalwebteam.store-api==5.0.0 canonicalwebteam.launchpad==0.9.0 diff --git a/tests/first_snap/tests_views.py b/tests/first_snap/tests_views.py index 509c123088..4e6bc07960 100644 --- a/tests/first_snap/tests_views.py +++ b/tests/first_snap/tests_views.py @@ -8,8 +8,6 @@ class FirstSnap(TestCase): - render_templates = False - def create_app(self): app = create_app(testing=True) app.secret_key = "secret_key" @@ -100,7 +98,7 @@ def test_get_build_and_test_snap_name(self): assert response.status_code == 200 self.assert_context("language", "python") self.assert_context("os", "linux-auto") - self.assert_context("snap_name", "test-snap-name-python") + self.assert_context("snap_name", "test-offlineimap-{name}") self.assert_template_used("first-snap/build-and-test.html") def test_get_build_and_test_404_language(self): diff --git a/tests/login/tests_login_handler.py b/tests/login/tests_login_handler.py index 43d8f944be..21dc8011f9 100644 --- a/tests/login/tests_login_handler.py +++ b/tests/login/tests_login_handler.py @@ -7,8 +7,6 @@ class LoginHandlerTest(TestCase): - render_templates = False - def setUp(self): self.api_url = "https://dashboard.snapcraft.io/dev/api/acl/" self.endpoint_url = "/login" @@ -38,7 +36,7 @@ def test_redirect_user_logged_in_next_url(self): response = self.client.get(self.endpoint_url + "?next=/test") assert response.status_code == 302 - self.assertEqual("http://localhost/test", response.location) + self.assertEqual("/test", response.location) @responses.activate def test_login_handler_redirect(self): @@ -82,7 +80,7 @@ def test_login_api_401(self): assert len(responses.calls) == 1 assert response.status_code == 302 - self.assertEqual("http://localhost/logout", response.location) + self.assertEqual("/logout", response.location) @responses.activate def test_login_connection_error(self): diff --git a/tests/publisher/endpoint_testing.py b/tests/publisher/endpoint_testing.py index 9e989656a4..ceb967279d 100644 --- a/tests/publisher/endpoint_testing.py +++ b/tests/publisher/endpoint_testing.py @@ -19,8 +19,6 @@ class BaseTestCases: """ class BaseAppTesting(TestCase): - render_templates = False - def setUp(self, snap_name, api_url, endpoint_url): self.snap_name = snap_name self.api_url = api_url @@ -37,7 +35,7 @@ def create_app(self): return app def _get_location(self): - return "http://localhost{}".format(self.endpoint_url) + return "{}".format(self.endpoint_url) def _log_in(self, client): """Emulates test client login in the store. @@ -93,7 +91,7 @@ def test_access_not_logged_in(self): self.assertEqual(302, response.status_code) self.assertEqual( - "http://localhost/login?next={}".format(self.endpoint_url), + "/login?next={}".format(self.endpoint_url), response.location, ) @@ -360,9 +358,7 @@ def test_account_not_signed_agreement_logged_in(self): self.check_call_by_api_url(responses.calls) self.assertEqual(302, response.status_code) - self.assertEqual( - "http://localhost/account/agreement", response.location - ) + self.assertEqual("/account/agreement", response.location) @responses.activate def test_account_no_username_logged_in(self): @@ -398,6 +394,4 @@ def test_account_no_username_logged_in(self): self.check_call_by_api_url(responses.calls) self.assertEqual(302, response.status_code) - self.assertEqual( - "http://localhost/account/username", response.location - ) + self.assertEqual("/account/username", response.location) diff --git a/tests/publisher/snaps/tests_post_close_channel.py b/tests/publisher/snaps/tests_post_close_channel.py index 47e069ac1f..0ed99acc8a 100644 --- a/tests/publisher/snaps/tests_post_close_channel.py +++ b/tests/publisher/snaps/tests_post_close_channel.py @@ -96,7 +96,7 @@ def test_page_not_found(self): self.assert_template_used("404.html") def test_post_no_data(self): - response = self.client.post(self.endpoint_url) + response = self.client.post(self.endpoint_url, json={}) assert response.status_code == 400 assert response.get_json() == {} diff --git a/tests/publisher/snaps/tests_post_default_track.py b/tests/publisher/snaps/tests_post_default_track.py index ff2d01d262..cddd6f0f05 100644 --- a/tests/publisher/snaps/tests_post_default_track.py +++ b/tests/publisher/snaps/tests_post_default_track.py @@ -97,7 +97,7 @@ def test_page_not_found(self): self.assert_template_used("404.html") def test_post_no_data(self): - response = self.client.post(self.endpoint_url) + response = self.client.post(self.endpoint_url, json={}) assert response.status_code == 400 assert response.get_json() == {} diff --git a/tests/publisher/snaps/tests_post_release.py b/tests/publisher/snaps/tests_post_release.py index 3223e05a53..f4bddc129c 100644 --- a/tests/publisher/snaps/tests_post_release.py +++ b/tests/publisher/snaps/tests_post_release.py @@ -55,7 +55,7 @@ def test_page_not_found(self): @responses.activate def test_post_no_data(self): - response = self.client.post(self.endpoint_url) + response = self.client.post(self.endpoint_url, json={}) assert response.status_code == 400 assert response.get_json() == {"errors": ["No changes were submitted"]} diff --git a/tests/publisher/tests_account_logout.py b/tests/publisher/tests_account_logout.py index dcc303d8e8..fbd1f9b685 100644 --- a/tests/publisher/tests_account_logout.py +++ b/tests/publisher/tests_account_logout.py @@ -17,4 +17,4 @@ def test_logout(self): self.assertEqual(302, response.status_code) - self.assertEqual("http://localhost/", response.location) + self.assertEqual("/", response.location) diff --git a/tests/publisher/tests_agreement.py b/tests/publisher/tests_agreement.py index bfda6ddb5f..ad9b16fea5 100644 --- a/tests/publisher/tests_agreement.py +++ b/tests/publisher/tests_agreement.py @@ -49,13 +49,11 @@ def test_post_agreement_on(self): self.assertEqual(b'{"latest_tos_accepted": true}', called.request.body) self.assertEqual(302, response.status_code) - self.assertEqual("http://localhost/account/", response.location) + self.assertEqual("/account/", response.location) @responses.activate def test_post_agreement_off(self): response = self.client.post(self.endpoint_url, data={"i_agree": "off"}) self.assertEqual(302, response.status_code) - self.assertEqual( - "http://localhost/account/agreement", response.location - ) + self.assertEqual("/account/agreement", response.location) diff --git a/tests/publisher/tests_publisher.py b/tests/publisher/tests_publisher.py index ea80755039..e3a8ba52d3 100644 --- a/tests/publisher/tests_publisher.py +++ b/tests/publisher/tests_publisher.py @@ -45,8 +45,6 @@ def test_cache_disabled(self): class PublisherPage(TestCase): - render_templates = False - def create_app(self): app = create_app(testing=True) app.secret_key = "secret_key" @@ -56,7 +54,7 @@ def create_app(self): def test_account(self): local_redirect = self.client.get("/account") - redirect_url = "http://localhost/login?next=/account" + redirect_url = "/login?next=/account" assert local_redirect.status_code == 302 assert local_redirect.headers.get("Location") == redirect_url @@ -90,16 +88,12 @@ def _log_in(self, client): def test_username_not_logged_in(self): response = self.client.get("/account/username") self.assertEqual(302, response.status_code) - self.assertEqual( - "http://localhost/login?next=/account/username", response.location - ) + self.assertEqual("/login?next=/account/username", response.location) def test_account_not_logged_in(self): response = self.client.get("/account") self.assertEqual(302, response.status_code) - self.assertEqual( - "http://localhost/login?next=/account", response.location - ) + self.assertEqual("/login?next=/account", response.location) # /account endpoint # === @@ -108,7 +102,7 @@ def test_account_redirect(self): self._log_in(self.client) response = self.client.get("/account") self.assertEqual(302, response.status_code) - self.assertEqual("http://localhost/snaps", response.location) + self.assertEqual("/snaps", response.location) # /account/username endpoint # === @@ -147,7 +141,7 @@ def test_post_username_logged_in(self): self.assertEqual(b'{"short_namespace": "toto"}', called.request.body) self.assertEqual(302, response.status_code) - self.assertEqual("http://localhost/account/", response.location) + self.assertEqual("/account/", response.location) @responses.activate def test_post_no_username_logged_in(self): @@ -157,9 +151,7 @@ def test_post_no_username_logged_in(self): self.assertEqual(0, len(responses.calls)) self.assertEqual(302, response.status_code) - self.assertEqual( - "http://localhost/account/username", response.location - ) + self.assertEqual("/account/username", response.location) @responses.activate def test_post_bad_username_logged_in(self): diff --git a/tests/publisher/tests_register_name.py b/tests/publisher/tests_register_name.py index 66f521f60d..cf2953986b 100644 --- a/tests/publisher/tests_register_name.py +++ b/tests/publisher/tests_register_name.py @@ -151,7 +151,7 @@ def test_post_snap_name(self): self.assertEqual(b'{"snap_name": "test-snap"}', called.request.body) assert response.status_code == 302 - self.assertEqual(response.location, "http://localhost/account/") + self.assertEqual(response.location, "/account/") @responses.activate def test_post_store(self): @@ -170,7 +170,7 @@ def test_post_store(self): self.assertIn(b'"store": "store"', called.request.body) assert response.status_code == 302 - self.assertEqual(response.location, "http://localhost/account/") + self.assertEqual(response.location, "/account/") @responses.activate def test_post_private(self): @@ -189,7 +189,7 @@ def test_post_private(self): self.assertIn(b'"is_private": true', called.request.body) assert response.status_code == 302 - self.assertEqual(response.location, "http://localhost/account/") + self.assertEqual(response.location, "/account/") @responses.activate def test_post_registrant_comment(self): @@ -208,7 +208,7 @@ def test_post_registrant_comment(self): self.assertIn(b'"registrant_comment": "comment"', called.request.body) assert response.status_code == 302 - self.assertEqual(response.location, "http://localhost/account/") + self.assertEqual(response.location, "/account/") @responses.activate def test_error_from_api(self): @@ -240,7 +240,7 @@ def test_name_already_registered(self): assert response.status_code == 302 self.assertIn("snap_name=test-snap", response.location) self.assertIn("is_private=False", response.location) - self.assertIn("http://localhost/register-snap", response.location) + self.assertIn("/register-snap", response.location) @responses.activate def test_name_reserved(self): @@ -257,7 +257,7 @@ def test_name_reserved(self): assert response.status_code == 302 self.assertIn("snap_name=test-snap", response.location) self.assertIn("is_private=False", response.location) - self.assertIn("http://localhost/register-snap", response.location) + self.assertIn("/register-snap", response.location) @responses.activate def test_claim_dispute(self): @@ -272,7 +272,7 @@ def test_claim_dispute(self): response = self.client.post(self.endpoint_url, data=self.data) assert response.status_code == 302 - self.assertEqual(response.location, "http://localhost/admin/account") + self.assertEqual(response.location, "/admin/account") @responses.activate def test_post_error_user_error(self): diff --git a/tests/publisher/tests_register_name_dispute.py b/tests/publisher/tests_register_name_dispute.py index 81c5a33195..5252923f19 100644 --- a/tests/publisher/tests_register_name_dispute.py +++ b/tests/publisher/tests_register_name_dispute.py @@ -49,7 +49,7 @@ def test_register_name_dispute_redirect_no_snap_name(self): responses.add( responses.GET, self.user_url, json=self.user_payload, status=200 ) - response = self.client.get(self.endpoint_url) + response = self.client.get(self.endpoint_url, follow_redirects=True) self.assertEqual(response.status_code, 302) self.assertRedirects(response, "/register-snap") diff --git a/tests/publisher/tests_reserved_name_dispute.py b/tests/publisher/tests_reserved_name_dispute.py index 1eb204fe4b..27dd51806b 100644 --- a/tests/publisher/tests_reserved_name_dispute.py +++ b/tests/publisher/tests_reserved_name_dispute.py @@ -47,7 +47,7 @@ def test_request_reserved_name_redirect_no_snap_name(self): responses.add( responses.GET, self.user_url, json=self.user_payload, status=200 ) - response = self.client.get(self.endpoint_url) + response = self.client.get(self.endpoint_url, follow_redirects=True) self.assertEqual(response.status_code, 302) self.assertRedirects(response, "/register-snap") diff --git a/tests/publisher/tests_username.py b/tests/publisher/tests_username.py index 1d32c6c01a..64820d191b 100644 --- a/tests/publisher/tests_username.py +++ b/tests/publisher/tests_username.py @@ -61,22 +61,18 @@ def test_post_username(self): self.assertEqual(b'{"short_namespace": "toto"}', called.request.body) self.assertEqual(302, response.status_code) - self.assertEqual("http://localhost/account/", response.location) + self.assertEqual("/account/", response.location) @responses.activate def test_post_username_empty(self): response = self.client.post(self.endpoint_url, data={"username": ""}) self.assertEqual(302, response.status_code) - self.assertEqual( - "http://localhost/account/username", response.location - ) + self.assertEqual("/account/username", response.location) @responses.activate def test_post_no_data(self): response = self.client.post(self.endpoint_url, data={}) self.assertEqual(302, response.status_code) - self.assertEqual( - "http://localhost/account/username", response.location - ) + self.assertEqual("/account/username", response.location) diff --git a/tests/snapcraft/tests_public.py b/tests/snapcraft/tests_public.py index 7826f3112f..5fb6d330ae 100644 --- a/tests/snapcraft/tests_public.py +++ b/tests/snapcraft/tests_public.py @@ -7,8 +7,6 @@ class StorePage(TestCase): - render_templates = False - def create_app(self): app = create_app(testing=True) app.secret_key = "secret_key" diff --git a/tests/store/tests_details.py b/tests/store/tests_details.py index 60e49679f9..da322cab24 100644 --- a/tests/store/tests_details.py +++ b/tests/store/tests_details.py @@ -5,8 +5,6 @@ class GetDetailsPageTest(TestCase): - render_templates = False - def setUp(self): self.snap_name = "toto" self.api_url = "".join( diff --git a/tests/store/tests_distro_page.py b/tests/store/tests_distro_page.py index fac05bf3b0..72f4a09ebc 100644 --- a/tests/store/tests_distro_page.py +++ b/tests/store/tests_distro_page.py @@ -5,8 +5,6 @@ class GetDistroPageTest(TestCase): - render_templates = False - snap_payload = { "snap-id": "id", "name": "snapName", diff --git a/tests/store/tests_embedded_card.py b/tests/store/tests_embedded_card.py index 7bd0c2c7b6..fa46f0c043 100644 --- a/tests/store/tests_embedded_card.py +++ b/tests/store/tests_embedded_card.py @@ -5,8 +5,6 @@ class GetEmbeddedCardTest(TestCase): - render_templates = False - snap_payload = { "snap-id": "id", "name": "snapName", diff --git a/tests/store/tests_github_badge.py b/tests/store/tests_github_badge.py index c72ae14e50..376e14e884 100644 --- a/tests/store/tests_github_badge.py +++ b/tests/store/tests_github_badge.py @@ -5,8 +5,6 @@ class GetGitHubBadgeTest(TestCase): - render_templates = False - snap_payload = { "snap-id": "id", "name": "snapName", diff --git a/tests/store/tests_publisher.py b/tests/store/tests_publisher.py index abaa2ab8d8..49be48483c 100644 --- a/tests/store/tests_publisher.py +++ b/tests/store/tests_publisher.py @@ -5,8 +5,6 @@ class GetPublisherPageTest(TestCase): - render_templates = False - def setUp(self): self.publisher = "jetbrains" self.api_url = "".join( diff --git a/tests/tests_badge_counter.py b/tests/tests_badge_counter.py index fc5227743d..dddfc31bf9 100644 --- a/tests/tests_badge_counter.py +++ b/tests/tests_badge_counter.py @@ -4,8 +4,6 @@ class TestsBadgePrometheusCounter(TestCase): - render_templates = False - def setUp(self): self.endpoint_url = "/static/images/badges/en/snap-store-black.svg" badge_counter._value.set(0.0) diff --git a/webapp/docs/views.py b/webapp/docs/views.py index 8df599350b..6625ae774f 100644 --- a/webapp/docs/views.py +++ b/webapp/docs/views.py @@ -38,6 +38,7 @@ def init_docs(app, url_prefix): "/docs/search", "docs-search", build_search_view( + app=app, session=session, site="snapcraft.io/docs", template_path="docs/search.html",