Olivier DOSSMANN
5cbef15a13
* le fait d'avoir joué ou non au jeu * de le vouloir dans sa liste de souhaits * de donner l'état de progression dans le jeu parmi : * inachevé * globalement terminé * complètement terminé * maîtrisé
29 lines
950 B
Python
29 lines
950 B
Python
from django.test import TestCase
|
|
from games.models import Console, Game
|
|
|
|
|
|
class GameTest(TestCase):
|
|
"""
|
|
Game Model
|
|
"""
|
|
|
|
def setUp(self):
|
|
self.console = Console.objects.create(name='BestConsole4Ever')
|
|
Game.objects.create(
|
|
name='Deponia', playing=False, console=self.console)
|
|
Game.objects.create(
|
|
name='Aladdin', playing=True, console=self.console)
|
|
Game.objects.create(
|
|
name='Persona 5', playing=True, console=self.console)
|
|
|
|
|
|
def test_game_are_sorted_by_playing_and_name(self):
|
|
"""
|
|
Games should be sorted by playing state (playing should be True first)
|
|
then by name in alphabetical order.
|
|
"""
|
|
games = list(Game.objects.all().values_list('name', flat=True))
|
|
sorted_games = list(Game.objects.all().order_by(
|
|
'-playing', 'name').values_list('name', flat=True))
|
|
self.assertEqual(games, sorted_games)
|