Olivier DOSSMANN
242b0edff0
* utilisation de classes abstraites Django : Item et Collection * héritage de ces classes pour Game et Console * création d'un objet Timeline contenant le changement d'état des jeux * affichage de la Timeline sur l'interface Admin
29 lines
959 B
Python
29 lines
959 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, collection=self.console)
|
|
Game.objects.create(
|
|
name='Aladdin', playing=True, collection=self.console)
|
|
Game.objects.create(
|
|
name='Persona 5', playing=True, collection=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)
|