-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HDX-9010 - adding test and validator for title (include inactive)
- Loading branch information
1 parent
da6c26e
commit 6f15b8b
Showing
6 changed files
with
188 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
ckanext-hdx_org_group/ckanext/hdx_org_group/tests/test_closed_organization.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
''' | ||
reCreated on 19 Sep, 2023 | ||
@author: dan | ||
''' | ||
|
||
import pytest | ||
import logging as logging | ||
import ckan.model as model | ||
import ckan.plugins.toolkit as tk | ||
|
||
_get_action = tk.get_action | ||
NotAuthorized = tk.NotAuthorized | ||
log = logging.getLogger(__name__) | ||
|
||
|
||
@pytest.mark.usefixtures('keep_db_tables_on_clean', 'clean_db', 'clean_index', 'setup_user_data', | ||
'with_request_context') | ||
class TestClosedOrg(object): | ||
|
||
def test_closed_organization(self, app): | ||
|
||
orgadmin = 'orgadmin' | ||
context = {'model': model, 'session': model.Session, 'user': orgadmin} | ||
|
||
org_dict = _get_action('organization_show')(context, {'id': 'hdx-test-org', 'include_users':True}) | ||
|
||
org_dict['closed_organization'] = True | ||
result = _get_action('organization_update')(context, org_dict) | ||
org_dict = _get_action('organization_show')(context, {'id': 'hdx-test-org', 'include_users':True}) | ||
assert '(inactive)' in org_dict.get('title') | ||
|
||
org_dict['closed_organization'] = False | ||
context = {'model': model, 'session': model.Session, 'user': orgadmin} | ||
result = _get_action('organization_update')(context, org_dict) | ||
org_dict = _get_action('organization_show')(context, {'id': 'hdx-test-org', 'include_users':True}) | ||
assert '(inactive)' not in org_dict.get('title') | ||
|
||
org_dict['closed_organization'] = True | ||
org_dict['title'] = 'HDX TEST ORG 123 (closed)' | ||
context = {'model': model, 'session': model.Session, 'user': orgadmin} | ||
result = _get_action('organization_update')(context, org_dict) | ||
org_dict = _get_action('organization_show')(context, {'id': 'hdx-test-org'}) | ||
assert '(inactive)' in org_dict.get('title') | ||
assert '123' in org_dict.get('title') |
Oops, something went wrong.