Skip to content

Commit d117c81

Browse files
committed
feat: add tests
1 parent ce972a3 commit d117c81

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

backend/tests/test_api.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
"""
2+
Tests for the `openedx-ai-extensions` API endpoints.
3+
"""
4+
5+
import pytest
6+
from django.contrib.auth import get_user_model
7+
from django.urls import reverse
8+
from opaque_keys.edx.keys import CourseKey
9+
from rest_framework.test import APIClient
10+
11+
User = get_user_model()
12+
13+
14+
@pytest.fixture
15+
def api_client():
16+
"""
17+
Return a REST framework API client.
18+
"""
19+
return APIClient()
20+
21+
22+
@pytest.fixture
23+
def user():
24+
"""
25+
Create and return a test user.
26+
"""
27+
return User.objects.create_user(
28+
username="testuser", email="[email protected]", password="password123"
29+
)
30+
31+
32+
@pytest.fixture
33+
def staff_user():
34+
"""
35+
Create and return a test staff user.
36+
"""
37+
return User.objects.create_user(
38+
username="staffuser",
39+
40+
password="password123",
41+
is_staff=True,
42+
)
43+
44+
45+
@pytest.fixture
46+
def course_key():
47+
"""
48+
Create and return a test course key.
49+
"""
50+
return CourseKey.from_string("course-v1:edX+DemoX+Demo_Course")
51+
52+
53+
@pytest.mark.django_db
54+
def test_api_urls_are_registered():
55+
"""
56+
Test that the API URLs are properly registered and accessible.
57+
"""
58+
# Test that the v1 workflows URL can be reversed
59+
url = reverse("openedx_ai_extensions:api:v1:ai_pipelines")
60+
assert url == "/openedx-ai-extensions/v1/workflows/"

0 commit comments

Comments
 (0)