Skip to content

Commit

Permalink
[#3192] package_search with ignore_auth now==calling as sysadmin, upd…
Browse files Browse the repository at this point in the history
…ate tests
  • Loading branch information
wardi committed Aug 21, 2016
1 parent 14360ed commit 666f3a1
Showing 1 changed file with 30 additions and 32 deletions.
62 changes: 30 additions & 32 deletions ckan/tests/logic/action/test_get.py
Expand Up @@ -961,10 +961,9 @@ def test_package_search_with_fq_excludes_private(self):
factories.Dataset(user=user, private=True, owner_org=org['name'])

fq = "capacity:private"
results = helpers.call_action('package_search', fq=fq)['results']
results = logic.get_action('package_search')({}, {'fq':fq})['results']

eq(len(results), 1)
eq(results[0]['name'], dataset['name'])
eq(len(results), 0)

def test_package_search_with_fq_excludes_drafts(self):
'''
Expand Down Expand Up @@ -997,7 +996,8 @@ def test_package_search_with_include_drafts_option_excludes_drafts_for_anon_user
draft_dataset = factories.Dataset(user=user, state='draft')
factories.Dataset(user=user, private=True, owner_org=org['name'])

results = helpers.call_action('package_search', include_drafts=True)['results']
results = logic.get_action('package_search')(
{}, {'include_drafts':True})['results']

eq(len(results), 1)
nose.tools.assert_not_equals(results[0]['name'], draft_dataset['name'])
Expand All @@ -1018,8 +1018,8 @@ def test_package_search_with_include_drafts_option_includes_drafts_for_sysadmin(
other_draft_dataset = factories.Dataset(user=other_user, state='draft')
factories.Dataset(user=user, private=True, owner_org=org['name'])

results = helpers.call_action('package_search', include_drafts=True,
context={'user': sysadmin['name']})['results']
results = logic.get_action('package_search')(
{'user': sysadmin['name']}, {'include_drafts': True})['results']

eq(len(results), 3)
names = [r['name'] for r in results]
Expand All @@ -1042,8 +1042,8 @@ def test_package_search_with_include_drafts_false_option_doesnot_include_drafts_
other_draft_dataset = factories.Dataset(user=other_user, state='draft')
factories.Dataset(user=user, private=True, owner_org=org['name'])

results = helpers.call_action('package_search', include_drafts=False,
context={'user': sysadmin['name']})['results']
results = logic.get_action('package_search')(
{'user': sysadmin['name']}, {'include_drafts':False})['results']

eq(len(results), 1)
names = [r['name'] for r in results]
Expand All @@ -1066,8 +1066,8 @@ def test_package_search_with_include_drafts_option_includes_drafts_for_user(self
other_draft_dataset = factories.Dataset(user=other_user, state='draft', name="other-draft-dataset")
factories.Dataset(user=user, private=True, owner_org=org['name'], name="private-dataset")

results = helpers.call_action('package_search', include_drafts=True,
context={'user': user['name']})['results']
results = logic.get_action('package_search')(
{'user': user['name']}, {'include_drafts':True})['results']

eq(len(results), 3)
names = [r['name'] for r in results]
Expand All @@ -1092,8 +1092,8 @@ def test_package_search_with_fq_for_create_user_id_will_include_datasets_for_oth
factories.Dataset(user=user, private=True, owner_org=org['name'], name="private-dataset")

fq = "creator_user_id:{0}".format(other_user['id'])
results = helpers.call_action('package_search', fq=fq,
context={'user': user['name']})['results']
results = logic.get_action('package_search')(
{'user': user['name']}, {'fq': fq})['results']

eq(len(results), 1)
names = [r['name'] for r in results]
Expand All @@ -1118,8 +1118,9 @@ def test_package_search_with_fq_for_create_user_id_will_not_include_drafts_for_o
factories.Dataset(user=user, private=True, owner_org=org['name'], name="private-dataset")

fq = "(creator_user_id:{0} AND +state:draft)".format(other_user['id'])
results = helpers.call_action('package_search', fq=fq,
context={'user': user['name']})['results']
results = logic.get_action('package_search')(
{'user': user['name']},
{'fq': fq, 'include_drafts': True})['results']

eq(len(results), 0)

Expand All @@ -1139,8 +1140,9 @@ def test_package_search_with_fq_for_creator_user_id_and_drafts_and_include_draft
factories.Dataset(user=user, private=True, owner_org=org['name'], name="private-dataset")

fq = "(creator_user_id:{0} AND +state:draft)".format(other_user['id'])
results = helpers.call_action('package_search', fq=fq, include_drafts=True,
context={'user': user['name']})['results']
results = logic.get_action('package_search')(
{'user': user['name']},
{'fq': fq, 'include_drafts': True})['results']

eq(len(results), 0)

Expand All @@ -1160,8 +1162,9 @@ def test_package_search_with_fq_for_creator_user_id_and_include_drafts_option_wi
factories.Dataset(user=user, private=True, owner_org=org['name'], name="private-dataset")

fq = "creator_user_id:{0}".format(other_user['id'])
results = helpers.call_action('package_search', fq=fq, include_drafts=True,
context={'user': user['name']})['results']
results = logic.get_action('package_search')(
{'user': user['name']},
{'fq': fq, 'include_drafts': True})['results']

names = [r['name'] for r in results]
eq(len(results), 1)
Expand All @@ -1184,8 +1187,9 @@ def test_package_search_with_fq_for_create_user_id_will_include_drafts_for_other
factories.Dataset(user=user, private=True, owner_org=org['name'], name="private-dataset")

fq = "(creator_user_id:{0} AND +state:draft)".format(user['id'])
results = helpers.call_action('package_search', fq=fq,
context={'user': sysadmin['name']})['results']
results = logic.get_action('package_search')(
{'user': sysadmin['name']},
{'fq': fq})['results']

names = [r['name'] for r in results]
eq(len(results), 1)
Expand All @@ -1203,10 +1207,8 @@ def test_package_search_private_with_include_private(self):
factories.Dataset(user=user, state='draft')
private_dataset = factories.Dataset(user=user, private=True, owner_org=org['name'])

results = helpers.call_action(
'package_search',
include_private=True,
context={'user': user['name']})['results']
results = logic.get_action('package_search')(
{'user': user['name']}, {'include_private': True})['results']

eq([r['name'] for r in results], [private_dataset['name']])

Expand All @@ -1217,10 +1219,8 @@ def test_package_search_private_with_include_private_wont_show_other_orgs_privat
org2 = factories.Organization(user=user2)
private_dataset = factories.Dataset(user=user2, private=True, owner_org=org2['name'])

results = helpers.call_action(
'package_search',
include_private=True,
context={'user': user['name']})['results']
results = logic.get_action('package_search')(
{'user': user['name']}, {'include_private': True})['results']

eq([r['name'] for r in results], [])

Expand All @@ -1230,10 +1230,8 @@ def test_package_search_private_with_include_private_syadmin(self):
org = factories.Organization(user=user)
private_dataset = factories.Dataset(user=user, private=True, owner_org=org['name'])

results = helpers.call_action(
'package_search',
include_private=True,
context={'user': sysadmin['name']})['results']
results = logic.get_action('package_search')(
{'user': sysadmin['name']}, {'include_private': True})['results']

eq([r['name'] for r in results], [private_dataset['name']])

Expand Down

0 comments on commit 666f3a1

Please sign in to comment.