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:phase-list')

        game = GameFactory()
        obj = PhaseFactory.build(game=game)
        payload = serializers.PhaseSerializer(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(PhaseTestCase, self).setUp()

        self.phase = PhaseFactory()
 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')