Esempio n. 1
0
    def test_budgets_list(self):
        user_one_budget = UserFactory.create()
        user_two_budgets = UserFactory.create()

        budget = BudgetFactory.create(owner=user_one_budget)
        budget.members.add(user_two_budgets)
        BudgetFactory.create(owner=user_two_budgets)

        keys = ["id", "name", "owner", "is_owner"]

        response = self.client.get(reverse(self.LIST_USER_BUDGETS_REVERSE))
        self.assertEquals(response.status_code, status.HTTP_401_UNAUTHORIZED)

        self.client.login(username=user_one_budget.username,
                          password="******")
        response = self.client.get(reverse(self.LIST_USER_BUDGETS_REVERSE))

        self.assertEquals(response.status_code, status.HTTP_200_OK)

        results = response.data["results"]

        self.assertEquals(len(results), 1)
        for key in keys:
            self.assertTrue(key in results[0])

        self.client.logout()

        self.client.login(username=user_two_budgets.username,
                          password="******")
        response = self.client.get(reverse(self.LIST_USER_BUDGETS_REVERSE))

        self.assertEquals(response.status_code, status.HTTP_200_OK)

        results = response.data["results"]

        self.assertEquals(len(results), 2)

        self.client.logout()
Esempio n. 2
0
 def setUp(self):
     super(LiveUserTests, self).setUp()
     self.user = UserFactory.create(email='*****@*****.**')
     self.user.save()
Esempio n. 3
0
 def setUpTestData(self):
     self.user = UserFactory.create()
Esempio n. 4
0
from apps.users.factories import UserFactory

UserFactory.create(username="******", password="******")
UserFactory.create(username="******", password="******")
UserFactory.create(username="******", password="******")
Esempio n. 5
0
 def test_full_name(self):
     user = UserFactory.create(first_name='Django', last_name='Reinhardt')
     self.assertEqual(user.full_name, 'Django Reinhardt')
Esempio n. 6
0
def user(db, client):
    _user = UserFactory.create()
    client.force_login(_user)
    return _user
Esempio n. 7
0
def test_email_backend_success(db):
    user = UserFactory.create()
    user = authenticate(username=user.email, password="******")
    assert user == user
Esempio n. 8
0
def test_login_fail(db, client):
    user = UserFactory.create()
    data = {"username": user.email, "password": "******"}
    response = client.post("/accounts/login/", data)
    assert response.status_code == 200
Esempio n. 9
0
def test_login_success(db, client):
    user = UserFactory.create()
    data = {"username": user.email, "password": "******"}
    response = client.post("/accounts/login/", data)
    assertRedirects(response, "/")
    assert get_user(client) == user
Esempio n. 10
0
def test_email_backend_fail(db):
    user = UserFactory.create()
    user = authenticate(username=user.email, password="******")
    assert user is None