Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/api/views/test_snapshot.py
Show First 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | def test_api_snapshot_paginated(self, snapshot): | ||||
url = reverse('api-snapshot', | url = reverse('api-snapshot', | ||||
url_args={'snapshot_id': snapshot}) | url_args={'snapshot_id': snapshot}) | ||||
rv = self.client.get(url) | rv = self.client.get(url) | ||||
self.assertEqual(rv.status_code, 200) | self.assertEqual(rv.status_code, 200) | ||||
self.assertEqual(rv['Content-Type'], 'application/json') | self.assertEqual(rv['Content-Type'], 'application/json') | ||||
self.assertEqual(rv.data, whole_snapshot) | self.assertEqual(rv.data, whole_snapshot) | ||||
@given(snapshot()) | def _api_snapshot_filtered_test(self, snapshot): | ||||
def test_api_snapshot_filtered(self, snapshot): | |||||
snapshot_branches = [] | snapshot_branches = [] | ||||
for k, v in sorted(self.snapshot_get(snapshot)['branches'].items()): | for k, v in sorted(self.snapshot_get(snapshot)['branches'].items()): | ||||
snapshot_branches.append({ | snapshot_branches.append({ | ||||
'name': k, | 'name': k, | ||||
'target_type': v['target_type'], | 'target_type': v['target_type'], | ||||
'target': v['target'] | 'target': v['target'] | ||||
Show All 9 Lines | def _api_snapshot_filtered_test(self, snapshot): | ||||
expected_data = self.snapshot_get_branches( | expected_data = self.snapshot_get_branches( | ||||
snapshot, target_types=target_type) | snapshot, target_types=target_type) | ||||
expected_data = self._enrich_snapshot(expected_data) | expected_data = self._enrich_snapshot(expected_data) | ||||
self.assertEqual(rv.status_code, 200) | self.assertEqual(rv.status_code, 200) | ||||
self.assertEqual(rv['Content-Type'], 'application/json') | self.assertEqual(rv['Content-Type'], 'application/json') | ||||
self.assertEqual(rv.data, expected_data) | self.assertEqual(rv.data, expected_data) | ||||
@given(snapshot()) | |||||
def test_api_snapshot_filtered(self, snapshot): | |||||
self._api_snapshot_filtered_test(snapshot) | |||||
@given(snapshot()) | |||||
def test_api_snapshot_filtered_with_uppercase_sha1(self, snapshot): | |||||
self._api_snapshot_filtered_test(snapshot.upper()) | |||||
anlambert: same here | |||||
@given(unknown_snapshot()) | @given(unknown_snapshot()) | ||||
def test_api_snapshot_errors(self, unknown_snapshot): | def test_api_snapshot_errors(self, unknown_snapshot): | ||||
url = reverse('api-snapshot', | url = reverse('api-snapshot', | ||||
url_args={'snapshot_id': '63ce369'}) | url_args={'snapshot_id': '63ce369'}) | ||||
rv = self.client.get(url) | rv = self.client.get(url) | ||||
self.assertEqual(rv.status_code, 400) | self.assertEqual(rv.status_code, 400) | ||||
Show All 36 Lines |
same here