[PATCH v6 06/10] REST: Add Patches to the API
andy.doan at linaro.org
Tue Jun 21 08:04:13 AEST 2016
On 06/19/2016 01:19 PM, Finucane, Stephen wrote:
> On 16 Jun 16:13, Andy Doan wrote:
>> This exposes patches via the REST API.
>> Security Constraints:
>> * Anyone (logged in or not) can read all objects.
>> * No one can create/delete objects.
>> * Project maintainers are allowed to update (ie "patch"
>> NOTE: Patch.save was overridden incorrectly and had to be
>> fixed to work with DRF.
>> Signed-off-by: Andy Doan <andy.doan at linaro.org>
> There's an issue with one of the tests below when I run the entire
> test suite as one...
>> + def test_detail_tags(self):
>> + patches = create_patches()
>> + patches.content = 'Reviewed-by: Test User <test at example.com>\n'
>> + patches.save()
>> + patches.refresh_tag_counts()
> ^ I don't think this is needed (it's called in 'save'), but more
>> + resp = self.client.get(self.api_url(patches.id))
>> + tags = resp.data['tags']
>> + self.assertEqual(1, len(tags))
> The above assertion fails when I run the entire test suite, like so:
> tox -e py27
> This doesn't seem to be storing tags correctly.
> FAIL: test_detail_tags (patchwork.tests.test_rest_api.TestPatchAPI)
> Traceback (most recent call last):
> File "/home/sfinucan/innovation/patchwork/patchwork/patchwork/tests/test_rest_api.py", line 274, in test_detail_tags
> self.assertEqual(1, len(tags))
> AssertionError: 1 != 0
> I'm guessing it's due to some side effect, but I haven't figured out
> what's causing this yet. Mind taking a look?
It seems like the "fixtures" attribute for the test:
fixtures = ['default_states', 'default_tags']
is getting ignored under certain circumstances. ie - I added some
debugging and see no configured tags for the project when I run the
full suite, but see the expected ones when I just run test_rest_api. I
haven't used fixtures in django before, but will poke around.
More information about the Patchwork