Пример #1
0
 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/sdk/test-data/', feed_date='2019-02-01')
     get_response = feed_req_obj.get()
     self.assertEqual(get_response.status_code, FAILURE_CODE)
     self.assertIsNotNone(get_response.message)
     self.assertIsNotNone(get_response.file_path, 'file_path is None in the response')
Пример #2
0
def games(title=None):
    '''
    Usage:

    Get all games at /games
    Get one game at /games/title

    returns json or 404 if not found
    '''
    feed = Feed(url=url)

    if title is None:
        return app.response_class(feed.get(), content_type='application/json')
    else:
        data = json.loads(feed.get())
        for item in data:
            if item['title'] == title:
                return app.response_class(json.dumps(item),
                                          content_type='application/json')
        return not_found()
Пример #3
0
 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/sdk/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.assertEqual(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.assertEqual(abspath(feed_req_obj.download_location), file_dir)
Пример #4
0
 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/sdk/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.assertEqual(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.assertEqual(abspath(feed_req_obj.download_location), file_dir)
Пример #5
0
 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.assertEqual(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')
Пример #6
0
    # 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()