-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restore and fix test for spa-only view
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from django.conf import settings | ||
from django.test import override_settings, tag | ||
|
||
from rest_framework import status | ||
from rest_framework.test import APIClient, APITestCase | ||
|
||
from argus.auth.factories import AdminUserFactory, BaseUserFactory | ||
from argus.util.testing import disconnect_signals, connect_signals | ||
|
||
|
||
@tag("API", "integration", "spa") | ||
@override_settings( | ||
ROOT_URLCONF="argus.spa.root_urls", | ||
) | ||
class SpaViewTests(APITestCase): | ||
def setUp(self): | ||
disconnect_signals() | ||
self.user = BaseUserFactory(username="user") | ||
|
||
self.rest_client = APIClient() | ||
self.rest_client.force_authenticate(user=self.user) | ||
|
||
def teardown(self): | ||
connect_signals() | ||
|
||
@override_settings( | ||
AUTHENTICATION_BACKENDS=[ | ||
"django.contrib.auth.backends.RemoteUserBackend", | ||
"django.contrib.auth.backends.ModelBackend", | ||
], | ||
) | ||
def test_can_get_login_methods(self): | ||
response = self.rest_client.get(path="/login-methods/") | ||
self.assertEqual(response.status_code, status.HTTP_200_OK) | ||
self.assertEqual( | ||
response.data, | ||
[ | ||
{"type": "username_password", "url": "http://testserver/api/v1/token-auth/", "name": "user_pw"}, | ||
], | ||
) |