API Game : ajout des champs status, unplayed, playing et wish
This commit is contained in:
parent
8dec41073f
commit
1845ae9eac
5
TODO
5
TODO
@ -1,7 +1,5 @@
|
||||
# À faire
|
||||
|
||||
* Ajouter le champ "status" des jeux dans l'API
|
||||
* API jeux : ajouter wish, playing et unplayed
|
||||
* Ajouter des help_text à tous les champs + classes enfants. Les traduire.
|
||||
* étudier la possibilité à l'utilisateur, via des variables d'environnement, de configurer un email, une autre BDD, etc.
|
||||
|
||||
@ -18,8 +16,9 @@
|
||||
|
||||
## Tests
|
||||
|
||||
* Sur Console
|
||||
* Sur Platform
|
||||
* Sur Game
|
||||
* API : sur Game, pour les champs wish, unplayed, playing et status
|
||||
* travis.yml to launch test
|
||||
* Selenium pour vérifier :
|
||||
* que Nouveau n'apparaisse pas dans la liste des états possibles
|
||||
|
@ -2,13 +2,21 @@ from games.models import Game, Platform
|
||||
from rest_framework import serializers
|
||||
|
||||
|
||||
class GameSerializer(serializers.HyperlinkedModelSerializer):
|
||||
class Meta:
|
||||
model = Game
|
||||
fields = (
|
||||
'collection',
|
||||
'name',
|
||||
'note',
|
||||
'playing',
|
||||
'status',
|
||||
'unplayed',
|
||||
'wish',
|
||||
)
|
||||
|
||||
|
||||
class PlatformSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Platform
|
||||
fields = ('name',)
|
||||
|
||||
|
||||
class GameSerializer(serializers.HyperlinkedModelSerializer):
|
||||
class Meta:
|
||||
model = Game
|
||||
fields = ('name', 'collection')
|
||||
|
@ -98,3 +98,17 @@ class GameTest(APITestCase):
|
||||
games = [x.get('name') for x in json.loads(response.content)]
|
||||
self.assertEqual(games, sorted_games)
|
||||
|
||||
def test_not_allowed_status(self):
|
||||
"""
|
||||
Check that we cannot insert a not allowed status in a Game
|
||||
"""
|
||||
console = Platform.objects.create(name='BestPlatform4Ever')
|
||||
url = reverse('game-list')
|
||||
data = {
|
||||
'name': 'Vilebrequin',
|
||||
'status': 'wrecked',
|
||||
}
|
||||
self.client.force_authenticate(user=self.superuser)
|
||||
response = self.client.post(url, data, format='json')
|
||||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
|
||||
self.assertEqual(Game.objects.count(), 0)
|
||||
|
Loading…
Reference in New Issue
Block a user