Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: duplication in URL routes #163

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: duplication in URL routes
  • Loading branch information
shadinaif committed Dec 9, 2024

Verified

This commit was signed with the committer’s verified signature.
shadinaif Shadi Naif
commit e249a6c243e7bc15fab9f804d19f55637657e8ea
2 changes: 1 addition & 1 deletion futurex_openedx_extensions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""One-line description for README and other doc files."""

__version__ = '0.9.16'
__version__ = '0.9.17'
11 changes: 6 additions & 5 deletions futurex_openedx_extensions/dashboard/urls.py
Original file line number Diff line number Diff line change
@@ -13,9 +13,10 @@

QUERY_ALLOWED_SCOPES = '|'.join(ClickhouseQuery.allowed_scopes())

router = DefaultRouter()
router.register(r'user_roles', views.UserRolesManagementView, basename='user-roles')
router.register(r'tasks', views.DataExportManagementView, basename='data-export-tasks')
roles_router = DefaultRouter()
roles_router.register(r'user_roles', views.UserRolesManagementView, basename='user-roles')
export_router = DefaultRouter()
export_router.register(r'tasks', views.DataExportManagementView, basename='data-export-tasks')

urlpatterns = [
re_path(r'^api/fx/accessible/v1/info/$', views.AccessibleTenantsInfoView.as_view(), name='accessible-info'),
@@ -38,8 +39,8 @@
name='learner-courses'
),
re_path(r'^api/fx/roles/v1/my_roles/$', views.MyRolesView.as_view(), name='my-roles'),
re_path(r'^api/fx/roles/v1/', include(router.urls)),
re_path(r'^api/fx/export/v1/', include(router.urls)),
re_path(r'^api/fx/roles/v1/', include(roles_router.urls)),
re_path(r'^api/fx/export/v1/', include(export_router.urls)),
re_path(r'^api/fx/statistics/v1/course_statuses/$', views.CourseStatusesView.as_view(), name='course-statuses'),
re_path(r'^api/fx/statistics/v1/rating/$', views.GlobalRatingView.as_view(), name='statistics-rating'),
re_path(r'^api/fx/statistics/v1/total_counts/$', views.TotalCountsView.as_view(), name='total-counts'),
15 changes: 7 additions & 8 deletions tests/test_dashboard/test_views.py
Original file line number Diff line number Diff line change
@@ -46,10 +46,6 @@ def setUp(self):
self.view_name = self.VIEW_NAME
self.url_args = []
self.staff_user = 2
self.registry = {}
for _, viewset, basename in urls.router.registry:
self.registry[basename] = viewset
self.viewset_base = None

@property
def url(self):
@@ -466,17 +462,20 @@ class TestDataExportTasksView(BaseTestViewMixin):

def set_action(self, action, task_id=1):
"""Set the viewname and client method"""
self.viewset_base = 'data-export-tasks'
self.view_name = f'fx_dashboard:{self.viewset_base}-{action}'
self.view_name = f'fx_dashboard:data-export-tasks-{action}'
self.url_args = []
if action == 'detail':
self.url_args = [task_id]

def test_permission_classes(self):
"""Verify that the view has the correct permission classes"""
registry = {}
for _, viewset, basename in urls.export_router.registry:
registry[basename] = viewset

for action in self.view_actions:
self.set_action(action)
view_class = self.registry['data-export-tasks']
view_class = registry['data-export-tasks']
self.assertEqual(view_class.permission_classes, [FXHasTenantCourseAccess])

def test_unauthorized(self):
@@ -1018,7 +1017,7 @@ def test_permission_classes(self, action):
self.set_action(action)

registry = {}
for _, viewset, basename in urls.router.registry:
for _, viewset, basename in urls.roles_router.registry:
registry[basename] = viewset
view_class = registry['user-roles']
self.assertEqual(view_class.permission_classes, [FXHasTenantAllCoursesAccess])