diff options
author | Stephen Finucane <stephen@that.guru> | 2020-04-17 23:07:27 +0100 |
---|---|---|
committer | Stephen Finucane <stephen@that.guru> | 2020-04-18 00:07:15 +0100 |
commit | 4fd7a739bbed62230d4166509929a35f63f6892e (patch) | |
tree | f07700b0a94a0e1211795304a83fb89bb109f92a /patchwork/tests | |
parent | d08b6c72964898c9997a62e4ab6a721f166a56ca (diff) | |
download | patchwork-4fd7a739bbed62230d4166509929a35f63f6892e.tar patchwork-4fd7a739bbed62230d4166509929a35f63f6892e.tar.gz |
REST: Allow update of bundle without patches
Presently, when updating a patch we assume that patches are provided.
This isn't necessary - you might just want to make it public - and isn't
enforced by the API itself. However, because we make this assumption, we
see a HTTP 500. Resolve the issue and add tests to prevent a regression.
Signed-off-by: Stephen Finucane <stephen@that.guru>
Resolves: #357
Diffstat (limited to 'patchwork/tests')
-rw-r--r-- | patchwork/tests/api/test_bundle.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/patchwork/tests/api/test_bundle.py b/patchwork/tests/api/test_bundle.py index d03f26f..7992448 100644 --- a/patchwork/tests/api/test_bundle.py +++ b/patchwork/tests/api/test_bundle.py @@ -288,9 +288,34 @@ class TestBundleAPI(utils.APITestCase): self.assertEqual(status.HTTP_200_OK, resp.status_code) self.assertEqual(2, len(resp.data['patches'])) self.assertEqual('hello-bundle', resp.data['name']) + self.assertFalse(resp.data['public']) self.assertEqual(1, Bundle.objects.all().count()) self.assertEqual(2, len(Bundle.objects.first().patches.all())) self.assertEqual('hello-bundle', Bundle.objects.first().name) + self.assertFalse(Bundle.objects.first().public) + + def test_update_no_patches(self): + """Validate we handle updating only the name.""" + user, project, patch_a, patch_b = self._test_create_update() + bundle = create_bundle(owner=user, project=project) + + bundle.append_patch(patch_a) + bundle.append_patch(patch_b) + + self.assertEqual(1, Bundle.objects.all().count()) + self.assertEqual(2, len(Bundle.objects.first().patches.all())) + + resp = self.client.patch(self.api_url(bundle.id), { + 'name': 'hello-bundle', 'public': True, + }) + self.assertEqual(status.HTTP_200_OK, resp.status_code) + self.assertEqual(2, len(resp.data['patches'])) + self.assertEqual('hello-bundle', resp.data['name']) + self.assertTrue(resp.data['public']) + self.assertEqual(1, Bundle.objects.all().count()) + self.assertEqual(2, len(Bundle.objects.first().patches.all())) + self.assertEqual('hello-bundle', Bundle.objects.first().name) + self.assertTrue(Bundle.objects.first().public) @utils.store_samples('bundle-delete-not-found') def test_delete_anonymous(self): |