Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump canonicalwebteam.search version #4853

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion templates/publisher/listing.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
window.DNS_VERIFICATION_TOKEN = "{{ dns_verification_token }}"
window.SENTRY_DSN = "{{ SENTRY_DSN }}";
window.CSRF_TOKEN = "{{ csrf_token() }}";
window.listingData = JSON.parse({{ listing_data|tojson }});
window.listingData = JSON.parse({{ listing_data|default({})|tojson }});
window.tourSteps = {{ tour_steps|tojson }};
</script>
<script src="{{ static_url('js/dist/publisher-listing.js') }}"></script>
Expand Down
2 changes: 1 addition & 1 deletion templates/publisher/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
unlisted: {{ unlisted|tojson }},
whitelist_countries: {{ whitelist_country_codes|tojson }},
blacklist_countries: {{ blacklist_country_codes|tojson }},
visibility_locked: {{ visibility_locked|tojson }},
visibility_locked: {{ visibility_locked|default(false)|tojson }},
};
</script>
<script src="{{ static_url('js/dist/publisher-settings.js') }}"></script>
Expand Down
8 changes: 3 additions & 5 deletions tests/first_snap/tests_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@


class FirstSnap(TestCase):
render_templates = False

def create_app(self):
app = create_app(testing=True)
app.secret_key = "secret_key"
Expand Down Expand Up @@ -55,7 +53,7 @@ def test_get_package(self):

def test_get_package_snap_name(self):
self.client.set_cookie(
"snapcraft.io", "fsf_snap_name_python", "test-snap-name-python"
"localhost", "fsf_snap_name_python", "test-snap-name-python"
)
response = self.client.get(
"/first-snap/python/linux-auto/package",
Expand Down Expand Up @@ -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):
Expand All @@ -127,7 +125,7 @@ def test_get_upload(self):

def test_get_upload_snap_name(self):
self.client.set_cookie(
"snapcraft.io", "fsf_snap_name_python", "test-snap-name-python"
"localhost", "fsf_snap_name_python", "test-snap-name-python"
)
response = self.client.get(
"/first-snap/python/linux/upload",
Expand Down
6 changes: 2 additions & 4 deletions tests/login/tests_login_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
14 changes: 4 additions & 10 deletions tests/publisher/endpoint_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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,
)

Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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)
1 change: 1 addition & 0 deletions tests/publisher/snaps/test_post_preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def test_renders_template(self):
"snap_name": self.snap_name,
"images": [],
"title": self.snap_name,
"categories": [{"slug": "devices-and-iot"}],
}
)

Expand Down
2 changes: 1 addition & 1 deletion tests/publisher/snaps/tests_post_close_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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() == {}
Expand Down
2 changes: 1 addition & 1 deletion tests/publisher/snaps/tests_post_default_track.py
Original file line number Diff line number Diff line change
Expand Up @@ -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() == {}
Expand Down
2 changes: 1 addition & 1 deletion tests/publisher/snaps/tests_post_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]}
Expand Down
2 changes: 1 addition & 1 deletion tests/publisher/tests_account_logout.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ def test_logout(self):

self.assertEqual(302, response.status_code)

self.assertEqual("http://localhost/", response.location)
self.assertEqual("/", response.location)
6 changes: 6 additions & 0 deletions tests/publisher/tests_account_snaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def test_uploaded_snaps(self):
"channels": [],
}
],
"publisher": {"username": "Toto"},
}
}
}
Expand Down Expand Up @@ -136,6 +137,7 @@ def test_uploaded_snaps_with_latest_release(self):
"channels": ["edge"],
}
],
"publisher": {"username": "Toto"},
}
}
}
Expand Down Expand Up @@ -180,6 +182,7 @@ def test_uploaded_snaps_registered_snaps(self):
"channels": [],
}
],
"publisher": {"username": "Toto"},
},
"test2": {
"status": "Approved",
Expand Down Expand Up @@ -224,6 +227,7 @@ def test_uploaded_snaps_registered_snaps(self):
"channels": [],
}
],
"publisher": {"username": "Toto"},
}
}

Expand All @@ -249,6 +253,7 @@ def test_revoked_snaps(self):
"channels": [],
}
],
"publisher": {"username": "Toto"},
},
"test2": {
"status": "Approved",
Expand Down Expand Up @@ -311,6 +316,7 @@ def test_revoked_snaps(self):
"channels": [],
}
],
"publisher": {"username": "Toto"},
}
}

Expand Down
6 changes: 2 additions & 4 deletions tests/publisher/tests_agreement.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
22 changes: 7 additions & 15 deletions tests/publisher/tests_publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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

Expand Down Expand Up @@ -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
# ===
Expand All @@ -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
# ===
Expand All @@ -126,7 +120,7 @@ def test_post_username_logged_in(self):
responses.PATCH,
"https://dashboard.snapcraft.io/dev/api/account",
json={},
status=204,
status=200,
)

authorization = self._log_in(self.client)
Expand All @@ -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):
Expand All @@ -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):
Expand Down
14 changes: 7 additions & 7 deletions tests/publisher/tests_register_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand Down Expand Up @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/publisher/tests_register_name_dispute.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_register_name_dispute_redirect_no_snap_name(self):
response = self.client.get(self.endpoint_url)

self.assertEqual(response.status_code, 302)
self.assertRedirects(response, "/register-snap")
self.assertEqual(response.headers["Location"], "/register-snap")


class PostRegisterNameDisputeNotAuth(BaseTestCases.EndpointLoggedOut):
Expand Down
2 changes: 1 addition & 1 deletion tests/publisher/tests_reserved_name_dispute.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ def test_request_reserved_name_redirect_no_snap_name(self):
response = self.client.get(self.endpoint_url)

self.assertEqual(response.status_code, 302)
self.assertRedirects(response, "/register-snap")
self.assertEqual(response.headers["Location"], "/register-snap")
Loading
Loading