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)
