Skip to content

Commit

Permalink
Add test for thumbnail filtering by frame
Browse files Browse the repository at this point in the history
Also don't try to generate a url or filename for frames that don't yet have a version_set
  • Loading branch information
Matt Daily committed May 8, 2024
1 parent a0ca3ce commit b8d1169
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions archive/frames/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ def get_header_dict(self):
def as_dict(self):
ret_dict = model_to_dict(self, exclude=('related_frames', 'area'))
ret_dict['version_set'] = [v.as_dict() for v in self.version_set.all()]
ret_dict['url'] = self.url
ret_dict['filename'] = self.filename
ret_dict['url'] = self.url if self.version_set.exists() else None
ret_dict['filename'] = self.filename if self.version_set.exists() else None
# TODO: Remove these old model field names once users have migrated their code
ret_dict['DATE_OBS'] = ret_dict['observation_date']
ret_dict['DAY_OBS'] = ret_dict['observation_day']
Expand Down
8 changes: 3 additions & 5 deletions archive/frames/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,11 +798,9 @@ def test_get_thumbnail_list(self):
self.assertEqual(len(response.json()), 5)
self.assertContains(response, self.thumbnails[0].filename)

def test_get_thumbnail_list_filtered(self):
response = self.client.get(reverse('thumbnail-list') + '?filename=small')
self.assertEqual(len(response.json()), 5)
self.assertContains(response, self.thumbnails[0].filename)

def test_get_thumbnail_list_filtered_by_frame_attribute(self):
response = self.client.get(reverse('thumbnail-list') + '?proposal_id=' + self.thumbnails[0].frame.proposal_id)
self.assertContains(response, self.thumbnails[0].frame.id)


class TestThumbnailPost(ReplicationTestCase):
Expand Down

0 comments on commit b8d1169

Please sign in to comment.