def check_export_apis(self): try: self.export_api_format_list except AttributeError: pass else: print('\nTesting export apis of ' + self.export_api) successful = True client = get_super_client() for format in self.export_api_format_list: kwargs = {} kwargs['format'] = format try: self.export_api_kwargs['pk'] except KeyError: pass else: kwargs['pk'] = self.export_api_kwargs['pk'] url = reverse(self.export_api, kwargs=kwargs) response = client.get(url) if response.status_code == 200: print('Successful request '.ljust(22) + url.ljust(30) + str(response.status_code)) else: print('Failed request '.ljust(22) + url.ljust(30) + str(response.status_code)) successful = False self.assertEqual(successful, True)
def check_export_apis(self): try: self.export_api_format_list except AttributeError: pass else: logger.debug('Testing export apis of %s', self.export_api) successful = True client = get_super_client() for format in self.export_api_format_list: kwargs = {} kwargs['format'] = format try: self.export_api_kwargs['pk'] except KeyError: pass else: kwargs['pk'] = self.export_api_kwargs['pk'] url = reverse(self.export_api, kwargs=kwargs) response = client.get(url) if response.status_code == 200: logger.debug('Successful request %s %s', url, response.status_code) else: logger.debug('Failed request %s %s', url, response.status_code) successful = False self.assertEqual(successful, True)
def assert_export_data(self): if self.compare_import_to_export_data is True: logger.debug('Comparing import to export for %s', self.export_api) client = get_super_client() response = client.get(reverse(self.export_api, kwargs=self.export_api_kwargs)) exported_xml_data = sanitize_xml(response.content) imported_xml_data = read_xml_file(self.import_file) successful = fuzzy_compare(imported_xml_data, exported_xml_data, self.compare_import_to_export_ignore_list) if successful is False: self.assertFalse('Export data differ from import data') if successful is True: logger.debug('Compare successful') else: logger.debug('Compare failed')