Correction de bug : les jeux avec l'état "created" généraient 2 timelines
This commit is contained in:
parent
1845ae9eac
commit
95d8b30c3c
@ -1,5 +1,6 @@
|
||||
Current version (0.2) :
|
||||
|
||||
- Bug corrigé : Génération de 2 timelines si on crée un jeu avec l'état "created"
|
||||
- Renommage des consoles en « plateformes »
|
||||
- Activation des requêtes CORS pour permettre à une autre application d'accéder à l'API
|
||||
- MàJ vers Django 1.11.5
|
||||
|
@ -18,5 +18,6 @@ def game_saved(sender, instance, created, raw, using, update_fields,
|
||||
new_entry = dict(entry)
|
||||
new_entry.update({'status': instance.CREATED})
|
||||
Timeline.objects.create(**new_entry)
|
||||
# Add new timeline entry
|
||||
Timeline.objects.create(**entry)
|
||||
# Add new timeline entry ONLY if status is difference from CREATED one
|
||||
if instance.status != instance.CREATED:
|
||||
Timeline.objects.create(**entry)
|
||||
|
34
collection/games/tests/test_timeline.py
Normal file
34
collection/games/tests/test_timeline.py
Normal file
@ -0,0 +1,34 @@
|
||||
from django.test import TestCase
|
||||
from games.models import Game, Platform, Timeline
|
||||
|
||||
|
||||
class TimelineTest(TestCase):
|
||||
"""
|
||||
Timeline Model
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
cls.console = Platform.objects.create(name='GP2X')
|
||||
|
||||
|
||||
def test_game_with_status_created_gives_one_timeline(self):
|
||||
"""
|
||||
Game with status "created" should only generate ONE status. Not more.
|
||||
"""
|
||||
# Games creation should generate timelines.
|
||||
game1 = Game.objects.create(
|
||||
name='Vektronizor',
|
||||
collection=self.console,
|
||||
status='beaten')
|
||||
game2 = Game.objects.create(
|
||||
name='Pomperman',
|
||||
collection=self.console,
|
||||
status='created')
|
||||
|
||||
game1_timeline = Timeline.objects.filter(
|
||||
item=game1)
|
||||
game2_timeline = Timeline.objects.filter(
|
||||
item=game2)
|
||||
self.assertEqual(game1_timeline.count(), 2)
|
||||
self.assertEqual(game2_timeline.count(), 1)
|
Loading…
Reference in New Issue
Block a user