コード例 #1
0
 def test_default_values(self):
     feed_req_obj = Feed(None, None, '220', 'EBAY_US', 'v^1 ...')
     self.assertEquals(feed_req_obj.feed_type, FeedType.ITEM.value)
     self.assertEquals(feed_req_obj.feed_scope, FeedScope.DAILY.value)
     self.assertTrue(feed_req_obj.token.startswith('Bearer'), 'Bearer is missing from token')
     self.assertEquals(feed_req_obj.feed_date, get_formatted_date(feed_req_obj.feed_type))
     self.assertEquals(feed_req_obj.environment, Environment.PRODUCTION.value)
     self.assertEquals(feed_req_obj.download_location, DEFAULT_DOWNLOAD_LOCATION)
     self.assertEquals(feed_req_obj.file_format, FileFormat.GZIP.value)
コード例 #2
0
 def __init__(self, feed_type, feed_scope, category_id, marketplace_id, token, feed_date=None,
              environment=Environment.PRODUCTION.value, download_location=None, file_format=FileFormat.GZIP.value):
     self.token = const.TOKEN_BEARER_PREFIX + token if (token and not token.startswith('Bearer')) else token
     self.feed_type = feed_type.lower() if feed_type else FeedType.ITEM.value
     self.feed_scope = feed_scope.upper() if feed_scope else FeedScope.DAILY.value
     self.category_id = category_id
     self.marketplace_id = marketplace_id
     self.environment = environment if environment else Environment.PRODUCTION.value
     self.download_location = download_location if download_location else DEFAULT_DOWNLOAD_LOCATION
     self.file_format = file_format if file_format else FileFormat.GZIP.value
     self.feed_date = feed_date if feed_date else date_utils.get_formatted_date(feed_type)
コード例 #3
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/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)
コード例 #4
0
 def test_get_formatted_date(self):
     today_date = date_utils.get_formatted_date(FeedType.ITEM)
     try:
         datetime.strptime(today_date, '%Y%m%d')
     except ValueError:
         self.fail('Invalid date format: %s' % today_date)