本文整理汇总了Python中tests.ozpcenter.helper.APITestHelper类的典型用法代码示例。如果您正苦于以下问题:Python APITestHelper类的具体用法?Python APITestHelper怎么用?Python APITestHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了APITestHelper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_create_subscription_invalid_entity_type
def test_create_subscription_invalid_entity_type(self):
url = '/api/subscription/'
data = {
'entity_type': 'none',
'entity_id': 5
}
APITestHelper.request(self, url, 'POST', data=data, username='bigbrother', status_code=400)
开发者ID:aml-development,项目名称:ozp-backend,代码行数:7,代码来源:test_api_subscription.py
示例2: test_storefront_authorized_with_ordering
def test_storefront_authorized_with_ordering(self):
# Recommended
url = '/api/storefront/recommended/?ordering=title'
response = APITestHelper.request(self, url, 'GET', username='wsmith', status_code=200)
data = response.data['recommended']
sorted_data = sorted(data, key=lambda x: x['title'])
self.assertEqual(data, sorted_data)
# Featured
url = '/api/storefront/featured/?ordering=-title'
response = APITestHelper.request(self, url, 'GET', username='wsmith', status_code=200)
data = response.data['featured']
sorted_data = sorted(data, key=lambda x: x['title'], reverse=True)
self.assertEqual(data, sorted_data)
# Most Popular
url = '/api/storefront/most_popular/?ordering=-edited_date'
response = APITestHelper.request(self, url, 'GET', username='wsmith', status_code=200)
data = response.data['most_popular']
sorted_data = sorted(data, key=lambda x: x['edited_date'], reverse=True)
self.assertEqual(data, sorted_data)
# Recent
url = '/api/storefront/recent/?ordering=-approved_date'
response = APITestHelper.request(self, url, 'GET', username='wsmith', status_code=200)
data = response.data['recent']
sorted_data = sorted(data, key=lambda x: x['approved_date'], reverse=True)
self.assertEqual(data, sorted_data)
开发者ID:aml-development,项目名称:ozp-backend,代码行数:28,代码来源:test_api_storefront.py
示例3: test_get_deleted_tag_subscription
def test_get_deleted_tag_subscription(self):
subscription_response = self._create_subscription('tag', username='bigbrother')
url = '/api/tag/{}/'.format(subscription_response.data['entity_id'])
APITestHelper.request(self, url, 'DELETE', username='bigbrother', status_code=204)
url = '/api/subscription/{}/'.format(subscription_response.data['id'])
response = APITestHelper.request(self, url, 'GET', username='bigbrother', status_code=200)
# TODO: should status_code be 404?
self.assertEqual(response.data['entity_description'], 'OBJECT NOT FOUND')
开发者ID:aml-development,项目名称:ozp-backend,代码行数:9,代码来源:test_api_subscription.py
示例4: test_frequently_visited_listings_with_ordering
def test_frequently_visited_listings_with_ordering(self):
url = '/api/profile/self/listingvisits/frequent/?ordering=-title'
response = APITestHelper.request(self, url, 'GET', username='bigbrother', status_code=200)
data = response.data
url = '/api/profile/self/listingvisits/frequent/?ordering=title'
response = APITestHelper.request(self, url, 'GET', username='bigbrother', status_code=200)
reverse_data = response.data
self.assertEqual(data, reverse_data[::-1])
开发者ID:aml-development,项目名称:ozp-backend,代码行数:10,代码来源:test_api_profile_listingvisit.py
示例5: test_increment_visit
def test_increment_visit(self):
# assumes bigbrother has at least one listing visit
url = '/api/profile/self/listingvisits/'
response = APITestHelper.request(self, url, 'GET', username='bigbrother', status_code=200)
visit = response.data[0]
url = '/api/profile/self/listingvisits/increment/'
data = {'listing': {'id': visit['listing']['id']}}
response = APITestHelper.request(self, url, 'POST', data=data, username='bigbrother', status_code=200)
new_visit = response.data
self.assertEqual(visit['count'] + 1, new_visit['count'])
开发者ID:aml-development,项目名称:ozp-backend,代码行数:12,代码来源:test_api_profile_listingvisit.py
示例6: test_negative_feedback_listing
def test_negative_feedback_listing(self):
# Create a negative feedback
url = '/api/listing/1/feedback/'
data = {"feedback": -1}
APITestHelper.request(self, url, 'POST', data=data, username='bettafish', status_code=201)
# Check to see if created
response = APITestHelper.request(self, url, 'GET', username='bettafish', status_code=200)
self.assertEqual(response.data['feedback'], -1)
# Check with a different beta group user to see if feedback exists for said user
response = APITestHelper.request(self, url, 'GET', username='betaraybill', status_code=404)
self.assertEqual(response.data['feedback'], 0)
开发者ID:aml-development,项目名称:ozp-backend,代码行数:13,代码来源:test_api_listing_feedback.py
示例7: test_delete_listing
def test_delete_listing(self):
url = '/api/listing/1/'
response = APITestHelper.request(self, url, 'GET', username='wsmith', status_code=200)
self.assertFalse(response.data.get('is_deleted'))
self.assertEqual(validate_listing_map_keys(response.data), [])
url = '/api/listing/1/'
data = {'description': 'deleting listing'}
response = APITestHelper.request(self, url, 'DELETE', data=data, username='wsmith', status_code=204)
url = '/api/listing/1/'
response = APITestHelper.request(self, url, 'GET', username='wsmith', status_code=200)
self.assertTrue(response.data.get('is_deleted'))
self.assertEqual(validate_listing_map_keys(response.data), [])
开发者ID:aml-development,项目名称:ozp-backend,代码行数:14,代码来源:test_api_listing.py
示例8: test_listing_508_compliant_true
def test_listing_508_compliant_true(self):
LISTING_ID = 11
USER_NAME = 'bigbrother'
request_profile = generic_model_access.get_profile(USER_NAME)
user = generic_model_access.get_profile(USER_NAME).user
self.client.force_authenticate(user=user)
APITestHelper.edit_listing(self, LISTING_ID, {'is_508_compliant': True}, USER_NAME)
url = '/api/listing/{0!s}/'.format(LISTING_ID)
response = self.client.get(url, format='json')
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.data['is_508_compliant'], True)
开发者ID:aml-development,项目名称:ozp-backend,代码行数:14,代码来源:test_api_listing.py
示例9: test_frequently_visited_listings
def test_frequently_visited_listings(self):
url = '/api/profile/self/listingvisits/frequent/'
response = APITestHelper.request(self, url, 'GET', username='bigbrother', status_code=200)
freq_visit_ids = [i['id'] for i in response.data]
url = '/api/profile/self/listingvisits/'
response = APITestHelper.request(self, url, 'GET', username='bigbrother', status_code=200)
visit_counts = dict((i['listing']['id'], i['count']) for i in response.data)
curr_count = None
for id in freq_visit_ids:
if curr_count is not None:
self.assertTrue(visit_counts[id] <= curr_count)
curr_count = visit_counts[id]
开发者ID:aml-development,项目名称:ozp-backend,代码行数:14,代码来源:test_api_profile_listingvisit.py
示例10: test_subscription_subscribe_unsubscribe
def test_subscription_subscribe_unsubscribe(self):
for entity_type in self.entity_types:
subscription_response = self._create_subscription(entity_type)
# unsubscribe
url = '/api/self/subscription/{}/'.format(subscription_response.data['id'])
APITestHelper.request(self, url, 'DELETE', username='bigbrother', status_code=204)
# Verify that subscription does not exist
url = '/api/subscription/{}/'.format(subscription_response.data['id'])
response = APITestHelper.request(self, url, 'GET', username='bigbrother', status_code=404)
# response.data = {'error_code': 'not_found', 'error': True, 'detail': 'Not found.'}
url = '/api/self/subscription/{}/'.format(subscription_response.data['id'])
response = APITestHelper.request(self, url, 'GET', username='bigbrother', status_code=404)
开发者ID:aml-development,项目名称:ozp-backend,代码行数:15,代码来源:test_api_subscription.py
示例11: test_create_agency_apps_mall_steward
def test_create_agency_apps_mall_steward(self):
url = '/api/agency/'
data = {'title': 'new agency', 'short_name': 'orgname'}
response = APITestHelper.request(self, url, 'POST', data=data, username='bigbrother', status_code=201)
shorten_data = shorthand_dict(response.data, exclude_keys=['id'])
self.assertEqual(shorten_data, '(short_name:orgname,title:new agency)')
开发者ID:aml-development,项目名称:ozp-backend,代码行数:7,代码来源:test_api_agency.py
示例12: test_update_contact_type_apps_mall_steward
def test_update_contact_type_apps_mall_steward(self):
url = '/api/contact_type/1/'
data = {'name': 'Updated Type', 'required': True}
response = APITestHelper.request(self, url, 'PUT', data=data, username='bigbrother', status_code=200)
self.assertEqual(response.data['name'], 'Updated Type')
self.assertEqual(response.data['required'], True)
开发者ID:aml-development,项目名称:ozp-backend,代码行数:7,代码来源:test_api_contact_type.py
示例13: test_recommendation_user_base
def test_recommendation_user_base(self):
if self.es_failed:
self.skipTest('Elasticsearch is not currently up: {}'.format(self.error_string))
recommender_wrapper_obj = RecommenderDirectory()
actual_result = recommender_wrapper_obj.recommend('elasticsearch_user_base')
expected_result = {'Elasticsearch User Based Filtering': {}}
self.assertEquals(actual_result, expected_result)
url = '/api/storefront/recommended/?randomize=False'
response = APITestHelper.request(self, url, 'GET', username='wsmith', status_code=200)
title_scores = [{'title': listing['title'], '_score': listing['_score']} for listing in response.data['recommended']]
# title_scores = sorted(title_scores, key=lambda k: (k['_score']['_sort_score'], k['title']))
title_scores = shorthand_dict(title_scores)
expected_result = [
'(_score:(Elasticsearch User Based Filtering:(raw_score:10.0,weight:1.0),_sort_score:10.0),title:Railroad)',
'(_score:(Elasticsearch User Based Filtering:(raw_score:10.0,weight:1.0),_sort_score:10.0),title:Barsoom)',
'(_score:(Elasticsearch User Based Filtering:(raw_score:10.0,weight:1.0),_sort_score:10.0),title:Snow)',
'(_score:(Elasticsearch User Based Filtering:(raw_score:10.0,weight:1.0),_sort_score:10.0),title:Business Management System)',
'(_score:(Elasticsearch User Based Filtering:(raw_score:10.0,weight:1.0),_sort_score:10.0),title:Tornado)',
'(_score:(Elasticsearch User Based Filtering:(raw_score:8.333,weight:1.0),_sort_score:8.333),title:Pluto (Not a planet))',
'(_score:(Elasticsearch User Based Filtering:(raw_score:8.333,weight:1.0),_sort_score:8.333),title:Project Management)',
'(_score:(Elasticsearch User Based Filtering:(raw_score:8.333,weight:1.0),_sort_score:8.333),title:BeiDou Navigation Satellite System)',
'(_score:(Elasticsearch User Based Filtering:(raw_score:8.333,weight:1.0),_sort_score:8.333),title:Satellite navigation)',
'(_score:(Elasticsearch User Based Filtering:(raw_score:8.333,weight:1.0),_sort_score:8.333),title:Stop sign)'
]
# import json; print(json.dumps(title_scores, indent=4))
self.assertEquals(expected_result, title_scores)
开发者ID:aml-development,项目名称:ozp-backend,代码行数:31,代码来源:test_recommend_es.py
示例14: test_recommendation_baseline_graph
def test_recommendation_baseline_graph(self):
recommender_wrapper_obj = RecommenderDirectory()
actual_result = recommender_wrapper_obj.recommend('baseline,graph_cf')
expected_result = {'Baseline': {}, 'Bookmark Collaborative Filtering': {}}
self.assertEquals(actual_result, expected_result)
url = '/api/storefront/recommended/?randomize=False'
response = APITestHelper.request(self, url, 'GET', username='wsmith', status_code=200)
title_scores = [{'title': listing['title'], '_score': listing['_score']} for listing in response.data['recommended']]
title_scores = sorted(title_scores, key=lambda k: (k['_score']['_sort_score'], k['title'])) # Order can change between postgres and sqlite
title_scores = shorthand_dict(title_scores)
expected_result = [
'(_score:(Baseline:(raw_score:8.2,weight:1.0),Bookmark Collaborative Filtering:(raw_score:1.0,weight:5.0),_sort_score:13.2),title:Navigation)',
'(_score:(Baseline:(raw_score:8.5,weight:1.0),Bookmark Collaborative Filtering:(raw_score:1.0,weight:5.0),_sort_score:13.5),title:Bleach)',
'(_score:(Baseline:(raw_score:9.0,weight:1.0),Bookmark Collaborative Filtering:(raw_score:1.0,weight:5.0),_sort_score:14.0),title:Informational Book)',
'(_score:(Baseline:(raw_score:9.0,weight:1.0),Bookmark Collaborative Filtering:(raw_score:1.0,weight:5.0),_sort_score:14.0),title:JotSpot)',
'(_score:(Baseline:(raw_score:9.0,weight:1.0),Bookmark Collaborative Filtering:(raw_score:1.0,weight:5.0),_sort_score:14.0),title:LocationLister)',
'(_score:(Baseline:(raw_score:9.0,weight:1.0),Bookmark Collaborative Filtering:(raw_score:1.0,weight:5.0),_sort_score:14.0),title:Stop sign)',
'(_score:(Baseline:(raw_score:10.0,weight:1.0),Bookmark Collaborative Filtering:(raw_score:1.0,weight:5.0),_sort_score:15.0),title:Acoustic Guitar)',
'(_score:(Baseline:(raw_score:10.5,weight:1.0),Bookmark Collaborative Filtering:(raw_score:1.0,weight:5.0),_sort_score:15.5),title:Killer Whale)',
'(_score:(Baseline:(raw_score:11.5,weight:1.0),Bookmark Collaborative Filtering:(raw_score:1.0,weight:5.0),_sort_score:16.5),title:Wolf Finder)',
'(_score:(Baseline:(raw_score:11.5,weight:1.0),Bookmark Collaborative Filtering:(raw_score:2.0,weight:5.0),_sort_score:21.5),title:Chart Course)'
]
# import pprint
# print(pprint.pprint(title_scores))
self.assertEquals(expected_result, title_scores)
sorted_scores = [listing['_score']['_sort_score'] for listing in response.data['recommended']]
self.assertEquals(sorted(sorted_scores, reverse=True), sorted_scores)
开发者ID:aml-development,项目名称:ozp-backend,代码行数:32,代码来源:test_recommend.py
示例15: test_recommendation_baseline
def test_recommendation_baseline(self):
recommender_wrapper_obj = RecommenderDirectory()
actual_result = recommender_wrapper_obj.recommend('baseline')
expected_result = {'Baseline': {}}
self.assertEquals(actual_result, expected_result)
url = '/api/storefront/recommended/?randomize=False'
response = APITestHelper.request(self, url, 'GET', username='wsmith', status_code=200)
title_scores = [{'title': listing['title'], '_score': listing['_score']} for listing in response.data['recommended']]
title_scores = sorted(title_scores, key=lambda k: (k['_score']['_sort_score'], k['title'])) # Order can change between postgres and sqlite
title_scores = shorthand_dict(title_scores)
expected_result = [
'(_score:(Baseline:(raw_score:9.0,weight:1.0),_sort_score:9.0),title:Astrology software)',
'(_score:(Baseline:(raw_score:9.0,weight:1.0),_sort_score:9.0),title:Bass Fishing)',
'(_score:(Baseline:(raw_score:9.0,weight:1.0),_sort_score:9.0),title:Dragons)',
'(_score:(Baseline:(raw_score:9.0,weight:1.0),_sort_score:9.0),title:House Targaryen)',
'(_score:(Baseline:(raw_score:9.0,weight:1.0),_sort_score:9.0),title:Informational Book)',
'(_score:(Baseline:(raw_score:9.0,weight:1.0),_sort_score:9.0),title:JotSpot)',
'(_score:(Baseline:(raw_score:10.0,weight:1.0),_sort_score:10.0),title:Acoustic Guitar)',
'(_score:(Baseline:(raw_score:10.5,weight:1.0),_sort_score:10.5),title:Killer Whale)',
'(_score:(Baseline:(raw_score:11.5,weight:1.0),_sort_score:11.5),title:Chart Course)',
'(_score:(Baseline:(raw_score:11.5,weight:1.0),_sort_score:11.5),title:Wolf Finder)'
]
# import pprint
# print(pprint.pprint(title_scores))
self.assertEquals(expected_result, title_scores)
sorted_scores = [listing['_score']['_sort_score'] for listing in response.data['recommended']]
self.assertEquals(sorted(sorted_scores, reverse=True), sorted_scores)
开发者ID:aml-development,项目名称:ozp-backend,代码行数:32,代码来源:test_recommend.py
示例16: test_search_tags_startwith
def test_search_tags_startwith(self):
url = '/api/listings/search/?search=tag_'
response = APITestHelper.request(self, url, 'GET', username='wsmith', status_code=200, validator=validate_listing_map_keys_list)
titles = [i['title'] for i in response.data]
self.assertTrue('Air Mail' in titles)
self.assertTrue(len(titles) == 1)
开发者ID:aml-development,项目名称:ozp-backend,代码行数:7,代码来源:test_api_listing_search.py
示例17: test_recommendation_graph
def test_recommendation_graph(self):
recommender_wrapper_obj = RecommenderDirectory()
actual_result = recommender_wrapper_obj.recommend('graph_cf')
expected_result = {'Bookmark Collaborative Filtering': {}}
self.assertEquals(actual_result, expected_result)
url = '/api/storefront/recommended/?randomize=False'
response = APITestHelper.request(self, url, 'GET', username='wsmith', status_code=200)
title_scores = [{'title': listing['title'], '_score': listing['_score']} for listing in response.data['recommended']]
title_scores = sorted(title_scores, key=lambda k: (k['_score']['_sort_score'], k['title'])) # Order can change between postgres and sqlite
title_scores = shorthand_dict(title_scores)
import pprint
pprint.pprint(title_scores)
expected_result = [
'(_score:(Bookmark Collaborative Filtering:(raw_score:1.0,weight:5.0),_sort_score:5.0),title:Acoustic Guitar)',
'(_score:(Bookmark Collaborative Filtering:(raw_score:1.0,weight:5.0),_sort_score:5.0),title:Bleach)',
'(_score:(Bookmark Collaborative Filtering:(raw_score:1.0,weight:5.0),_sort_score:5.0),title:Bourbon)',
'(_score:(Bookmark Collaborative Filtering:(raw_score:1.0,weight:5.0),_sort_score:5.0),title:India Pale Ale)',
'(_score:(Bookmark Collaborative Filtering:(raw_score:1.0,weight:5.0),_sort_score:5.0),title:Informational Book)',
'(_score:(Bookmark Collaborative Filtering:(raw_score:1.0,weight:5.0),_sort_score:5.0),title:Internet meme)',
'(_score:(Bookmark Collaborative Filtering:(raw_score:1.0,weight:5.0),_sort_score:5.0),title:Killer Whale)',
'(_score:(Bookmark Collaborative Filtering:(raw_score:1.0,weight:5.0),_sort_score:5.0),title:Screamin Eagle CVO)',
'(_score:(Bookmark Collaborative Filtering:(raw_score:1.0,weight:5.0),_sort_score:5.0),title:Snow)',
'(_score:(Bookmark Collaborative Filtering:(raw_score:2.0,weight:5.0),_sort_score:10.0),title:Chart Course)'
]
# import pprint
# print(pprint.pprint(title_scores))
self.assertEquals(expected_result, title_scores)
sorted_scores = [listing['_score']['_sort_score'] for listing in response.data['recommended']]
self.assertEquals(sorted(sorted_scores, reverse=True), sorted_scores)
开发者ID:aml-development,项目名称:ozp-backend,代码行数:34,代码来源:test_recommend.py
示例18: test_get_shared_folder_list_create_delete
def test_get_shared_folder_list_create_delete(self):
"""
test_get_bookmark_list_shared_folder
test checks for shared folders (InstrumentSharing)
"""
new_library_object = _compare_bookmarks(self, self.library_object)
shared_folder_id = new_library_object.search('/bigbrother2/').first_shared_folder().id
response = _create_bookmark_listing(self, 'bigbrother2', 2, 'Air Mail', shared_folder_id)
new_library_object.search('/bigbrother2/').first_shared_folder().add_listing_bookmark('Air Mail')
new_library_object.search('/julia/').first_shared_folder().add_listing_bookmark('Air Mail')
new_library_object.search('/johnson/').first_shared_folder().add_listing_bookmark('Air Mail')
new_library_object = _compare_bookmarks(self, new_library_object)
username = 'bigbrother2'
url = '/api/bookmark/{}/'.format(response.data['id'])
response = APITestHelper.request(self, url, 'DELETE', username=username, status_code=204)
new_library_object.search_delete('/bigbrother2/InstrumentSharing/Air Mail')
new_library_object.search_delete('/julia/InstrumentSharing/Air Mail')
new_library_object.search_delete('/johnson/InstrumentSharing/Air Mail')
_compare_bookmarks(self, new_library_object)
开发者ID:aml-development,项目名称:ozp-backend,代码行数:26,代码来源:test_api_bookmark.py
示例19: test_get_bookmark_list_shared_folder_permissions
def test_get_bookmark_list_shared_folder_permissions(self):
"""
Test getting permissions for a shared folder, test between owner, viewer, other
"""
username = 'bigbrother2'
url = '/api/bookmark/'
response = APITestHelper.request(self, url, 'GET', username=username, status_code=200)
bookmark_folder = BookmarkFolder.parse_endpoint(response.data)
# Getting the id of the first shared folder
shared_folder_id = bookmark_folder.first_shared_folder().id
bigbrother2_permission_shorthand_expected = [
'bigbrother2(OWNER)',
'julia(OWNER)',
'johnson(VIEWER)'
]
# Check OWNER permission
_get_folder_permission(self, 'bigbrother2', shared_folder_id, bigbrother2_permission_shorthand_expected)
# Check OWNER permission
_get_folder_permission(self, 'julia', shared_folder_id, bigbrother2_permission_shorthand_expected)
# Check VIEWER permission
_get_folder_permission(self, 'johnson', shared_folder_id, bigbrother2_permission_shorthand_expected, status_code=403)
# Check OTHER permission
_get_folder_permission(self, 'bigbrother', shared_folder_id, bigbrother2_permission_shorthand_expected, status_code=403)
开发者ID:aml-development,项目名称:ozp-backend,代码行数:25,代码来源:test_api_bookmark.py
示例20: test_search_text
def test_search_text(self):
url = '/api/listings/search/?search=air mail'
response = APITestHelper.request(self, url, 'GET', username='wsmith', status_code=200, validator=validate_listing_map_keys_list)
titles = [i['title'] for i in response.data]
excepted_titles = ['Air Mail']
self.assertEqual(titles, excepted_titles)
开发者ID:aml-development,项目名称:ozp-backend,代码行数:7,代码来源:test_api_listing_search.py
注:本文中的tests.ozpcenter.helper.APITestHelper类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论