-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dc69f94
commit ab713aa
Showing
1 changed file
with
14 additions
and
12 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 |
---|---|---|
@@ -1,30 +1,32 @@ | ||
""" | ||
Tests that verify that the admin view loads. | ||
""" | ||
from django.test import TestCase | ||
from django.urls import reverse | ||
from django.contrib.auth.models import User | ||
from django.test import Client | ||
from openedx.core.djangoapps.discussions.models import DiscussionsConfiguration | ||
|
||
from openedx.core.djangoapps.discussions.models import DiscussionsConfiguration, Provider | ||
from common.djangoapps.student.tests.factories import UserFactory | ||
|
||
class DiscussionsConfigurationAdminTest(TestCase): | ||
""" | ||
Tests for discussion config admin | ||
""" | ||
def setUp(self): | ||
super().setUp() | ||
self.superuser = User.objects.create_superuser('admin', '[email protected]', 'password') | ||
self.superuser = UserFactory(is_staff=True, is_superuser=True) | ||
self.client = Client() | ||
self.client.login(username='admin', password='password') | ||
self.client.login(username=self.superuser.username, password="Password1234") | ||
|
||
self.discussion_config = DiscussionsConfiguration.objects.create( | ||
context_key='course-v1:MITx+Discussion.Test+06_25_2024', | ||
provider_type='openedx', | ||
) | ||
|
||
def test_change_view(self): | ||
""" | ||
Test that the change view fn processes the context_key correctly and returns a successful response. | ||
Test that the DiscussionAdmin's change_view processes the context_key correctly and returns a successful response. | ||
""" | ||
url = reverse('admin:discussions_discussionsconfiguration_change', args=[self.discussion_config.context_key]) | ||
discussion_config = DiscussionsConfiguration.objects.create( | ||
context_key='course-v1:test+test+06_25_2024', | ||
provider_type=Provider.OPEN_EDX, | ||
) | ||
url = reverse('admin:discussions_discussionsconfiguration_change', args=[discussion_config.context_key]) | ||
response = self.client.get(url) | ||
self.assertEqual(response.status_code, 200) | ||
self.assertContains(response, 'course-v1:MITx+Discussion.Test+06_25_2024') | ||
self.assertContains(response, 'course-v1:test+test+06_25_2024') |