本文整理汇总了Python中tests.ozpcenter.helper.APITestHelper.edit_listing方法的典型用法代码示例。如果您正苦于以下问题:Python APITestHelper.edit_listing方法的具体用法?Python APITestHelper.edit_listing怎么用?Python APITestHelper.edit_listing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tests.ozpcenter.helper.APITestHelper
的用法示例。
在下文中一共展示了APITestHelper.edit_listing方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_listing_508_compliant_true
# 需要导入模块: from tests.ozpcenter.helper import APITestHelper [as 别名]
# 或者: from tests.ozpcenter.helper.APITestHelper import edit_listing [as 别名]
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)
示例2: test_featured_listings_order
# 需要导入模块: from tests.ozpcenter.helper import APITestHelper [as 别名]
# 或者: from tests.ozpcenter.helper.APITestHelper import edit_listing [as 别名]
def test_featured_listings_order(self):
"""
test_featured_listings_order
Supported query params: is_featured, featured_date
"""
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)
# Get the targeted listing's data. (The listing to be featured)
url = '/api/listing/{0!s}/'.format(LISTING_ID)
response = self.client.get(url, format='json')
self.assertEqual(response.status_code, status.HTTP_200_OK)
target_listing_data = response.data
target_listing_id = target_listing_data['id']
# Un-feature target listing, if already featured (toggle)
if (target_listing_data['is_featured']):
APITestHelper.edit_listing(self, LISTING_ID, {'is_featured': False}, USER_NAME)
# Get the 1st featured listing id
url = '/api/storefront/featured/'
self.client.force_authenticate(user=user)
response = self.client.get(url, format='json')
self.assertEqual(response.status_code, status.HTTP_200_OK)
first_featured_listing_id = response.data['featured'][0]['id']
# Check - The target listing is not 1st in the featured list
self.assertNotEqual(first_featured_listing_id, target_listing_id)
# Feature the target listing
APITestHelper.edit_listing(self, LISTING_ID, {'is_featured': True}, USER_NAME)
# Get the 1st featured listing id
url = '/api/storefront/featured/'
self.client.force_authenticate(user=user)
response = self.client.get(url, format='json')
self.assertEqual(response.status_code, status.HTTP_200_OK)
first_featured_listing_id = response.data['featured'][0]['id']
# Check - target featured listing is now the 1st featured listing
self.assertEqual(first_featured_listing_id, target_listing_id)
示例3: test_get_bookmark_list_admin_disable_listing
# 需要导入模块: from tests.ozpcenter.helper import APITestHelper [as 别名]
# 或者: from tests.ozpcenter.helper.APITestHelper import edit_listing [as 别名]
def test_get_bookmark_list_admin_disable_listing(self):
"""
Check for bookmarks when listing owner disables listing, it should not be visable
"""
new_library_object = _compare_bookmarks(self, self.library_object)
bigbrother_listing = new_library_object.search('/bigbrother/').first_listing_bookmark()
# Disable Listing
APITestHelper.edit_listing(self, bigbrother_listing.listing_id, {'is_enabled': False}, 'bigbrother')
bigbrother_listing.hidden(True)
_compare_bookmarks(self, new_library_object)
APITestHelper.edit_listing(self, bigbrother_listing.listing_id, {'is_enabled': True}, 'bigbrother')
bigbrother_listing.hidden(False)
_compare_bookmarks(self, new_library_object)
示例4: test_unfeature_listing
# 需要导入模块: from tests.ozpcenter.helper import APITestHelper [as 别名]
# 或者: from tests.ozpcenter.helper.APITestHelper import edit_listing [as 别名]
def test_unfeature_listing(self):
"""
test_unfeature_listing
Supported query params: is_featured, featured_date
"""
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)
# Un-feature listing
APITestHelper.edit_listing(self, LISTING_ID, {'is_featured': False}, 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_featured'], False)
示例5: test_essearch_is_enable
# 需要导入模块: from tests.ozpcenter.helper import APITestHelper [as 别名]
# 或者: from tests.ozpcenter.helper.APITestHelper import edit_listing [as 别名]
def test_essearch_is_enable(self):
"""
test_essearch_is_enable
Elasticsearch Search should be independent from database(sqlite/postgresql)
"""
if self.es_failed:
self.skipTest('Elasticsearch is not currently up: {}'.format(self.error_string))
url = '/api/listings/essearch/?search=demo_tag&type=Web Application'
response = APITestHelper.request(self, url, 'GET', username='wsmith', status_code=200)
titles_ids = _format_essearch_endpoint(response.data)
titles = [record['title'] for record in titles_ids]
expected_titles = [
"Air Mail",
"Bread Basket",
"Chart Course",
"Chatter Box",
"Clipboard",
"Double Heroides",
"Floppy Disk",
"FrameIt",
"Hatch Latch",
"House Stark",
"JotSpot",
"Lightning",
"LocationAnalyzer",
"LocationLister",
"LocationViewer",
"Monkey Finder",
"Skybox",
"Smart Phone",
"Taxonomy Classifier",
"Tornado"
]
self.assertEqual(titles, expected_titles)
owners = [{'owners': record.get('owners')} for record in response.data['results']]
usage_requirements = [{'usage_requirements': record.get('usage_requirements')} for record in response.data['results']]
system_requirements = [{'system_requirements': record.get('system_requirements')} for record in response.data['results']]
self.assertIsNotNone(owners)
self.assertIsNotNone(usage_requirements)
self.assertIsNotNone(system_requirements)
first_record = titles_ids[0]
id_to_disable = first_record['id']
replace_dict = {'title': '{}_disabled'.format(first_record['title']),
'is_enabled': False}
# Disable one app
APITestHelper.edit_listing(self, id_to_disable, replace_dict, 'bigbrother')
elasticsearch_factory.wait_for_yellow_cluster_heath()
# Check
url = '/api/listings/essearch/?search=demo_tag&type=Web Application'
response = APITestHelper.request(self, url, 'GET', username='wsmith', status_code=200)
titles_ids = [{'title': record.get('title'), 'id': record.get('id')} for record in response.data['results']]
titles = sorted([i['title'] for i in titles_ids])
# import json; print(json.dumps(titles, indent=2))
expected_titles = [
"Bread Basket",
"Chart Course",
"Chatter Box",
"Clipboard",
"Double Heroides",
"Floppy Disk",
"FrameIt",
"Hatch Latch",
"House Stark",
"JotSpot",
"Lightning",
"LocationAnalyzer",
"LocationLister",
"LocationViewer",
"Monkey Finder",
"Skybox",
"Smart Phone",
"Taxonomy Classifier",
"Tornado"
]
self.assertEqual(titles, expected_titles)