Exemple #1
0
    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")
Exemple #2
0
 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))
Exemple #3
0
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")  
Exemple #4
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])
Exemple #5
0
 def setUp(self):
     self.api = API('')