def test_active_inactive(self):
        g1 = GameFactory()
        g2 = GameFactory(active=False)

        qs1 = Game.objects.active()
        qs2 = Game.objects.inactive()

        self.assertEqual(len(qs1), 1)
        self.assertEqual(len(qs2), 1)

        self.assertEqual(qs1[0], g1)
        self.assertEqual(qs2[0], g2)
    def test_simpl_model(self):
        user = UserFactory()
        game = GameFactory(slug="blackjack")
        log_entry = LogEntry()

        self.assertTrue(events.simpl_model(user))
        self.assertTrue(events.simpl_model(game))
        self.assertFalse(events.simpl_model(log_entry))
    def test_event_namespace(self):
        game = GameFactory(slug="blackjack")
        phase = PhaseFactory(game=game)

        self.assertEqual(events.event_namespace(game, 'created'),
                         'blackjack.game.created')
        self.assertEqual(events.event_namespace(phase, 'changed'),
                         'blackjack.phase.changed')
    def test_create(self):
        url = reverse('simpl_api:run-list')

        game = GameFactory()
        obj = RunFactory.build(game=game)
        payload = serializers.RunSerializer(obj).data

        # Does this api work without auth?
        response = self.client.post(url, payload, format='json')
        self.assertEqual(response.status_code, 401)

        # Does this api work with auth?
        with self.login(self.user):
            response = self.client.post(url, payload, format='json')
            self.assertEqual(response.status_code, 201)
            self.assertNotEqual(len(response.data), 0)
    def setUp(self):
        super(GameTestCase, self).setUp()

        self.game = GameFactory()
 def test_get_model_name(self):
     game = GameFactory(slug="blackjack")
     phase = PhaseFactory(game=game)
     self.assertEqual(events.get_model_name(game), 'game')
     self.assertEqual(events.get_model_name(phase), 'phase')
 def test_game_save(self):
     g = GameFactory(name="Foo", slug=None)
     assert str(g) == "Foo"
     assert g.slug == "foo"