def runTest(self): access_token = self.account.oauth(APP_ID, PERMISSIONS) self.assertNotEqual(access_token, None) self.assertNotEqual(access_token, '') api = API(access_token) self.assertEqual(api.isAppUser(), "1")
def form_valid(self, form): api = API() id_list = form.cleaned_data['id_list'] student_id_regex = form.cleaned_data['student_id_regex'] new_id_list = api.process_id_list(id_list, student_id_regex) data = form.data.copy() data['id_list'] = new_id_list form.data = data return self.render_to_response(self.get_context_data(form=form))
class APITest(unittest.TestCase): ''' Тестирование работоспособности класса для работы с API ''' def setUp(self): self.api = API('') def runTest(self): answer = self.api.getProfiles(uids='durov,andrew') self.assertEqual(answer[0]['uid'], 1) self.assertEqual(answer[1]['uid'], 6492) self.assertEqual(self.api.isAppUser(), "0")
def handle_uploaded_file(file: File, output_format): api = API() with NamedTemporaryFile(suffix='.pdf', mode='wb') as pdf_file, \ NamedTemporaryFile(suffix='.csv', mode='r') as csv_file: # Convert PDF to CSV for chunk in file.chunks(): pdf_file.write(chunk) convert_into(pdf_file.name, csv_file.name, spreadsheet=True, pages='all', output_format='csv') # Process sheet = pyexcel.get_sheet(file_name=csv_file.name) sheet.name = 'Output' api.process_spreadsheet(sheet) # Output file return django_excel.make_response(sheet, output_format, file_name=path.splitext( path.basename(file.name))[0])
def setUp(self): self.api = API('')