def get_categories(from_cache: bool = False): """ method in charge of getting categories. :param from_cache: indicates if data should be recovered from cache or not :type from_cache: bool """ data = Category.get_api_data_list(from_cache=from_cache) Category.insert_data(data)
def get_categories_data_with_mock(fake_data_path: str, file_name: str): """ Get categories data with mock. :param fake_data_path: :param file_name: :return: """ with open(os.path.join(fake_data_path, '%s.json' % file_name), 'r') as file: fake_data_categories = file.read() with requests_mock.Mocker() as mock: mock.get(Category.get_list_api_url(), text=fake_data_categories) data = Category.get_api_data_list() return data
def get_category_json_test_file(): """ Recover category json test file from OpenfoodFacts """ Category.get_api_data_list(from_cache=False)