Esempio n. 1
0
def create_context(json_data=dict(),
                   params=dict(),
                   headers=dict(),
                   form=dict(),
                   files=dict()):
    ctx = QRContext(json_data,
                    params,
                    headers,
                    form,
                    files,
                    repository=MockSearchRepository())
    ctx.add_manager(MockTokenManager.get_name(), MockTokenManager())
    return ctx
Esempio n. 2
0
 def test_failure(self):
     token = MockTokenManager().make_token(user_id=2)
     res = register_event(
         create_context(headers={'Authorization': token},
                        json_data={
                            'time': 12345,
                            'event': 'a'
                        }))
     self.assertEqual(500, res.status_code)
Esempio n. 3
0
 def test_failed_to_update(self):
     token = MockTokenManager().make_token(user_id=2)
     res = update_user(
         create_context(form={
             'login': '******',
             'password': '******'
         },
                        headers={'Authorization': token}))
     self.assertEqual(500, res.status_code)
Esempio n. 4
0
 def test_login_not_exists(self):
     token = MockTokenManager().make_token(user_id=1)
     res = update_user(
         create_context(form={
             'login': '******',
             'password': '******'
         },
                        headers={'Authorization': token}))
     self.assertEqual(500, res.status_code)
Esempio n. 5
0
 def test_success(self):
     token = MockTokenManager().make_token(user_id=1)
     res = update_user(
         create_context(form={
             'login': '******',
             'password': '******',
             'name': 'c'
         },
                        headers={'Authorization': token}))
     self.assertEqual(200, res.status_code)
Esempio n. 6
0
 def test_all_data(self):
     token = MockTokenManager().make_token(user_id=1)
     res = register_event(
         create_context(headers={'Authorization': token},
                        json_data={
                            'time': 12345,
                            'event': 'a',
                            'data': {
                                'a': 'a',
                                'b': 'b'
                            }
                        }))
     self.assertEqual(200, res.status_code)
Esempio n. 7
0
 def test_success(self):
     token = MockTokenManager().make_token(user_id=1)
     res = user_info(create_context(headers={'Authorization': token}))
     self.assertEqual(200, res.status_code)
     self.assertEqual(
         {
             'id': 1,
             'name': 'a',
             'last_name': 'a',
             'avatar': None,
             'email': '*****@*****.**',
             'login': '******'
         }, res.result)
Esempio n. 8
0
 def test_success(self):
     token = MockTokenManager().make_token(user_id=1)
     res = get_book(create_context(headers={'Authorization': token}), 'a')
     self.assertEqual(200, res.status_code)
     self.assertEqual('a', res.result)
Esempio n. 9
0
 def test_failure(self):
     token = MockTokenManager().make_token(user_id=1)
     res = get_avatar(create_context(headers={'Authorization': token}),
                      'xxx')
     self.assertEqual('file not found', res.result)
Esempio n. 10
0
 def test_failure(self):
     token = MockTokenManager().make_token(user_id=2)
     res = delete_profile(create_context(headers={'Authorization': token}))
     self.assertEqual(500, res.status_code)
Esempio n. 11
0
 def test_not_found(self):
     token = MockTokenManager().make_token(user_id=2)
     res = user_info(create_context(headers={'Authorization': token}))
     self.assertEqual(500, res.status_code)
     self.assertNotEqual(res.result.find('not found'), -1)