1+ from unittest import mock
12from types import SimpleNamespace
23import pytest
34from ckantoolkit .tests import factories as ckan_factories
@@ -22,13 +23,29 @@ def test_regular_user(self, app, setup_data):
2223
2324 resp = app .get ("/activity-info" , headers = environ )
2425 assert resp .status_code == 200
25- # CKAN users without a registered ActivityInfo token, will be asked to add one
26+ # This must be redirected to the /api-key URL
2627 assert "Add API key" in resp .body
2728
2829 def test_activityinfo_user (self , app , setup_data ):
2930 environ = {"Authorization" : setup_data .activityinfo_user ["token" ]}
30-
31- resp = app .get ("/activity-info" , headers = environ )
32- assert resp .status_code == 200
33- # Activity info users will see the ActivityInfo UI
34- assert "Update API key" in resp .body
31+ fake_databases = [
32+ {
33+ "databaseId" : "0001" ,
34+ "label" : "Database label 01" ,
35+ "description" : "" ,
36+ "ownerId" : "999999999" ,
37+ "billingAccountId" : 8888888888888888 ,
38+ "suspended" : False ,
39+ "publishedTemplate" : False ,
40+ "languages" : []
41+ },
42+ ]
43+
44+ with mock .patch (
45+ "ckanext.activityinfo.data.base.ActivityInfoClient.get_databases" ,
46+ return_value = fake_databases ,
47+ ):
48+ resp = app .get ("/activity-info" , headers = environ )
49+ assert resp .status_code == 200
50+ # Activity info users will be redirected to see their databases
51+ assert "Activity Info databases" in resp .body
0 commit comments