Esempio n. 1
0
 def test_get(self):
     with app.app_context() as context:
         context.push()
         db.session.remove()
         db.drop_all()
         db.create_all()
         self.assertIsNone(User.query.get(1))
         db.session.remove()
Esempio n. 2
0
 def test_get_api(self):
     with app.app_context() as context:
         context.push()
         db.session.remove()
         db.drop_all()
         db.create_all()
         client = app.test_client()
         response = client.get('/api')
         self.assertEqual(response.status_code, 200)
Esempio n. 3
0
 def test_post_new_user(self, mock_post):
     with app.app_context() as context:
         with app.test_request_context('/api', json=card1):
             context.push()
             db.session.remove()
             db.drop_all()
             db.create_all()
             mock_post.return_value = card1
             resp = FirstResourse().post()
             self.assertEqual(resp["email"], card1["email"])
Esempio n. 4
0
 def test_exist(self):
     with app.app_context() as context:
         context.push()
         db.session.remove()
         db.drop_all()
         db.create_all()
         card1.update({"password_hash": set_password(card1['password'])})
         user = UserSchema().make_instance(card1, partial=False)
         db.session.add(user)
         db.session.commit()
         exist = User.query.get(card1["id"])
         self.assertEqual(user.id, exist.id)
         db.session.remove()
Esempio n. 5
0
 def test_post_exist_user(self, mock_post):
     with app.app_context() as context:
         with app.test_request_context('/api', json=card1):
             context.push()
             db.session.remove()
             db.drop_all()
             db.create_all()
             card1.update(
                 {"password_hash": set_password(card1['password'])})
             user = UserSchema().make_instance(card1, partial=False)
             db.session.add(user)
             db.session.commit()
             mock_post.return_value = 'use different email!'
             resp = FirstResourse().post()
             self.assertEqual(resp, 'use different email!')
Esempio n. 6
0
 def test_user_get_card(self, mock_get):
     with app.app_context() as context:
         with app.test_request_context(
                 '/api/users/1/card',
                 headers=dict(Authorization=f"{authent}")):
             context.push()
             db.session.remove()
             db.drop_all()
             db.create_all()
             card1.update(
                 {"password_hash": set_password(card1['password'])})
             user = UserSchema().make_instance(card1, partial=False)
             db.session.add(user)
             db.session.commit()
             mock_get.return_value = make_response(jsonify([patient1]), 200)
             resp = GateCardResourse().get(id=1)
             self.assertEqual(resp.status_code, 200)
Esempio n. 7
0
 def test_post_user(self):
     with app.app_context() as context:
         with app.test_client() as client:
             context.push()
             db.session.remove()
             db.drop_all()
             db.create_all()
             card1.update(
                 {"password_hash": set_password(card1['password'])})
             user = UserSchema().make_instance(card1, partial=False)
             db.session.add(user)
             db.session.commit()
             response = client.get('/api/users/1',
                                   headers=dict(Authorization=f"{authent}"))
             self.assertEqual(response.status_code, 200)
             self.assertEqual(response.json["email"], card1["email"])
             db.session.remove()