diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/test_dashboard/test_details/__init__.py b/tests/test_dashboard/test_details/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/test_dashboard/test_details/test_details_learners.py b/tests/test_dashboard/test_details/test_details_learners.py index 2118d009..90c287c6 100644 --- a/tests/test_dashboard/test_details/test_details_learners.py +++ b/tests/test_dashboard/test_details/test_details_learners.py @@ -1,9 +1,7 @@ """Tests for learner details collectors""" import pytest -from django.db.models import Sum from futurex_openedx_extensions.dashboard.details.learners import get_learners_queryset -from tests.base_test_data import expected_statistics @pytest.mark.django_db @@ -16,6 +14,6 @@ ([7], 'user6', 0), ([4], None, 0), ]) -def test_get_learners_queryset(base_data, tenant_ids, search_text, expected_count): +def test_get_learners_queryset(base_data, tenant_ids, search_text, expected_count): # pylint: disable=unused-argument """Verify that get_learners_queryset returns the correct QuerySet.""" assert get_learners_queryset(tenant_ids, search_text).count() == expected_count diff --git a/tests/test_dashboard/test_statistics/__init__.py b/tests/test_dashboard/test_statistics/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/test_dashboard/test_statistics/test_certificates.py b/tests/test_dashboard/test_statistics/test_certificates.py index 67a68b41..e6dadabb 100644 --- a/tests/test_dashboard/test_statistics/test_certificates.py +++ b/tests/test_dashboard/test_statistics/test_certificates.py @@ -19,7 +19,7 @@ ([2, 7], {'ORG3': 7, 'ORG8': 2}), ([7, 8], {'ORG3': 7, 'ORG8': 2}), ]) -def test_get_certificates_count(base_data, tenant_ids, expected_result): +def test_get_certificates_count(base_data, tenant_ids, expected_result): # pylint: disable=unused-argument """Verify get_certificates_count function.""" result = certificates.get_certificates_count(tenant_ids) assert result == expected_result, \ @@ -27,7 +27,7 @@ def test_get_certificates_count(base_data, tenant_ids, expected_result): @pytest.mark.django_db -def test_get_certificates_count_not_downloadable(base_data): +def test_get_certificates_count_not_downloadable(base_data): # pylint: disable=unused-argument """Verify get_certificates_count function with empty tenant_ids.""" result = certificates.get_certificates_count([1]) assert result == {'ORG1': 4, 'ORG2': 10}, f'Wrong certificates result. expected: {result}' diff --git a/tests/test_dashboard/test_statistics/test_learners.py b/tests/test_dashboard/test_statistics/test_learners.py index 3c1a6474..87993392 100644 --- a/tests/test_dashboard/test_statistics/test_learners.py +++ b/tests/test_dashboard/test_statistics/test_learners.py @@ -15,7 +15,9 @@ (7, {'ORG3': 13}), (8, {'ORG8': 6}), ]) -def test_get_learners_count_having_enrollment_per_org(base_data, tenant_id, expected_result): +def test_get_learners_count_having_enrollment_per_org( + base_data, tenant_id, expected_result +): # pylint: disable=unused-argument """Test get_learners_count_having_enrollment_per_org function.""" result = learners.get_learners_count_having_enrollment_per_org(tenant_id) assert result.count() == len(expected_result), 'Wrong number of organizations returned' @@ -37,7 +39,9 @@ def test_get_learners_count_having_enrollment_per_org(base_data, tenant_id, expe (7, 13), (8, 6), ]) -def test_get_learners_count_having_enrollment_for_tenant(base_data, tenant_id, expected_result): +def test_get_learners_count_having_enrollment_for_tenant( + base_data, tenant_id, expected_result +): # pylint: disable=unused-argument """Test get_learners_count_having_enrollment_for_tenant function.""" result = learners.get_learners_count_having_enrollment_for_tenant(tenant_id) assert result == expected_result, f'Wrong learners count: {result} for tenant: {tenant_id}' @@ -54,14 +58,16 @@ def test_get_learners_count_having_enrollment_for_tenant(base_data, tenant_id, e (7, 4), (8, 3), ]) -def test_get_learners_count_having_no_enrollment(base_data, tenant_id, expected_result): +def test_get_learners_count_having_no_enrollment( + base_data, tenant_id, expected_result +): # pylint: disable=unused-argument """Test get_learners_count_having_no_enrollment function.""" result = learners.get_learners_count_having_no_enrollment(tenant_id) assert result == expected_result, f'Wrong learners count: {result} for tenant: {tenant_id}' @pytest.mark.django_db -def test_get_learners_count(base_data): +def test_get_learners_count(base_data): # pylint: disable=unused-argument """Test get_learners_count function.""" result = learners.get_learners_count([1, 2, 4]) assert result == { diff --git a/tests/test_helpers/__init__.py b/tests/test_helpers/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/test_helpers/test_permissions.py b/tests/test_helpers/test_permissions.py index c9c7c48a..a4b9d988 100644 --- a/tests/test_helpers/test_permissions.py +++ b/tests/test_helpers/test_permissions.py @@ -26,7 +26,7 @@ def set_user(request, user_id): ('GET', '?tenant_ids=1,2,3', 2), ('GET', '', 1), ]) -def test_has_tenant_access(base_data, method, query_params, user_id): +def test_has_tenant_access(base_data, method, query_params, user_id): # pylint: disable=unused-argument """Verify that HasTenantAccess returns True when user has access to all tenants.""" permission = HasTenantAccess() request = APIRequestFactory().generic(method, f'/dummy/{query_params}') @@ -40,7 +40,9 @@ def test_has_tenant_access(base_data, method, query_params, user_id): ('GET', '?tenant_ids=1,2,3', 6, 'denied', [1, 2, 3]), ('GET', '?tenant_ids=1,2,3,4,9', 1, 'invalid', [9, 4]), ]) -def test_has_tenant_access_no_access(base_data, method, query_params, user_id, reason, bad_tenant_ids): +def test_has_tenant_access_no_access( + base_data, method, query_params, user_id, reason, bad_tenant_ids +): # pylint: disable=unused-argument """Verify that PermissionDenied is raised when user does not have access to one of the tenants.""" permission = HasTenantAccess() request = APIRequestFactory().generic(method, f'/dummy/{query_params}') @@ -63,7 +65,7 @@ def test_has_tenant_access_no_access(base_data, method, query_params, user_id, r @pytest.mark.django_db @pytest.mark.parametrize('user_id', [0, None]) -def test_has_tenant_access_not_authenticated(base_data, user_id): +def test_has_tenant_access_not_authenticated(base_data, user_id): # pylint: disable=unused-argument """Verify that NotAuthenticated is raised when user is not authenticated.""" permission = HasTenantAccess() request = APIRequestFactory().generic('GET', '/dummy/')