def test_authenticate_user_internal(self): # No need to set headers since the Authorization Token was added in setUp response = self.post(self.authenticate_user_internal_url, None) assert response.status_code == 200 data = json.loads(response.content) assert data['success'] == True assert data['username'] == user().email
def setUp(self): super(BaseAPITestCase, self).setUp() self.channel = testdata.channel() self.user = testdata.user() token, _new = Token.objects.get_or_create(user=self.user) self.header = {"Authorization": "Token {0}".format(token)} self.client = APIClient() self.client.force_authenticate(self.user) self.channel.main_tree.refresh_from_db()
def setUp(self): super(BaseAPITestCase, self).setUp() self.channel = testdata.channel() self.user = testdata.user() self.channel.editors.add(self.user) self.token, _new = Token.objects.get_or_create(user=self.user) self.client = APIClient() self.client.force_authenticate( self.user) # This will skip all authentication checks self.channel.main_tree.refresh_from_db()
def test_user_with_info(self): """ Test that correct user data is included in the get_user_stats call. """ uses_stats = {} sources_stats = {} country_stats = {} countries = get_sorted_countries() for rando in range(10): email = '{}@{}.com'.format(random_string(), random_string()) test_user = user(email) info = {} info['uses'] = add_random_choices(USAGES, uses_stats) info['heard_from'] = add_random_choices(SOURCES, sources_stats) info['locations'] = add_random_choices(countries, country_stats) test_user.information = info test_user.save() stats = get_user_stats() assert stats['count'] == 11 assert stats['heard_from'] == sources_stats assert stats['locations'] == country_stats assert stats['uses'] == uses_stats
def setUp(self): super(BaseTestCase, self).setUp() self.channel = testdata.channel() self.user = testdata.user() self.channel.editors.add(self.user) self.channel.main_tree.refresh_from_db()
def setUp(self): super(BaseTestCase, self).setUp() self.channel = testdata.channel() self.user = testdata.user() self.channel.main_tree.refresh_from_db()