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()
def setUp(self): super(LiveUserTests, self).setUp() self.user = UserFactory.create(email='*****@*****.**') self.user.save()
def setUpTestData(self): self.user = UserFactory.create()
from apps.users.factories import UserFactory UserFactory.create(username="******", password="******") UserFactory.create(username="******", password="******") UserFactory.create(username="******", password="******")
def test_full_name(self): user = UserFactory.create(first_name='Django', last_name='Reinhardt') self.assertEqual(user.full_name, 'Django Reinhardt')
def user(db, client): _user = UserFactory.create() client.force_login(_user) return _user
def test_email_backend_success(db): user = UserFactory.create() user = authenticate(username=user.email, password="******") assert user == user
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
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
def test_email_backend_fail(db): user = UserFactory.create() user = authenticate(username=user.email, password="******") assert user is None