Skip to content

Commit

Permalink
fix: fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Anas12091101 committed Jul 12, 2024
1 parent dc69f94 commit ab713aa
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions openedx/core/djangoapps/discussions/tests/test_admin.py
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')

0 comments on commit ab713aa

Please sign in to comment.