def test_download_feed_invalid_date(self): feed_req_obj = Feed(FeedType.ITEM.value, FeedScope.BOOTSTRAP.value, '220', 'EBAY_US', 'Bearer v^1 ...', download_location='../tests/test-data/', feed_date='2019-02-01') get_response = feed_req_obj.get() self.assertEquals(get_response.status_code, FAILURE_CODE) self.assertIsNotNone(get_response.message) self.assertIsNotNone(get_response.file_path, 'file_path is None in the response')
def test_download_feed_daily_multiple_calls(self): feed_req_obj = Feed(FeedType.ITEM.value, FeedScope.BOOTSTRAP.value, self.test_category_2, self.test_marketplace, self.test_token, download_location='../tests/test-data/') get_response = feed_req_obj.get() # store the file path for clean up self.file_paths.append(get_response.file_path) # assert the result self.assertEquals(get_response.status_code, SUCCESS_CODE) self.assertIsNotNone(get_response.message) self.assertIsNotNone(get_response.file_path, 'file has not been created') self.assertTrue(isfile(get_response.file_path), 'file_path is not pointing to a file. file_path: %s' % get_response.file_path) # check the file size and name self.assertTrue(getsize(get_response.file_path) > PROD_CHUNK_SIZE, 'feed file is less than %s. file_path: %s' % (PROD_CHUNK_SIZE, get_response.file_path)) self.assertTrue(FeedPrefix.BOOTSTRAP.value in get_response.file_path, 'feed file name does not have %s in it. file_path: %s' % (FeedPrefix.BOOTSTRAP.value, get_response.file_path)) file_dir, file_name = split(abspath(get_response.file_path)) self.assertEquals(abspath(feed_req_obj.download_location), file_dir)
def test_download_feed_daily(self): test_date = get_formatted_date(FeedType.ITEM, -4) feed_req_obj = Feed(FeedType.ITEM.value, FeedScope.DAILY.value, self.test_category_1, self.test_marketplace, self.test_token, download_location='../tests/test-data/', feed_date=test_date) get_response = feed_req_obj.get() # store the file path for clean up self.file_paths.append(get_response.file_path) # assert the result self.assertEquals(get_response.status_code, SUCCESS_CODE) self.assertIsNotNone(get_response.message) self.assertIsNotNone(get_response.file_path, 'file_path is None') self.assertTrue(isfile(get_response.file_path), 'file_path is not pointing to a file. file_path: %s' % get_response.file_path) # check the file size and name self.assertTrue(getsize(get_response.file_path) > 0, 'feed file is empty. file_path: %s' % get_response.file_path) self.assertTrue(FeedPrefix.DAILY.value in get_response.file_path, 'feed file name does not have %s in it. file_path: %s' % (FeedPrefix.DAILY.value, get_response.file_path)) file_dir, file_name = split(abspath(get_response.file_path)) self.assertEquals(abspath(feed_req_obj.download_location), file_dir)
# create the filtered file feed_filter_obj = FeedFilterRequest(args.downloadlocation, args.itemf, args.lf, args.sellerf, args.gtinf, args.epidf, args.pricelf, args.priceuf, args.locf, args.iepidf, args.qf, args.format) filter_response = feed_filter_obj.filter() if filter_response.status_code != SUCCESS_CODE: print(filter_response.message) else: # download the feed file if --filteronly option is not set feed_obj = Feed(FeedType.ITEM.value, args.scope, args.c1, args.mkt, args.token, args.dt, args.env, args.downloadlocation, args.format) get_response = feed_obj.get() if get_response.status_code != SUCCESS_CODE: logger.error( 'Exception in downloading feed. Cannot proceed\nFile path: %s\n Error message: %s\n', get_response.file_path, get_response.message) else: # create the filtered file feed_filter_obj = FeedFilterRequest(get_response.file_path, args.itemf, args.lf, args.sellerf, args.gtinf, args.epidf, args.pricelf, args.priceuf, args.locf, args.iepidf, args.qf, args.format) filter_response = feed_filter_obj.filter() if filter_response.status_code != SUCCESS_CODE: print(filter_response.message) end = time.time()
def test_none_token(self): feed_req_obj = Feed(FeedType.ITEM.value, FeedScope.BOOTSTRAP.value, '220', 'EBAY_US', None) get_response = feed_req_obj.get() self.assertEquals(get_response.status_code, FAILURE_CODE) self.assertIsNotNone(get_response.message) self.assertIsNone(get_response.file_path, 'file_path is not None in the response')
from feed.feed_request import Feed feed_obj = Feed(feed_type='item', feed_scope='ALL_ACTIVE', category_id='6000', marketplace_id='EBAY_US', token='none', environment='PRODUCTION') feed_obj.get()