API
This package contains tests of the integreat_cms.api app
API Config
This modules contains the config for the API tests
- tests.api.api_config.API_ENDPOINTS: Final[list[tuple[str, str, str, int, int]]] = [('/api/v3/regions/', '/wp-json/extensions/v3/sites/', 'tests/api/expected-outputs/regions.json', 200, 8), ('/api/v3/regions/augsburg/', '/wp-json/extensions/v3/sites/augsburg/', 'tests/api/expected-outputs/regions_augsburg.json', 200, 3), ('/api/v3/regions/nurnberg/', '/wp-json/extensions/v3/sites/nurnberg/', 'tests/api/expected-outputs/regions_nurnberg.json', 200, 3), ('/api/v3/augsburg/languages/', '/augsburg/de/wp-json/extensions/v3/languages/', 'tests/api/expected-outputs/augsburg_languages.json', 200, 2), ('/api/v3/nurnberg/languages/', '/nurnberg/de/wp-json/extensions/v3/languages/', 'tests/api/expected-outputs/nurnberg_languages.json', 200, 2), ('/api/v3/augsburg/de/pages/', '/augsburg/de/wp-json/extensions/v3/pages/', 'tests/api/expected-outputs/augsburg_de_pages.json', 200, 8), ('/api/v3/augsburg/ar/pages/', '/augsburg/ar/wp-json/extensions/v3/pages/', 'tests/api/expected-outputs/augsburg_ar_pages.json', 200, 8), ('/api/v3/augsburg/non-existing/pages/', '/augsburg/non-existing/wp-json/extensions/v3/pages/', 'tests/api/expected-outputs/augsburg_non-existing_pages.json', 404, 2), ('/api/v3/augsburg/de/locations/', '/augsburg/de/wp-json/extensions/v3/locations/', 'tests/api/expected-outputs/augsburg_de_locations.json', 200, 7), ('/api/v3/augsburg/en/locations/', '/augsburg/en/wp-json/extensions/v3/locations/', 'tests/api/expected-outputs/augsburg_en_locations.json', 200, 7), ('/api/v3/augsburg/ar/locations/', '/augsburg/ar/wp-json/extensions/v3/locations/', 'tests/api/expected-outputs/augsburg_ar_locations.json', 200, 7), ('/api/v3/augsburg/non-existing/locations/', '/augsburg/non-existing/wp-json/extensions/v3/locations/', 'tests/api/expected-outputs/augsburg_non-existing_locations.json', 404, 2), ('/api/v3/augsburg/de/location-categories/', '/augsburg/de/wp-json/extensions/v3/location-categories/', 'tests/api/expected-outputs/augsburg_de_location_categories.json', 200, 12), ('/api/v3/augsburg/en/location-categories/', '/augsburg/en/wp-json/extensions/v3/location-categories/', 'tests/api/expected-outputs/augsburg_en_location_categories.json', 200, 12), ('/api/v3/augsburg/ar/location-categories/', '/augsburg/ar/wp-json/extensions/v3/location-categories/', 'tests/api/expected-outputs/augsburg_ar_location_categories.json', 200, 12), ('/api/v3/augsburg/de/children/', '/augsburg/de/wp-json/extensions/v3/children/', 'tests/api/expected-outputs/augsburg_de_children.json', 200, 7), ('/api/v3/augsburg/de/children/?depth=3&url=/augsburg/de/behörden-und-beratung/behörden/', '/augsburg/de/wp-json/extensions/v3/children/?depth=3&url=/augsburg/de/behörden-und-beratung/behörden/', 'tests/api/expected-outputs/augsburg_de_children_archived_descendants.json', 200, 15), ('/augsburg/de/wp-json/extensions/v3/page/?url=/augsburg/de/behörden-und-beratung/behörden/archiviertes-amt/', '/augsburg/de/wp-json/extensions/v3/page/?url=/augsburg/de/behörden-und-beratung/behörden/archiviertes-amt/', 'tests/api/expected-outputs/augsburg_de_page_archived.json', 404, 4), ('/api/v3/augsburg/de/children/?depth=2', '/augsburg/de/wp-json/extensions/v3/children/?depth=2', 'tests/api/expected-outputs/augsburg_de_children_depth_2.json', 200, 7), ('/api/v3/augsburg/de/events/', '/augsburg/de/wp-json/extensions/v3/events/', 'tests/api/expected-outputs/augsburg_de_events.json', 200, 5), ('/api/v3/augsburg/de/events/?combine_recurring=True', '/augsburg/de/wp-json/extensions/v3/events/?combine_recurring=True', 'tests/api/expected-outputs/augsburg_de_events_combine_recurring.json', 200, 5), ('/api/v3/augsburg/en/events/', '/augsburg/en/wp-json/extensions/v3/events/', 'tests/api/expected-outputs/augsburg_en_events.json', 200, 5), ('/api/v3/augsburg/ar/events/', '/augsburg/ar/wp-json/extensions/v3/events/', 'tests/api/expected-outputs/augsburg_ar_events.json', 200, 5), ('/api/v3/augsburg/non-existing/events/', '/augsburg/non-existing/wp-json/extensions/v3/events/', 'tests/api/expected-outputs/augsburg_non-existing_events.json', 404, 2), ('/api/v3/augsburg/de/page/?id=1', '/augsburg/de/wp-json/extensions/v3/page/?id=1', 'tests/api/expected-outputs/augsburg_de_page_1.json', 200, 6), ('/api/v3/augsburg/de/imprint/', '/augsburg/de/wp-json/extensions/v3/disclaimer/', 'tests/api/expected-outputs/augsburg_de_imprint.json', 200, 4), ('/api/v3/augsburg/en/imprint/', '/augsburg/en/wp-json/extensions/v3/disclaimer/', 'tests/api/expected-outputs/augsburg_en_imprint.json', 200, 4), ('/api/v3/augsburg/non-existing/imprint/', '/augsburg/non-existing/wp-json/extensions/v3/disclaimer/', 'tests/api/expected-outputs/augsburg_non-existing_imprint.json', 404, 2), ('/api/v3/nurnberg/de/events/', '/nurnberg/de/wp-json/extensions/v3/events/', 'tests/api/expected-outputs/nurnberg_de_events.json', 200, 9), ('/api/v3/nurnberg/en/events/', '/nurnberg/en/wp-json/extensions/v3/events/', 'tests/api/expected-outputs/nurnberg_en_events.json', 200, 9), ('/api/v3/nurnberg/ar/events/', '/nurnberg/ar/wp-json/extensions/v3/events/', 'tests/api/expected-outputs/nurnberg_ar_events.json', 200, 5), ('/api/v3/nurnberg/de/locations/', '/nurnberg/de/wp-json/extensions/v3/locations/', 'tests/api/expected-outputs/nurnberg_de_locations.json', 200, 7), ('/api/v3/nurnberg/en/locations/', '/nurnberg/en/wp-json/extensions/v3/locations/', 'tests/api/expected-outputs/nurnberg_en_locations.json', 200, 7), ('/api/v3/nurnberg/ar/locations/', '/nurnberg/ar/wp-json/extensions/v3/locations/', 'tests/api/expected-outputs/nurnberg_ar_locations.json', 200, 5), ('/api/v3/nurnberg/de/imprint/', '/nurnberg/de/wp-json/extensions/v3/disclaimer/', 'tests/api/expected-outputs/nurnberg_de_imprint.json', 200, 3), ('/api/v3/nurnberg/en/imprint/', '/nurnberg/en/wp-json/extensions/v3/disclaimer/', 'tests/api/expected-outputs/nurnberg_en_imprint.json', 200, 3), ('/api/v3/nurnberg/de/fcm/', '/nurnberg/de/wp-json/extensions/v3/fcm/', 'tests/api/expected-outputs/nurnberg_de_fcm.json', 200, 3), ('/api/v3/nurnberg/en/fcm/', '/nurnberg/en/wp-json/extensions/v3/fcm/', 'tests/api/expected-outputs/nurnberg_en_fcm.json', 200, 3), ('/api/v3/nurnberg/ar/fcm/', '/nurnberg/ar/wp-json/extensions/v3/fcm/', 'tests/api/expected-outputs/nurnberg_ar_fcm.json', 200, 3), ('/api/v3/augsburg/de/extras/', '/augsburg/de/wp-json/extensions/v3/extras/', 'tests/api/expected-outputs/augsburg-offers.json', 200, 3)][source]
The API endpoints
[ ( '/api/v3/regions/', '/wp-json/extensions/v3/sites/', 'tests/api/expected-outputs/regions.json', 200, 8, ), ( '/api/v3/regions/augsburg/', '/wp-json/extensions/v3/sites/augsburg/', 'tests/api/expected-outputs/regions_augsburg.json', 200, 3, ), ( '/api/v3/regions/nurnberg/', '/wp-json/extensions/v3/sites/nurnberg/', 'tests/api/expected-outputs/regions_nurnberg.json', 200, 3, ), ( '/api/v3/augsburg/languages/', '/augsburg/de/wp-json/extensions/v3/languages/', 'tests/api/expected-outputs/augsburg_languages.json', 200, 2, ), ( '/api/v3/nurnberg/languages/', '/nurnberg/de/wp-json/extensions/v3/languages/', 'tests/api/expected-outputs/nurnberg_languages.json', 200, 2, ), ( '/api/v3/augsburg/de/pages/', '/augsburg/de/wp-json/extensions/v3/pages/', 'tests/api/expected-outputs/augsburg_de_pages.json', 200, 8, ), ( '/api/v3/augsburg/ar/pages/', '/augsburg/ar/wp-json/extensions/v3/pages/', 'tests/api/expected-outputs/augsburg_ar_pages.json', 200, 8, ), ( '/api/v3/augsburg/non-existing/pages/', '/augsburg/non-existing/wp-json/extensions/v3/pages/', 'tests/api/expected-outputs/augsburg_non-existing_pages.json', 404, 2, ), ( '/api/v3/augsburg/de/locations/', '/augsburg/de/wp-json/extensions/v3/locations/', 'tests/api/expected-outputs/augsburg_de_locations.json', 200, 7, ), ( '/api/v3/augsburg/en/locations/', '/augsburg/en/wp-json/extensions/v3/locations/', 'tests/api/expected-outputs/augsburg_en_locations.json', 200, 7, ), ( '/api/v3/augsburg/ar/locations/', '/augsburg/ar/wp-json/extensions/v3/locations/', 'tests/api/expected-outputs/augsburg_ar_locations.json', 200, 7, ), ( '/api/v3/augsburg/non-existing/locations/', '/augsburg/non-existing/wp-json/extensions/v3/locations/', 'tests/api/expected-outputs/augsburg_non-existing_locations.json', 404, 2, ), ( '/api/v3/augsburg/de/location-categories/', '/augsburg/de/wp-json/extensions/v3/location-categories/', 'tests/api/expected-outputs/augsburg_de_location_categories.json', 200, 12, ), ( '/api/v3/augsburg/en/location-categories/', '/augsburg/en/wp-json/extensions/v3/location-categories/', 'tests/api/expected-outputs/augsburg_en_location_categories.json', 200, 12, ), ( '/api/v3/augsburg/ar/location-categories/', '/augsburg/ar/wp-json/extensions/v3/location-categories/', 'tests/api/expected-outputs/augsburg_ar_location_categories.json', 200, 12, ), ( '/api/v3/augsburg/de/children/', '/augsburg/de/wp-json/extensions/v3/children/', 'tests/api/expected-outputs/augsburg_de_children.json', 200, 7, ), ( '/api/v3/augsburg/de/children/?depth=3&url=/augsburg/de/behörden-und-beratung/behörden/', '/augsburg/de/wp-json/extensions/v3/children/?depth=3&url=/augsburg/de/behörden-und-beratung/behörden/', 'tests/api/expected-outputs/augsburg_de_children_archived_descendants.json', 200, 15, ), ( '/augsburg/de/wp-json/extensions/v3/page/?url=/augsburg/de/behörden-und-beratung/behörden/archiviertes-amt/', '/augsburg/de/wp-json/extensions/v3/page/?url=/augsburg/de/behörden-und-beratung/behörden/archiviertes-amt/', 'tests/api/expected-outputs/augsburg_de_page_archived.json', 404, 4, ), ( '/api/v3/augsburg/de/children/?depth=2', '/augsburg/de/wp-json/extensions/v3/children/?depth=2', 'tests/api/expected-outputs/augsburg_de_children_depth_2.json', 200, 7, ), ( '/api/v3/augsburg/de/events/', '/augsburg/de/wp-json/extensions/v3/events/', 'tests/api/expected-outputs/augsburg_de_events.json', 200, 5, ), ( '/api/v3/augsburg/de/events/?combine_recurring=True', '/augsburg/de/wp-json/extensions/v3/events/?combine_recurring=True', 'tests/api/expected-outputs/augsburg_de_events_combine_recurring.json', 200, 5, ), ( '/api/v3/augsburg/en/events/', '/augsburg/en/wp-json/extensions/v3/events/', 'tests/api/expected-outputs/augsburg_en_events.json', 200, 5, ), ( '/api/v3/augsburg/ar/events/', '/augsburg/ar/wp-json/extensions/v3/events/', 'tests/api/expected-outputs/augsburg_ar_events.json', 200, 5, ), ( '/api/v3/augsburg/non-existing/events/', '/augsburg/non-existing/wp-json/extensions/v3/events/', 'tests/api/expected-outputs/augsburg_non-existing_events.json', 404, 2, ), ( '/api/v3/augsburg/de/page/?id=1', '/augsburg/de/wp-json/extensions/v3/page/?id=1', 'tests/api/expected-outputs/augsburg_de_page_1.json', 200, 6, ), ( '/api/v3/augsburg/de/imprint/', '/augsburg/de/wp-json/extensions/v3/disclaimer/', 'tests/api/expected-outputs/augsburg_de_imprint.json', 200, 4, ), ( '/api/v3/augsburg/en/imprint/', '/augsburg/en/wp-json/extensions/v3/disclaimer/', 'tests/api/expected-outputs/augsburg_en_imprint.json', 200, 4, ), ( '/api/v3/augsburg/non-existing/imprint/', '/augsburg/non-existing/wp-json/extensions/v3/disclaimer/', 'tests/api/expected-outputs/augsburg_non-existing_imprint.json', 404, 2, ), ( '/api/v3/nurnberg/de/events/', '/nurnberg/de/wp-json/extensions/v3/events/', 'tests/api/expected-outputs/nurnberg_de_events.json', 200, 9, ), ( '/api/v3/nurnberg/en/events/', '/nurnberg/en/wp-json/extensions/v3/events/', 'tests/api/expected-outputs/nurnberg_en_events.json', 200, 9, ), ( '/api/v3/nurnberg/ar/events/', '/nurnberg/ar/wp-json/extensions/v3/events/', 'tests/api/expected-outputs/nurnberg_ar_events.json', 200, 5, ), ( '/api/v3/nurnberg/de/locations/', '/nurnberg/de/wp-json/extensions/v3/locations/', 'tests/api/expected-outputs/nurnberg_de_locations.json', 200, 7, ), ( '/api/v3/nurnberg/en/locations/', '/nurnberg/en/wp-json/extensions/v3/locations/', 'tests/api/expected-outputs/nurnberg_en_locations.json', 200, 7, ), ( '/api/v3/nurnberg/ar/locations/', '/nurnberg/ar/wp-json/extensions/v3/locations/', 'tests/api/expected-outputs/nurnberg_ar_locations.json', 200, 5, ), ( '/api/v3/nurnberg/de/imprint/', '/nurnberg/de/wp-json/extensions/v3/disclaimer/', 'tests/api/expected-outputs/nurnberg_de_imprint.json', 200, 3, ), ( '/api/v3/nurnberg/en/imprint/', '/nurnberg/en/wp-json/extensions/v3/disclaimer/', 'tests/api/expected-outputs/nurnberg_en_imprint.json', 200, 3, ), ( '/api/v3/nurnberg/de/fcm/', '/nurnberg/de/wp-json/extensions/v3/fcm/', 'tests/api/expected-outputs/nurnberg_de_fcm.json', 200, 3, ), ( '/api/v3/nurnberg/en/fcm/', '/nurnberg/en/wp-json/extensions/v3/fcm/', 'tests/api/expected-outputs/nurnberg_en_fcm.json', 200, 3, ), ( '/api/v3/nurnberg/ar/fcm/', '/nurnberg/ar/wp-json/extensions/v3/fcm/', 'tests/api/expected-outputs/nurnberg_ar_fcm.json', 200, 3, ), ( '/api/v3/augsburg/de/extras/', '/augsburg/de/wp-json/extensions/v3/extras/', 'tests/api/expected-outputs/augsburg-offers.json', 200, 3, ), ]
- tests.api.api_config.API_FEEDBACK_VIEWS: Final[list[tuple[str, dict[str, str]]]] = [('api:legacy_feedback_endpoint', {'category': 'Inhalte', 'comment': 'Cool page!', 'permalink': '/augsburg/de/willkommen', 'rating': 'up'}), ('api:legacy_feedback_endpoint', {'category': 'Technisches Feedback', 'comment': 'Strange bug!', 'permalink': '/augsburg/de/willkommen', 'rating': 'down'}), ('api:legacy_feedback_endpoint', {'category': 'Inhalte', 'comment': 'Cool event!', 'permalink': '/augsburg/de/events/test-veranstaltung', 'rating': 'up'}), ('api:legacy_feedback_endpoint', {'category': 'Technisches Feedback', 'comment': 'Strange bug!', 'permalink': '/augsburg/de/events/test-veranstaltung', 'rating': 'down'}), ('api:region_feedback', {'category': 'Inhalte', 'rating': 'up'}), ('api:region_feedback', {'category': 'Inhalte', 'comment': 'Feedback ohne Bewertung'}), ('api:region_feedback', {'category': 'Technisches Feedback', 'comment': 'Strange bug!', 'rating': 'down'}), ('api:page_feedback', {'category': 'Inhalte', 'comment': 'Cool page!', 'rating': 'up', 'slug': 'willkommen'}), ('api:page_feedback', {'category': 'Technisches Feedback', 'comment': 'Strange bug!', 'rating': 'down', 'slug': 'willkommen'}), ('api:poi_feedback', {'category': 'Inhalte', 'comment': 'Cool POI!', 'rating': 'up', 'slug': 'test-ort'}), ('api:poi_feedback', {'category': 'Technisches Feedback', 'comment': 'Strange bug!', 'rating': 'down', 'slug': 'test-ort'}), ('api:event_feedback', {'category': 'Inhalte', 'comment': 'Cool event!', 'rating': 'up', 'slug': 'test-veranstaltung'}), ('api:event_feedback', {'category': 'Technisches Feedback', 'comment': 'Strange bug!', 'rating': 'down', 'slug': 'test-veranstaltung$2030-01-01'}), ('api:event_list_feedback', {'category': 'Inhalte', 'comment': 'Cool events!', 'rating': 'up'}), ('api:event_list_feedback', {'category': 'Technisches Feedback', 'comment': 'Strange bug!', 'rating': 'down'}), ('api:imprint_page_feedbacks', {'category': 'Inhalte', 'comment': 'Cool imprint!', 'rating': 'up'}), ('api:imprint_page_feedbacks', {'category': 'Technisches Feedback', 'comment': 'Strange bug!', 'rating': 'down'}), ('api:map_feedback', {'category': 'Inhalte', 'comment': 'Cool map!', 'rating': 'up'}), ('api:map_feedback', {'category': 'Technisches Feedback', 'comment': 'Strange bug!', 'rating': 'down'}), ('api:search_result_feedback', {'category': 'Inhalte', 'comment': 'Cool search results!', 'query': 'search query', 'rating': 'up'}), ('api:search_result_feedback', {'category': 'Technisches Feedback', 'comment': 'Strange bug!', 'query': 'search query', 'rating': 'down'}), ('api:offer_list_feedback', {'category': 'Inhalte', 'comment': 'Cool offers!', 'rating': 'up'}), ('api:offer_list_feedback', {'category': 'Technisches Feedback', 'comment': 'Strange bug!', 'rating': 'down'}), ('api:offer_feedback', {'category': 'Inhalte', 'comment': 'Cool offer!', 'rating': 'up', 'slug': 'sprungbrett'}), ('api:offer_feedback', {'category': 'Technisches Feedback', 'comment': 'Strange bug!', 'rating': 'down', 'slug': 'sprungbrett'})][source]
This list contains the config for all API feedback views
[ ( 'api:legacy_feedback_endpoint', { 'category': 'Inhalte', 'comment': 'Cool page!', 'permalink': '/augsburg/de/willkommen', 'rating': 'up', }, ), ( 'api:legacy_feedback_endpoint', { 'category': 'Technisches Feedback', 'comment': 'Strange bug!', 'permalink': '/augsburg/de/willkommen', 'rating': 'down', }, ), ( 'api:legacy_feedback_endpoint', { 'category': 'Inhalte', 'comment': 'Cool event!', 'permalink': '/augsburg/de/events/test-veranstaltung', 'rating': 'up', }, ), ( 'api:legacy_feedback_endpoint', { 'category': 'Technisches Feedback', 'comment': 'Strange bug!', 'permalink': '/augsburg/de/events/test-veranstaltung', 'rating': 'down', }, ), ('api:region_feedback', {'category': 'Inhalte', 'rating': 'up'}), ( 'api:region_feedback', {'category': 'Inhalte', 'comment': 'Feedback ohne Bewertung'}, ), ( 'api:region_feedback', { 'category': 'Technisches Feedback', 'comment': 'Strange bug!', 'rating': 'down', }, ), ( 'api:page_feedback', { 'category': 'Inhalte', 'comment': 'Cool page!', 'rating': 'up', 'slug': 'willkommen', }, ), ( 'api:page_feedback', { 'category': 'Technisches Feedback', 'comment': 'Strange bug!', 'rating': 'down', 'slug': 'willkommen', }, ), ( 'api:poi_feedback', { 'category': 'Inhalte', 'comment': 'Cool POI!', 'rating': 'up', 'slug': 'test-ort', }, ), ( 'api:poi_feedback', { 'category': 'Technisches Feedback', 'comment': 'Strange bug!', 'rating': 'down', 'slug': 'test-ort', }, ), ( 'api:event_feedback', { 'category': 'Inhalte', 'comment': 'Cool event!', 'rating': 'up', 'slug': 'test-veranstaltung', }, ), ( 'api:event_feedback', { 'category': 'Technisches Feedback', 'comment': 'Strange bug!', 'rating': 'down', 'slug': 'test-veranstaltung$2030-01-01', }, ), ( 'api:event_list_feedback', {'category': 'Inhalte', 'comment': 'Cool events!', 'rating': 'up'}, ), ( 'api:event_list_feedback', { 'category': 'Technisches Feedback', 'comment': 'Strange bug!', 'rating': 'down', }, ), ( 'api:imprint_page_feedbacks', {'category': 'Inhalte', 'comment': 'Cool imprint!', 'rating': 'up'}, ), ( 'api:imprint_page_feedbacks', { 'category': 'Technisches Feedback', 'comment': 'Strange bug!', 'rating': 'down', }, ), ( 'api:map_feedback', {'category': 'Inhalte', 'comment': 'Cool map!', 'rating': 'up'}, ), ( 'api:map_feedback', { 'category': 'Technisches Feedback', 'comment': 'Strange bug!', 'rating': 'down', }, ), ( 'api:search_result_feedback', { 'category': 'Inhalte', 'comment': 'Cool search results!', 'query': 'search query', 'rating': 'up', }, ), ( 'api:search_result_feedback', { 'category': 'Technisches Feedback', 'comment': 'Strange bug!', 'query': 'search query', 'rating': 'down', }, ), ( 'api:offer_list_feedback', {'category': 'Inhalte', 'comment': 'Cool offers!', 'rating': 'up'}, ), ( 'api:offer_list_feedback', { 'category': 'Technisches Feedback', 'comment': 'Strange bug!', 'rating': 'down', }, ), ( 'api:offer_feedback', { 'category': 'Inhalte', 'comment': 'Cool offer!', 'rating': 'up', 'slug': 'sprungbrett', }, ), ( 'api:offer_feedback', { 'category': 'Technisches Feedback', 'comment': 'Strange bug!', 'rating': 'down', 'slug': 'sprungbrett', }, ), ]
- tests.api.api_config.API_RAW_CONTENT_ENDPOINTS: Final[list[tuple[str, str | None, int, int]]] = [('/api/v3/raw-content/', 'tests/api/expected-outputs/raw_content.html', 200, 1), ('/api/v3/raw-content/landing/de/', 'tests/api/expected-outputs/raw_content_landing_de.html', 200, 1), ('/api/v3/raw-content/landing/non-existing/', 'tests/api/expected-outputs/raw_content_landing_non-existing.html', 404, 1), ('/api/v3/raw-content/augsburg/', 'tests/api/expected-outputs/raw_content_augsburg.html', 200, 2), ('/api/v3/raw-content/augsburg/de/', 'tests/api/expected-outputs/raw_content_augsburg_de.html', 200, 2), ('/api/v3/raw-content/augsburg/non-existing/', 'tests/api/expected-outputs/raw_content_augsburg_non-existing.html', 404, 2), ('/api/v3/raw-content/augsburg/de/willkommen/', 'tests/api/expected-outputs/raw_content_augsburg_de_page.html', 200, 3), ('/api/v3/raw-content/augsburg/de/non-existing/', 'tests/api/expected-outputs/raw_content_augsburg_de_page_non-existing.html', 404, 3), ('/api/v3/raw-content/augsburg/de/disclaimer/impressum/', 'tests/api/expected-outputs/raw_content_augsburg_de_imprint.html', 200, 3), ('/api/v3/raw-content/augsburg/de/events/test-veranstaltung/', 'tests/api/expected-outputs/raw_content_augsburg_de_event.html', 200, 3), ('/api/v3/raw-content/augsburg/de/events/non-existing/', 'tests/api/expected-outputs/raw_content_augsburg_de_event_non-existing.html', 404, 3), ('/api/v3/raw-content/augsburg/de/locations/test-ort/', 'tests/api/expected-outputs/raw_content_augsburg_de_location.html', 200, 3), ('/api/v3/raw-content/augsburg/de/locations/non-existing/', 'tests/api/expected-outputs/raw_content_augsburg_de_location_non-existing.html', 404, 3), ('/api/v3/raw-content/augsburg/de/news/local/1/', 'tests/api/expected-outputs/raw_content_augsburg_de_pn_non-existing.html', 404, 3), ('/api/v3/raw-content/birkenfeld/de/', 'tests/api/expected-outputs/raw_content_birkenfeld_de_archived.html', 404, 2)][source]
The raw content endpoints
[ ( '/api/v3/raw-content/', 'tests/api/expected-outputs/raw_content.html', 200, 1, ), ( '/api/v3/raw-content/landing/de/', 'tests/api/expected-outputs/raw_content_landing_de.html', 200, 1, ), ( '/api/v3/raw-content/landing/non-existing/', 'tests/api/expected-outputs/raw_content_landing_non-existing.html', 404, 1, ), ( '/api/v3/raw-content/augsburg/', 'tests/api/expected-outputs/raw_content_augsburg.html', 200, 2, ), ( '/api/v3/raw-content/augsburg/de/', 'tests/api/expected-outputs/raw_content_augsburg_de.html', 200, 2, ), ( '/api/v3/raw-content/augsburg/non-existing/', 'tests/api/expected-outputs/raw_content_augsburg_non-existing.html', 404, 2, ), ( '/api/v3/raw-content/augsburg/de/willkommen/', 'tests/api/expected-outputs/raw_content_augsburg_de_page.html', 200, 3, ), ( '/api/v3/raw-content/augsburg/de/non-existing/', 'tests/api/expected-outputs/raw_content_augsburg_de_page_non-existing.html', 404, 3, ), ( '/api/v3/raw-content/augsburg/de/disclaimer/impressum/', 'tests/api/expected-outputs/raw_content_augsburg_de_imprint.html', 200, 3, ), ( '/api/v3/raw-content/augsburg/de/events/test-veranstaltung/', 'tests/api/expected-outputs/raw_content_augsburg_de_event.html', 200, 3, ), ( '/api/v3/raw-content/augsburg/de/events/non-existing/', 'tests/api/expected-outputs/raw_content_augsburg_de_event_non-existing.html', 404, 3, ), ( '/api/v3/raw-content/augsburg/de/locations/test-ort/', 'tests/api/expected-outputs/raw_content_augsburg_de_location.html', 200, 3, ), ( '/api/v3/raw-content/augsburg/de/locations/non-existing/', 'tests/api/expected-outputs/raw_content_augsburg_de_location_non-existing.html', 404, 3, ), ( '/api/v3/raw-content/augsburg/de/news/local/1/', 'tests/api/expected-outputs/raw_content_augsburg_de_pn_non-existing.html', 404, 3, ), ( '/api/v3/raw-content/birkenfeld/de/', 'tests/api/expected-outputs/raw_content_birkenfeld_de_archived.html', 404, 2, ), ]
Test API Chat
Test Chat API / Zammad
As we have no Zammad server in the test setup, we need to mock the responses.
- tests.api.test_api_chat.mark_chat_active(device_id: str) None[source]
Update the current chat’s
last_message_timestampto now so it is not considered expired. Uses a queryset update to bypass theauto_nowbehaviour.- Parameters:
device_id (str) – device id whose current chat should be marked active
- Return type:
None
- tests.api.test_api_chat.mark_chat_expired(device_id: str) None[source]
Update the current chat’s
last_message_timestampto be older than the retention period so it is considered expired. Uses a queryset update to bypass theauto_nowbehaviour.- Parameters:
device_id (str) – device id whose current chat should be marked expired
- Return type:
None
- tests.api.test_api_chat.test_api_chat_first_chat(automatic_answers: Mock, get_zammad_user_mail: Mock, create_ticket: Mock, evaluation_consent: Mock, save_message: Mock, messages: Mock, celery_translate_and_answer_question: Mock, load_test_data: None) None[source]
Check that sending a message from a never seen-before device_id creates a new chat
- tests.api.test_api_chat.test_api_chat_get_messages_failure(get_zammad_user_mail: Mock, load_test_data: None) None[source]
Check that GET-ing messages for a non-existing chat returns an error
- Parameters:
load_test_data (None) – The fixture providing the test data (see
load_test_data())get_zammad_user_mail (Mock)
- Return type:
None
- tests.api.test_api_chat.test_api_chat_get_messages_success(save_message: Mock, evaluation_consent: Mock, messages: Mock, get_zammad_user_mail: Mock, load_test_data: None) None[source]
Check that GET-ing messages works for an existing chat
- Parameters:
load_test_data (None) – The fixture providing the test data (see
load_test_data())save_message (Mock)
evaluation_consent (Mock)
messages (Mock)
get_zammad_user_mail (Mock)
- Return type:
None
- tests.api.test_api_chat.test_api_chat_incorrect_server_error(mock_zammad_url: Mock, load_test_data: None) None[source]
Check that incorrect server url leads to an error
- Parameters:
load_test_data (None) – The fixture providing the test data (see
load_test_data())mock_zammad_url (Mock)
- Return type:
None
- tests.api.test_api_chat.test_api_chat_missing_auth_error(zammad_request: Mock, load_test_data: None) None[source]
Check that missing/wrong auth information leads to an error
- Parameters:
load_test_data (None) – The fixture providing the test data (see
load_test_data())zammad_request (Mock)
- Return type:
None
- tests.api.test_api_chat.test_api_chat_ratelimiting(save_message: Mock, evaluation_consent: Mock, messages: Mock, get_zammad_user_mail: Mock, load_test_data: None) None[source]
Check that the ratelimiting correctly prevents further API requests
- Parameters:
load_test_data (None) – The fixture providing the test data (see
load_test_data())save_message (Mock)
evaluation_consent (Mock)
messages (Mock)
get_zammad_user_mail (Mock)
- Return type:
None
- tests.api.test_api_chat.test_api_chat_ratelimiting_trusted_ip_header(save_message: Mock, evaluation_consent: Mock, messages: Mock, get_zammad_user_mail: Mock, load_test_data: None) None[source]
Check that ratelimiting kicks in when a trusted IP header is configured but not set in the request.
- Parameters:
load_test_data (None) – The fixture providing the test data (see
load_test_data())save_message (Mock)
evaluation_consent (Mock)
messages (Mock)
get_zammad_user_mail (Mock)
- Return type:
None
- tests.api.test_api_chat.test_api_chat_send_message(celery_translate_and_answer_question: Mock, get_zammad_user_mail: Mock, save_message: Mock, get_messages: Mock, evaluation_consent: Mock, automatic_answers: Mock, load_test_data: None) None[source]
Check that sending a message with a known device_id works and does not create a new chat
- tests.api.test_api_chat.test_api_chat_set_evaluation_consent(celery_translate_and_answer_question: Mock, evaluation_consent: Mock, save_message: Mock, save_evaluation_consent: Mock, messages: Mock, get_zammad_user_mail: Mock, automatic_answers: Mock, load_test_data: None) None[source]
Check that setting evaluation consent works for an existing (active) chat
- Parameters:
- Return type:
None
- tests.api.test_api_chat.test_api_chat_stale_chat_get_returns_not_found(get_zammad_user_mail: Mock, load_test_data: None) None[source]
Check that GET-ing messages for an expired chat returns a “not found” error instead of creating a new chat.
- Parameters:
load_test_data (None) – The fixture providing the test data (see
load_test_data())get_zammad_user_mail (Mock)
- Return type:
None
- tests.api.test_api_chat.test_api_chat_stale_chat_starts_new_chat(celery_translate_and_answer_question: Mock, evaluation_consent: Mock, save_message: Mock, messages: Mock, create_ticket: Mock, get_zammad_user_mail: Mock, automatic_answers: Mock, load_test_data: None) None[source]
Check that a new chat is started when the existing chat has been inactive long enough that its Zammad ticket is assumed to be gone (Zammad’s retention policy).
- tests.api.test_api_chat.test_api_is_chat_enabled_for_user(load_test_data: None) None[source]
Check that whether a user is chat beta tester is stored in the DB
- Parameters:
load_test_data (None) – The fixture providing the test data (see
load_test_data())- Return type:
None
Test API Feedback
- tests.api.test_api_feedback.test_api_feedback_errors(load_test_data: None, view_name: str, kwargs: dict[str, str], post_data: dict[str, str], response_data: dict[str, Any]) None[source]
Check different errors during feedback processing
- Parameters:
load_test_data (None) – The fixture providing the test data (see
load_test_data())view_name (str) – The identifier of the view
kwargs (dict[str, str]) – The keyword argument passed to the view
- Return type:
None
- tests.api.test_api_feedback.test_api_feedback_invalid_method(load_test_data: None) None[source]
Check error when request method is not POST
- Parameters:
load_test_data (None) – The fixture providing the test data (see
load_test_data())- Return type:
None
- tests.api.test_api_feedback.test_api_feedback_success(load_test_data: None, view_name: str, post_data: dict[str, str]) None[source]
Check successful feedback submission for different feedback types
- Parameters:
load_test_data (None) – The fixture providing the test data (see
load_test_data())view_name (str) – The identifier of the view
- Return type:
None
Test API Push Page
- tests.api.test_api_push_page.test_api_push_page_content(load_test_data: None) None[source]
This test class checks all endpoints defined in
API_ENDPOINTS. It verifies that the content delivered by the endpoint is equivalent with the data provided in the corresponding json file.- Parameters:
load_test_data (None) – The fixture providing the test data (see
load_test_data())- Return type:
None
Test API Raw Content
- tests.api.test_api_raw_content.REGION_SLUG = 'augsburg'[source]
The region and language which are used for the tests which are not parametrized
- tests.api.test_api_raw_content.test_api_result(load_test_data: None, django_assert_num_queries: Callable, endpoint: str, expected_result: str, expected_code: int, expected_queries: int) None[source]
This test class checks all endpoints defined in
API_RAW_CONTENT_ENDPOINTS. It verifies that the content delivered by the endpoint is equivalent with the data provided in the corresponding html file.- Parameters:
load_test_data (None) – The fixture providing the test data (see
load_test_data())django_assert_num_queries (Callable) – The fixture providing the query assertion
endpoint (str) – The url of the new Django pattern
expected_result (str) – The path to the html file that contains the expected result
expected_code (int) – The expected HTTP status code
expected_queries (int) – The expected number of SQL queries
- Return type:
None
- tests.api.test_api_raw_content.test_external_news_content_is_sanitized(load_test_data: None, clean_news_cache: None) None[source]
External news are not created in our own editor, so their content must be sanitized before it is served.
- Parameters:
load_test_data (None) – The fixture providing the test data (see
load_test_data())clean_news_cache (None) – Fixture that wipes external news-source cache entries
- Return type:
None
- tests.api.test_api_raw_content.test_local_news_is_addressed_by_translation_id(load_test_data: None, prefix: str) None[source]
Local news are addressed by the id of their translation, just like in the web app and in the news API.
- Parameters:
load_test_data (None) – The fixture providing the test data (see
load_test_data())prefix (str) – The url prefix of the endpoint under test
- Return type:
None
- tests.api.test_api_raw_content.test_local_news_text_is_escaped(load_test_data: None) None[source]
The text of a push notification is plain text, so it must be escaped and its line breaks must be kept.
- Parameters:
load_test_data (None) – The fixture providing the test data (see
load_test_data())- Return type:
None
- tests.api.test_api_raw_content.test_local_news_which_is_not_public(load_test_data: None, prefix: str, sent_date: datetime | None) None[source]
Local news which have not been sent yet or which are older than the FCM history window are not exposed.
- Parameters:
load_test_data (None) – The fixture providing the test data (see
load_test_data())prefix (str) – The url prefix of the endpoint under test
sent_date (datetime | None) – The date the push notification was sent, or
Noneif it has not been sent yet
- Return type:
None
- tests.api.test_api_raw_content.test_page_content_rejects_outdated_slug(load_test_data: None) None[source]
A page’s outdated (renamed) slug must not resolve to its current content anymore, even though the superseded translation version which used it is still marked as
PUBLIC(see https://github.com/digitalfabrik/integreat-cms/issues/4524).- Parameters:
load_test_data (None) – The fixture providing the test data (see
load_test_data())- Return type:
None
Test API Result
- tests.api.test_api_result.test_api_result(load_test_data: None, update_snapshots: bool, django_assert_num_queries: Callable, endpoint: str, wp_endpoint: str, expected_result: str, expected_code: int, expected_queries: int) None[source]
This test class checks all endpoints defined in
API_ENDPOINTS. It verifies that the content delivered by the endpoint is equivalent with the data provided in the corresponding json file.- Parameters:
load_test_data (None) – The fixture providing the test data (see
load_test_data())update_snapshots (bool) – Whether to update snapshot files instead of comparing
django_assert_num_queries (Callable) – The fixture providing the query assertion
endpoint (str) – The url of the new Django pattern
wp_endpoint (str) – The legacy url of the wordpress endpoint pattern
expected_result (str) – The path to the json file that contains the expected result
expected_code (int) – The expected HTTP status code
expected_queries (int) – The expected number of SQL queries
- Return type:
None
Test API Token Auth
- tests.api.test_api_token_auth.test_api_token_required_accepts_valid_token(load_test_data: None) None[source]
A valid bearer token authenticates the request and updates the last usage.
- Parameters:
load_test_data (None) – The fixture providing the test data (see
load_test_data())- Return type:
None
- tests.api.test_api_token_auth.test_api_token_required_enforces_permission(load_test_data: None) None[source]
A token only grants the permissions of its user, so a user without the required permission is rejected while a privileged user passes.
- Parameters:
load_test_data (None) – The fixture providing the test data (see
load_test_data())- Return type:
None
- tests.api.test_api_token_auth.test_api_token_required_rejects_inactive_user(load_test_data: None) None[source]
A token of a deactivated user must not authenticate anymore.
- Parameters:
load_test_data (None) – The fixture providing the test data (see
load_test_data())- Return type:
None
- tests.api.test_api_token_auth.test_api_token_required_rejects_invalid_tokens(load_test_data: None, header: str | None) None[source]
Missing, malformed and unknown tokens are rejected with 403.
- Parameters:
load_test_data (None) – The fixture providing the test data (see
load_test_data())header (str | None) – The value of the
Authorizationheader
- Return type:
None
Test News Endpoint
- tests.api.test_news_endpoint.test_news_endpoint(load_test_data: None, clean_news_cache: None, disable_auto_news_reimport: None) None[source]
The combined endpoint merges items from every news source and sorts them by
display_date, newest first.- Parameters:
load_test_data (None) – The fixture providing the test data (see
load_test_data())clean_news_cache (None) – Fixture that wipes external news-source cache entries
disable_auto_news_reimport (None)
- Return type:
None
- tests.api.test_news_endpoint.test_news_endpoint_pagination(load_test_data: None, clean_news_cache: None, disable_auto_news_reimport: None) None[source]
The combined endpoint returns only one page of results at a time. Page 1 contains the most recent items; page 2 contains the next batch. Non-integer and out-of-range page numbers fall back gracefully via
get_safe_page().- Parameters:
load_test_data (None) – The fixture providing the test data (see
load_test_data())clean_news_cache (None) – Fixture that wipes external news-source cache entries
disable_auto_news_reimport (None)
- Return type:
None
- tests.api.test_news_endpoint.test_news_endpoint_source_filter(load_test_data: None, clean_news_cache: None, disable_auto_news_reimport: None) None[source]
The combined endpoint supports filtering by source. Filtering by
localreturns only push notifications; filtering bytunewsreturns only tüNews items.- Parameters:
load_test_data (None) – The fixture providing the test data (see
load_test_data())clean_news_cache (None) – Fixture that wipes external news-source cache entries
disable_auto_news_reimport (None)
- Return type:
None
- tests.api.test_news_endpoint.test_single_news_endpoint(load_test_data: None, clean_news_cache: None, disable_auto_news_reimport: None) None[source]
The single news endpoint returns one news that matches the given id.
- Parameters:
load_test_data (None) – The fixture providing the test data (see
load_test_data())clean_news_cache (None) – Fixture that wipes external news-source cache entries
disable_auto_news_reimport (None)
- Return type:
None
Test Pushnotification API
- tests.api.test_pushnotification_api.create_a_pushnotification(region_slug: str) tuple[int, int][source]
A function to create a new push notification and a translation in the default language of the region.
- tests.api.test_pushnotification_api.test_no_archived_pushnotification(load_test_data: None) None[source]
Check that archived push notifications are excluded from the API result
- Parameters:
load_test_data (None) – The fixture providing the test data (see
load_test_data())- Return type:
None
Test Region Settings
- tests.api.test_region_settings.test_api_managed_region_form_shows_the_real_budget(load_test_data: None) None[source]
An API-managed region may have a budget outside the predefined package sizes, so the form must not fall back to a dropdown which would display a wrong value.
- Parameters:
load_test_data (None) – The fixture providing the test data (see
load_test_data())- Return type:
None
- tests.api.test_region_settings.test_get_region_settings(load_test_data: None) None[source]
The endpoint returns the writable settings plus the derived budget values.
- Parameters:
load_test_data (None) – The fixture providing the test data (see
load_test_data())- Return type:
None
- tests.api.test_region_settings.test_post_accepts_budget_outside_the_predefined_sizes(load_test_data: None) None[source]
The model no longer restricts the budget to the package sizes, so any integer is accepted.
- Parameters:
load_test_data (None) – The fixture providing the test data (see
load_test_data())- Return type:
None
- tests.api.test_region_settings.test_post_rejects_invalid_values(load_test_data: None) None[source]
Values which do not pass the model validation are rejected with 400.
- Parameters:
load_test_data (None) – The fixture providing the test data (see
load_test_data())- Return type:
None
- tests.api.test_region_settings.test_post_rejects_non_writable_fields(load_test_data: None, payload: dict) None[source]
Only the allow-listed settings may be written.
- Parameters:
load_test_data (None) – The fixture providing the test data (see
load_test_data())payload (dict) – The rejected request body
- Return type:
None
- tests.api.test_region_settings.test_post_updates_settings_and_records_sync(load_test_data: None) None[source]
A POST writes the supplied fields and marks the region as API-managed.
- Parameters:
load_test_data (None) – The fixture providing the test data (see
load_test_data())- Return type:
None
- tests.api.test_region_settings.test_requires_authentication(load_test_data: None) None[source]
Without a valid token the endpoint answers with 403.
- Parameters:
load_test_data (None) – The fixture providing the test data (see
load_test_data())- Return type:
None
- tests.api.test_region_settings.test_requires_permission(load_test_data: None) None[source]
A token of a user without
cms.change_regionis rejected.- Parameters:
load_test_data (None) – The fixture providing the test data (see
load_test_data())- Return type:
None
- tests.api.test_region_settings.test_unknown_region_returns_404(load_test_data: None) None[source]
An unknown region slug results in a 404.
- Parameters:
load_test_data (None) – The fixture providing the test data (see
load_test_data())- Return type:
None