def test_update_built_in_addons_no_browser_version(self, api_client): addon = AddonFactory() res = api_client.post('/api/v1/addon_group/update_built_in/', {'addons': [addon.id]}) assert res.status_code == 400
def test_it_works(self): addon = AddonFactory() group = AddonGroupFactory() group.addons.add(addon) serializer = AddonGroupSerializer(group) assert serializer.data == { 'id': group.id, 'browser_version': '%s' % group.browser_version, 'addons': [AddonSerializer(addon).data], 'built_in_addons': [], 'qa_addons': [], 'shipped_addons': [], 'qa_sync_diff': { 'added': [addon.id], 'downgraded': [], 'removed': [], 'upgraded': [] }, 'qa_synced': False, 'shipped_sync_diff': { 'added': [addon.id], 'downgraded': [], 'removed': [], 'upgraded': [] }, 'shipped_synced': False }
def test_it_can_delete_addons(self, api_client): addon = AddonFactory() res = api_client.delete('/api/v1/addon/%s/' % addon.id) assert res.status_code == 204 addons = Addon.objects.all() assert addons.count() == 0
def test_it_serves_groups(self, api_client): group = AddonGroupFactory() addon = AddonFactory() group.addons.add(addon) res = api_client.get('/api/v1/addon_group/') assert res.status_code == 200 assert res.data[0]['addons'][0] == addon.id
def test_groups(self, api_client): addon = AddonFactory() group = AddonGroupFactory() group.addons.add(addon) res = api_client.get('/api/v1/addon/%s/groups/' % addon.id) assert res.status_code == 200 assert res.data[0]['id'] == group.id
def test_it_can_add_addons_to_group(self, api_client): group = AddonGroupFactory() a1 = AddonFactory() res = api_client.post('/api/v1/addon_group/%s/add_addons/' % group.id, {'addon_ids': [a1.pk]}) assert res.status_code == 204 assert group.addons.count() == 1 a2 = AddonFactory() a3 = AddonFactory() res = api_client.post('/api/v1/addon_group/%s/add_addons/' % group.id, {'addon_ids': [a2.pk, a3.pk]}) assert res.status_code == 204 assert group.addons.count() == 3
def test_it_can_edit_addons(self, api_client): addon = AddonFactory(name='unchanged') res = api_client.patch('/api/v1/addon/%s/' % addon.id, {'name': 'changed'}) assert res.status_code == 200 addon = Addon.objects.first() assert addon.name == 'changed'
def test_removing_an_addon_that_doesnt_exist(self, api_client): group = AddonGroupFactory() addon = AddonFactory() group.addons.add(addon) res = api_client.post('/api/v1/addon_group/%s/add_addons/' % group.id, {'addon_ids': [addon.id + 1]}) assert res.status_code == 400 assert group.addons.count() == 1
def test_it_works(self): addon = AddonFactory() serializer = AddonSerializer(addon) assert serializer.data == { 'id': addon.id, 'name': addon.name, 'version': '%s' % addon.version, 'ftp_url': addon.ftp_url }
def test_it_can_remove_addons_from_group(self, api_client): group = AddonGroupFactory() group.addons.add(AddonFactory()) group.addons.add(AddonFactory()) group.addons.add(AddonFactory()) res = api_client.post( '/api/v1/addon_group/%s/remove_addons/' % group.id, {'addon_ids': [group.addons.first().pk]}) assert res.status_code == 204 assert group.addons.count() == 2 res = api_client.post( '/api/v1/addon_group/%s/remove_addons/' % group.id, {'addon_ids': [group.addons.first().pk, group.addons.last().pk]}) assert res.status_code == 204 assert group.addons.count() == 0
def test_release_data(self): addon = AddonFactory() addon_group = AddonGroupFactory(addons=[addon]) assert addon_group.release_data == { 'addons': { addon.name: addon.release_data }, 'hashFunction': 'sha512', 'name': 'SystemAddons-ff{}-{}-{}'.format(addon_group.browser_version, addon.name, addon.version), 'schema_version': 5000 }
def test_it_works(self): addon = AddonFactory() serializer = AddonSerializer(addon) assert serializer.data == { 'id': addon.id, 'name': addon.name, 'version': '%s' % addon.version, 'ftp_url': addon.ftp_url, 'xpi_hash': FAKE_XPI_HASH, 'xpi_filesize': FAKE_XPI_FILESIZE, }
def test_update_built_in_addons_new_group(self, api_client): addon = AddonFactory() res = api_client.post( '/api/v1/addon_group/update_built_in/', { 'browser_version': '1.0.0', 'addons': [{ 'name': addon.name, 'version': addon.version, }] }) assert res.status_code == 204 assert AddonGroup.objects.count() == 1
def test_it_works(self): addon = AddonFactory() group = AddonGroupFactory() group.addons.add(addon) serializer = AddonGroupSerializer(group) assert serializer.data == { 'id': group.id, 'browser_version': '%s' % group.browser_version, 'addons': [AddonSerializer(addon).data], 'built_in_addons': [], 'qa_addons': [], 'shipped_addons': [], }
def test_update_built_in_addons_existing_addon(self, api_client): group = AddonGroupFactory() addon = AddonFactory() res = api_client.post( '/api/v1/addon_group/update_built_in/', { 'browser_version': group.browser_version, 'addons': [{ 'name': addon.name, 'version': addon.version, }] }) assert res.status_code == 204 assert group.built_in_addons.count() == 1 assert Addon.objects.count() == 1
def test_update_built_in_addons_invalid_addons(self, api_client): group = AddonGroupFactory() addon = AddonFactory() group.built_in_addons.add(addon) res = api_client.post('/api/v1/addon_group/update_built_in/', { 'browser_version': group.browser_version, }) assert res.status_code == 400 assert group.built_in_addons.count() == 1 res = api_client.post('/api/v1/addon_group/update_built_in/', { 'browser_version': group.browser_version, 'addons': addon.id }) assert res.status_code == 400 assert group.built_in_addons.count() == 1
def test_release_data(self): addon = AddonFactory() assert addon.release_data == { 'platforms': { 'default': { 'fileUrl': addon.ftp_url, 'filesize': FAKE_XPI_FILESIZE, 'hashValue': FAKE_XPI_HASH }, 'Darwin_x86-gcc3-u-i386-x86_64': {'alias': 'default'}, 'Darwin_x86_64-gcc3-u-i386-x86_64': {'alias': 'default'}, 'Linux_x86-gcc3': {'alias': 'default'}, 'Linux_x86_64-gcc3': {'alias': 'default'}, 'WINNT_x86-msvc': {'alias': 'default'}, 'WINNT_x86-msvc-x64': {'alias': 'default'}, 'WINNT_x86-msvc-x86': {'alias': 'default'}, 'WINNT_x86_64-msvc': {'alias': 'default'}, 'WINNT_x86_64-msvc-x64': {'alias': 'default'}, } }
def test_it_works(self): addon = AddonFactory() group = AddonGroupFactory() group.addons.add(addon) serializer = AddonGroupSerializer(group) assert serializer.data == { 'id': group.id, 'channel_name': group.channel_name, 'browser_version': '%s' % group.browser_version, 'addons': [{ 'id': addon.id, 'name': addon.name, 'version': '%s' % addon.version, 'ftp_url': addon.ftp_url }] }
def test_it_serves_addons(self, api_client): addon = AddonFactory() res = api_client.get('/api/v1/addon/') assert res.status_code == 200 assert res.data[0]['name'] == addon.name