def test_spell_with_login_post(): app = Flask(__name__, template_folder='../src/templates') app.secret_key = "CS9163Assignment02WebsiteFlaskSessionSecretKeyForPytestOnly" configure_routes(app) app.config["TESTING"] = True app.config["DEBUG"] = False app.config["WTF_CSRF_ENABLED"] = False client = app.test_client() form = RegisterForm( username="******", password="******", phone="testnumber" ) url = ROOT_URL + "/register" response = client.post(url, data=form.data) url = ROOT_URL + "/login" response = client.post(url, data={"uname": "testusername", "pword": "testpassword", "2fa": "testnumber"}, follow_redirects=True) url = ROOT_URL + "/spell_check" text2check = "Take a sad sogn and make it better. Remember to let her under your (skyn),.! then you b3gin to make it betta." response = client.post(url, data={"inputtext": text2check}) assert response.status_code == 200 assert b"textout" in response.data assert b"misspelled" in response.data
def test_login_with_correct_data_post(): app = Flask(__name__, template_folder='../src/templates') app.secret_key = "CS9163Assignment02WebsiteFlaskSessionSecretKeyForPytestOnly" app.WTF_CSRF_SECRET_KEY = "CS9163Assignment02WebsiteFlaskWTFCSRFToken" configure_routes(app) app.testing = True csrf = CSRFProtect(app) client = app.test_client() url = ROOT_URL + "/register" response = client.post(url, data={ "uname": "testusername", "pword": "testpassword", "2fa": "testnumber" }) url = ROOT_URL + "/login" response = client.post(url, data={ "uname": "testusername", "pword": "testpassword", "2fa": "testnumber" }, follow_redirects=True) assert response.status_code == 200 assert b"Login" in response.data assert b"Login success" in response.data
def create_app(self): app = Flask(__name__, template_folder="../src/templates/") app.secret_key = "CS9163Assignment02WebsiteFlaskSessionSecretKeyForPytestOnly" configure_routes(app) app.config["TESTING"] = True app.config["DEBUG"] = False app.config["WTF_CSRF_ENABLED"] = False return app
def test_spell_get(): app = Flask(__name__, template_folder='../src/templates') app.secret_key = "CS9163Assignment02WebsiteFlaskSessionSecretKeyForPytestOnly" app.WTF_CSRF_SECRET_KEY = "CS9163Assignment02WebsiteFlaskWTFCSRFToken" app.testing = True configure_routes(app) csrf = CSRFProtect(app) client = app.test_client() url = ROOT_URL + "/spell_check" response = client.get(url, follow_redirects=True) assert response.status_code == 200 assert b"Register" in response.data assert b"uname" in response.data assert b"pword" in response.data assert b"2fa" in response.data