Merge lp:~vila/ols-store-tests/x-ubuntu-arch into lp:~ubuntuone-pqm-team/ols-store-tests/store-acceptance-tests

Proposed by Vincent Ladeuil
Status: Merged
Approved by: Vincent Ladeuil
Approved revision: 44
Merged at revision: 43
Proposed branch: lp:~vila/ols-store-tests/x-ubuntu-arch
Merge into: lp:~ubuntuone-pqm-team/ols-store-tests/store-acceptance-tests
Diff against target: 49 lines (+12/-3)
2 files modified
tests/api/cpi/helpers.py (+2/-2)
tests/api/cpi/test_snaps.py (+10/-1)
To merge this branch: bzr merge lp:~vila/ols-store-tests/x-ubuntu-arch
Reviewer Review Type Date Requested Status
Para Siva (community) Approve
Review via email: mp+320470@code.launchpad.net

Commit message

X-Ubuntu-Architecture is now mandatory. Report better errors in cpi.assert_{success,not_found}.

Description of the change

cpi now requires X-Ubuntu-Architecture.

Fix failures, add a test for requests without architecture.

Improve error reporting.

To post a comment you must log in.
Revision history for this message
Para Siva (psivaa) wrote :

LGTM. Just a tiny nit of a comment. Feel free to ignore.

review: Approve
Revision history for this message
Vincent Ladeuil (vila) wrote :

fixed, thanks for the heads-up.

44. By Vincent Ladeuil

Simplify errror reporting, py3 unittest already prepends the assertion itself.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/api/cpi/helpers.py'
2--- tests/api/cpi/helpers.py 2016-09-14 20:05:35 +0000
3+++ tests/api/cpi/helpers.py 2017-03-21 10:30:28 +0000
4@@ -65,12 +65,12 @@
5 class APITestCase(unittest.TestCase):
6
7 def assert_success(self, response, content_type='application/hal+json'):
8- self.assertEqual(response.status_code, 200)
9+ self.assertEqual(response.status_code, 200, response.content)
10 self.assertEqual(response.headers['Content-Type'],
11 content_type)
12
13 def assert_not_found(self, response, message=None, new_style_error=False):
14- self.assertEqual(response.status_code, 404)
15+ self.assertEqual(response.status_code, 404, response.content)
16 self.assertEqual(response.headers['Content-Type'],
17 'application/hal+json')
18 expected = {
19
20=== modified file 'tests/api/cpi/test_snaps.py'
21--- tests/api/cpi/test_snaps.py 2017-03-13 11:55:37 +0000
22+++ tests/api/cpi/test_snaps.py 2017-03-21 10:30:28 +0000
23@@ -11,9 +11,11 @@
24 from .test_search import SearchTestCase
25
26
27-def get_snap_detail(name, series='16', auth=False):
28+def get_snap_detail(name, series='16', arch='amd64', auth=False):
29 url = '{}/api/v1/snaps/details/{}'.format(CPI_ROOT_URL, name)
30 headers = {}
31+ if arch:
32+ headers['X-Ubuntu-Architecture'] = arch
33 if series:
34 headers['X-Ubuntu-Series'] = series
35 if auth:
36@@ -104,6 +106,13 @@
37 message='X-Ubuntu-Series header is required.',
38 new_style_error=True)
39
40+ def test_get_snap_detail_without_arch(self):
41+ response = get_snap_detail(SNAP_PACKAGE_NAME, arch=None)
42+ self.assert_bad_request(
43+ response, code='missing-header',
44+ message='X-Ubuntu-Architecture header is required.',
45+ new_style_error=True)
46+
47 def test_get_snap_detail_unauthorized(self):
48 response = get_snap_detail(PRIVATE_SNAP_PACKAGE_NAME, auth=False)
49 self.assert_not_found(response, message='No such package',

Subscribers

People subscribed via source and target branches