def test_profile_api_access(self): api_access = APIAccess() api_access.user = self.user api_access.save() response = self.client.get(reverse('shortener_app:profile')) self.assertTemplateUsed(response, 'shortener_app/profile.html') self.assertContains(response, api_access.apikey) self.assertEquals(response.status_code, 200)
def test_delete_api_access(self): api_access = APIAccess() api_access.user = self.user api_access.save() response = self.client.get( reverse('shortener_app:delete_api_access', kwargs={'api_access_id': api_access.id})) self.assertEqual(api_access.user, self.user) self.assertRedirects(response, reverse('shortener_app:profile'))
def create_api_access(request): api_access = APIAccess() api_access.user = request.user api_access.save() return redirect(reverse('shortener_app:profile'))