Stars y Opinion se incluyeron en ListItem

Esto porque al final eran relaciones 1 a 1 y era preferible que
estuvieran incluidos en un solo modelo, de esta forma hay menos llamadas
a la base de datos desde la api y una api mas simple de realizar y
llamar

Realmente el unico modelo que quedo "extraño" es el de opinion helpfull
que tendra que pasar a ser ... listitemhelpful? pero el nombre
opinionhelpful es mas coherente
This commit is contained in:
Daniel Cortes
2020-07-14 10:31:32 -04:00
parent 1a36bec50a
commit ce76f76dfb
5 changed files with 52 additions and 42 deletions

View File

@@ -68,7 +68,9 @@ class TestList(TestCase):
to_add = {
'entity': 'b',
'entity_type': 'artist',
'tags': ['1', '2']
'tags': ['1', '2'],
'stars': 1,
'opinion': 'oh no'
}
response = self.client.post('/api/lists/list/1/', json.dumps(to_add),
@@ -133,6 +135,35 @@ class TestList(TestCase):
self.assertEqual(list_item.entity_id, to_add['entity'])
self.assertEqual(list_item.tags.count(), len(to_add['tags']))
def test_add_to_list_non_valid_stars(self):
to_add = {
'entity': 'b',
'entity_type': 'artist',
'tags': ['1', '2'],
'stars': -1,
'opinion': 'oh no'
}
response = self.client.post('/api/lists/list/1/', json.dumps(to_add),
content_type='application/json',
HTTP_AUTHORIZATION=self._user_bearer_token())
self.assertEqual(response.status_code, 400)
to_add = {
'entity': 'b',
'entity_type': 'artist',
'tags': ['1', '2'],
'stars': 6,
'opinion': 'oh no'
}
response = self.client.post('/api/lists/list/1/', json.dumps(to_add),
content_type='application/json',
HTTP_AUTHORIZATION=self._user_bearer_token())
self.assertEqual(response.status_code, 400)
def test_delete_list_item_is_protected(self):
response = self.client.delete('/api/lists/list/1/1/')
self.assertEqual(response.status_code, 403)