def test_compile_large_format_files(self): ''' Test that we can scrape the hyrax server given a reference designator and date ''' # Can't be sure this data will always be here so check the error data = _compile_large_format_files(self.ref_des, self.date_str) # There should be 15 records on this date self.assertEqual(len(data[self.ref_des][self.year][self.month][self.day]), 15)
def test_check_response(self): ''' Test the format of the response. Needs 'url' ''' # Can't be sure this data will always be here so check the error data = _compile_large_format_files(self.ref_des, self.date_str) # Check the content of the first record self.assertIn('url', data[self.ref_des][self.year][self.month][self.day][0])
def compile_large_format_files(): try: with current_app.test_request_context(): print "[+] Starting large format file cache reset..." cache = Cache(config={'CACHE_TYPE': 'redis', 'CACHE_REDIS_DB': 0}) cache.init_app(current_app) data = _compile_large_format_files() if "error" not in data: cache.set('large_format', data, timeout=CACHE_TIMEOUT) print "[+] large format files updated." else: print "[-] Error in large file format update" except Exception as err: message = 'compile_large_format_files exception: %s' % err.message current_app.logger.warning(message)