Merge lp:~blake-rouse/maas/fix-1602721-2.0 into lp:maas/2.0

Proposed by Blake Rouse
Status: Merged
Approved by: Blake Rouse
Approved revision: 5175
Merged at revision: 5175
Proposed branch: lp:~blake-rouse/maas/fix-1602721-2.0
Merge into: lp:maas/2.0
Diff against target: 68 lines (+33/-3)
3 files modified
src/maasserver/api/tests/test_commissioning.py (+30/-0)
src/metadataserver/fields.py (+1/-1)
src/metadataserver/tests/test_fields.py (+2/-2)
To merge this branch: bzr merge lp:~blake-rouse/maas/fix-1602721-2.0
Reviewer Review Type Date Requested Status
Blake Rouse (community) Approve
Review via email: mp+301166@code.launchpad.net

Commit message

Prevent Bin class from causing Piston3 from having a circular dependency issue. An object that defines __emittable__ can not return an equal object as a result or a circular dependency will occur.

To post a comment you must log in.
Revision history for this message
Blake Rouse (blake-rouse) wrote :

Backport self-approval.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/api/tests/test_commissioning.py'
2--- src/maasserver/api/tests/test_commissioning.py 2016-05-24 14:43:27 +0000
3+++ src/maasserver/api/tests/test_commissioning.py 2016-07-26 12:24:30 +0000
4@@ -173,6 +173,36 @@
5 ]
6 )
7
8+ def test_list_returns_with_multiple_empty_data(self):
9+ commissioning_results = [
10+ factory.make_NodeResult_for_commissioning(data=b"")
11+ for counter in range(3)]
12+ url = reverse('node_results_handler')
13+ response = self.client.get(url)
14+ self.assertEqual(
15+ http.client.OK, response.status_code, response.content)
16+ parsed_results = json_load_bytes(response.content)
17+ self.assertItemsEqual(
18+ [
19+ (
20+ commissioning_result.name,
21+ commissioning_result.script_result,
22+ b64encode(commissioning_result.data).decode("utf-8"),
23+ commissioning_result.node.system_id,
24+ )
25+ for commissioning_result in commissioning_results
26+ ],
27+ [
28+ (
29+ result.get('name'),
30+ result.get('script_result'),
31+ result.get('data'),
32+ result.get('node').get('system_id'),
33+ )
34+ for result in parsed_results
35+ ]
36+ )
37+
38 def test_list_can_be_filtered_by_node(self):
39 commissioning_results = [
40 factory.make_NodeResult_for_commissioning()
41
42=== modified file 'src/metadataserver/fields.py'
43--- src/metadataserver/fields.py 2015-12-02 20:43:30 +0000
44+++ src/metadataserver/fields.py 2016-07-26 12:24:30 +0000
45@@ -57,7 +57,7 @@
46
47 Exists as a hook for Piston's JSON encoder.
48 """
49- return b64encode(self)
50+ return b64encode(self).decode('ascii')
51
52
53 class BinaryField(Field, metaclass=SubfieldBase):
54
55=== modified file 'src/metadataserver/tests/test_fields.py'
56--- src/metadataserver/tests/test_fields.py 2015-12-01 18:12:59 +0000
57+++ src/metadataserver/tests/test_fields.py 2016-07-26 12:24:30 +0000
58@@ -35,10 +35,10 @@
59 # Piston hooks onto an __emittable__() method, if present.
60 # Bin() returns a base-64 encoded string so that it can be
61 # transmitted in JSON.
62- self.assertEqual(b"", Bin(b"").__emittable__())
63+ self.assertEqual("", Bin(b"").__emittable__())
64 example_bytes = factory.make_bytes()
65 self.assertEqual(
66- b64encode(example_bytes),
67+ b64encode(example_bytes).decode('ascii'),
68 Bin(example_bytes).__emittable__())
69
70

Subscribers

People subscribed via source and target branches

to all changes: