def test_create_account(self, test_client, app):
     test_client.post("/register",
                      data=dict(firstname="Test",
                                lastname="User",
                                username="******",
                                email="*****@*****.**",
                                password="******",
                                confirm_password="******"))
     with app.app_context():
         user = User.query.filter_by(username="******").first()
         assert user is not None
 def test_correct_login(self, test_client):
     test_client.post("/register",
                      data=dict(firstname="Test",
                                lastname="User",
                                username="******",
                                email="*****@*****.**",
                                password="******",
                                confirm_password="******"))
     result = test_client.post("/login",
                               data=dict(username="******",
                                         password="******"))
     assert result.status_code == 302
Beispiel #3
0
    def test_upload_image(self, test_client, app):
        # upload an image, make sure its in temp
        with app.app_context():

            f = FileStorage(
                filename="radiology_assistant/tests/sample_xray.jpg",
                stream=open("radiology_assistant/tests/sample_xray.jpg", "rb"),
                content_type="image/jpeg")
            test_client.post("/",
                             data=dict(image=f),
                             content_type="multipart/form-data")
            assert len(
                os.listdir(
                    os.path.join(current_app.root_path,
                                 current_app.static_folder, "images",
                                 "temp"))) != 0
 def test_create_existing_account(self, test_client):
     test_client.post("/register",
                      data=dict(firstname="Test",
                                lastname="User",
                                username="******",
                                email="*****@*****.**",
                                password="******",
                                confirm_password="******"))
     result = test_client.post("/register",
                               data=dict(firstname="Test",
                                         lastname="User",
                                         username="******",
                                         email="*****@*****.**",
                                         password="******",
                                         confirm_password="******"))
     # Status code 200 means user wasn't redirected which means error logging in
     assert result.status_code == 200
    def test_existing_search(self, test_client, app):
        test_client.post("/register",
                         data=dict(firstname="Test",
                                   lastname="User",
                                   username="******",
                                   email="*****@*****.**",
                                   password="******",
                                   confirm_password="******"))
        with app.app_context():
            user = User.query.filter_by(username="******").first()
            c = Case(image="xray1.jpg",
                     patient="Test Patient",
                     details="Test Details",
                     user_id=user.id)
            d = Disease(case=c, name="Test")
            db.session.add(c)
            db.session.add(d)
            db.session.commit()

        result = test_client.get("/search", query_string=dict(query="Test"))
        assert "No Results found" not in str(result.data)
 def test_duplicate_removal(self, test_client, app):
     test_client.post("/register",
                      data=dict(firstname="Test",
                                lastname="User",
                                username="******",
                                email="*****@*****.**",
                                password="******",
                                confirm_password="******"))
     with app.app_context():
         user = User.query.filter_by(username="******").first()
         shutil.copy2(
             "radiology_assistant/tests/sample_xray.jpg",
             os.path.join(current_app.root_path, current_app.static_folder,
                          "images", "xrays", "xray1.jpg"))
         shutil.copy2(
             "radiology_assistant/tests/sample_xray.jpg",
             os.path.join(current_app.root_path, current_app.static_folder,
                          "images", "xrays", "xray2.jpg"))
         c1 = Case(image="xray1.jpg",
                   patient="Test Patient",
                   details="Test Details",
                   user_id=user.id)
         c2 = Case(image="xray2.jpg",
                   patient="Test Patient 2",
                   details="Test Details 2",
                   user_id=user.id)
         db.session.add(c1)
         db.session.add(c2)
         db.session.commit()
         delete_duplicates()
         assert (os.path.exists(
             os.path.join(
                 current_app.root_path, current_app.static_folder, "images",
                 "xrays", "xray1.jpg"))) and (not os.path.exists(
                     os.path.join(current_app.root_path,
                                  current_app.static_folder, "images",
                                  "xrays", "xray2.jpg")))
 def test_incorrect_login(self, test_client):
     result = test_client.post("/login",
                               data=dict(username="******",
                                         password="******"))
     assert result.status_code == 200