def test_commcare_user_flag(self): self.assertFalse(WebUser().is_commcare_user()) self.assertFalse(CouchUser.wrap(WebUser().to_json()).is_commcare_user()) self.assertTrue(CommCareUser().is_commcare_user()) self.assertTrue(CouchUser.wrap(CommCareUser().to_json()).is_commcare_user()) with self.assertRaises(NotImplementedError): CouchUser().is_commcare_user()
def create_request(cls, request_url, username, password): # Initialize request request = Client().get(request_url).wsgi_request # Create user request.user = get_user_model().objects.create_user(username=username, email=username, password=password) # Create couch user request.couch_user = CouchUser() # Login assert Client().login(username=username, password=password) # Activate middleware OTPMiddleware().process_request(request) return request
def create_request(cls, request_url): request = RequestFactory().get(request_url) request.couch_user = CouchUser() return request
def test_normal_user(): user = CouchUser(username="******") assert_false(is_superuser_or_contractor(user))
def test_superuser(): user = CouchUser(username="******", is_superuser=True) assert_true(is_superuser_or_contractor(user))
def test_contractor(): user = CouchUser(username="******") with flag_enabled('IS_CONTRACTOR'): assert_true(is_superuser_or_contractor(user))