    def test_login(self):
        login_code = LoginCode.objects.create(user=self.user, code='foobar', next='/private/')

        response = self.client.post('/accounts-rest/login/code/', {
            'code': login_code.code,
        })

        self.assertEqual(response.status_code, 200)
        self.assertFalse(LoginCode.objects.filter(pk=login_code.pk).exists())

        token = Token.objects.filter(user=self.user).first()

        self.assertIsNotNone(token)
        self.assertEqual(response.data, {
            'key': token.key,
            'next': '/private/',
        })