def test_PUT_updates_boot_source_selection(self): self.become_admin() boot_source_selection = factory.make_BootSourceSelection() new_os = factory.make_name('os') new_release = factory.make_name('release') boot_source_caches = factory.make_many_BootSourceCaches( 2, boot_source=boot_source_selection.boot_source, os=new_os, release=new_release) new_values = { 'os': new_os, 'release': new_release, 'arches': [boot_source_caches[0].arch, boot_source_caches[1].arch], 'subarches': [boot_source_caches[0].subarch, boot_source_caches[1].subarch], 'labels': [boot_source_caches[0].label], } response = self.client.put( get_boot_source_selection_uri(boot_source_selection), new_values) self.assertEqual(http.client.OK, response.status_code, response.content) boot_source_selection = reload_object(boot_source_selection) self.assertAttributes(boot_source_selection, new_values)
def make_some_caches(self, boot_source, os, release): # Make a few BootSourceCache records that the following tests can use # to validate against when using BootSourceSelectionForm. return factory.make_many_BootSourceCaches(3, boot_source=boot_source, os=os, release=release)
def test_POST_creates_boot_source_selection(self): self.become_admin() boot_source = factory.make_BootSource() new_release = factory.make_name("release") boot_source_caches = factory.make_many_BootSourceCaches( 2, boot_source=boot_source, release=new_release) params = { "release": new_release, "arches": [boot_source_caches[0].arch, boot_source_caches[1].arch], "subarches": [ boot_source_caches[0].subarch, boot_source_caches[1].subarch, ], "labels": [boot_source_caches[0].label], } response = self.client.post( reverse("boot_source_selections_handler", args=[boot_source.id]), params, ) self.assertEqual(http.client.OK, response.status_code) parsed_result = json_load_bytes(response.content) boot_source_selection = BootSourceSelection.objects.get( id=parsed_result["id"]) self.assertAttributes(boot_source_selection, params)