Skip to content

Commit

Permalink
tests: refactor test_views, new SessionAndAPIAccessViewsTestCase
Browse files Browse the repository at this point in the history
  • Loading branch information
eshaan7 committed Sep 21, 2021
1 parent b1d296c commit dae5aaf
Show file tree
Hide file tree
Showing 2 changed files with 303 additions and 71 deletions.
19 changes: 19 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,22 @@ def setUp(self):
}

self.client_names = ["web", "mobile", "cli"]

def _create_clients(self) -> None:
Client.objects.all().delete()
self.assertEqual(Client.objects.count(), 0)
for name in self.client_names:
Client.objects.create(name=name)
self.assertEqual(Client.objects.count(), len(self.client_names))

def _create_authtoken(self, user=None, client_name=None) -> AuthToken:
if not user:
user = self.user
if not client_name:
client_name = "customtestcase_client"
client, _ = Client.objects.get_or_create(name=client_name)
try:
token = AuthToken.objects.get(user=user, client=client)
except AuthToken.DoesNotExist:
token = AuthToken.objects.create(user=user, client=client)
return token
Loading

0 comments on commit dae5aaf

Please sign in to comment.