~ltrager/maas/lp1554636_2.0

« back to all changes in this revision

Viewing changes to src/maasserver/api/tests/test_boot_source_selections.py

Merge Blake's branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
__all__ = []
7
7
 
8
8
import http.client
9
 
import json
10
9
 
11
10
from django.core.urlresolvers import reverse
12
11
from maasserver.api.boot_source_selections import (
17
16
from maasserver.testing.api import APITestCase
18
17
from maasserver.testing.factory import factory
19
18
from maasserver.testing.orm import reload_object
 
19
from maasserver.utils.converters import json_load_bytes
20
20
from testtools.matchers import MatchesStructure
21
21
 
22
22
 
67
67
        response = self.client.get(
68
68
            get_boot_source_selection_uri(boot_source_selection))
69
69
        self.assertEqual(http.client.OK, response.status_code)
70
 
        returned_boot_source_selection = json.loads(response.content)
 
70
        returned_boot_source_selection = json_load_bytes(response.content)
71
71
        boot_source = boot_source_selection.boot_source
72
72
        # The returned object contains a 'resource_uri' field.
73
73
        self.assertEqual(
160
160
        response = self.client.get(
161
161
            get_boot_source_selection_backward_uri(boot_source_selection))
162
162
        self.assertEqual(http.client.OK, response.status_code)
163
 
        returned_boot_source_selection = json.loads(response.content)
 
163
        returned_boot_source_selection = json_load_bytes(response.content)
164
164
        boot_source = boot_source_selection.boot_source
165
165
        # The returned object contains a 'resource_uri' field.
166
166
        self.assertEqual(
190
190
                get_boot_source_selection_backward_uri(
191
191
                    boot_source_selection, nodegroup))
192
192
            self.assertEqual(http.client.OK, response.status_code)
193
 
            returned_boot_source_selection = json.loads(response.content)
 
193
            returned_boot_source_selection = json_load_bytes(response.content)
194
194
            del returned_boot_source_selection['resource_uri']
195
195
            self.assertThat(
196
196
                boot_source_selection,
274
274
                args=[boot_source.id]))
275
275
        self.assertEqual(
276
276
            http.client.OK, response.status_code, response.content)
277
 
        parsed_result = json.loads(response.content)
 
277
        parsed_result = json_load_bytes(response.content)
278
278
        self.assertItemsEqual(
279
279
            [selection.id for selection in selections],
280
280
            [selection.get('id') for selection in parsed_result])
306
306
                'boot_source_selections_handler',
307
307
                args=[boot_source.id]), params)
308
308
        self.assertEqual(http.client.OK, response.status_code)
309
 
        parsed_result = json.loads(response.content)
 
309
        parsed_result = json_load_bytes(response.content)
310
310
 
311
311
        boot_source_selection = BootSourceSelection.objects.get(
312
312
            id=parsed_result['id'])
361
361
        response = self.client.get(self.get_uri(boot_source))
362
362
        self.assertEqual(
363
363
            http.client.OK, response.status_code, response.content)
364
 
        parsed_result = json.loads(response.content)
 
364
        parsed_result = json_load_bytes(response.content)
365
365
        self.assertItemsEqual(
366
366
            [selection.id for selection in selections],
367
367
            [selection.get('id') for selection in parsed_result])
379
379
            response = self.client.get(self.get_uri(boot_source, nodegroup))
380
380
            self.assertEqual(
381
381
                http.client.OK, response.status_code, response.content)
382
 
            parsed_result = json.loads(response.content)
 
382
            parsed_result = json_load_bytes(response.content)
383
383
            self.assertItemsEqual(
384
384
                [selection.id for selection in selections],
385
385
                [selection.get('id') for selection in parsed_result])
404
404
        }
405
405
        response = self.client.post(self.get_uri(boot_source), params)
406
406
        self.assertEqual(http.client.OK, response.status_code)
407
 
        parsed_result = json.loads(response.content)
 
407
        parsed_result = json_load_bytes(response.content)
408
408
 
409
409
        boot_source_selection = BootSourceSelection.objects.get(
410
410
            id=parsed_result['id'])