Created
April 5, 2021 17:45
-
-
Save Verina-Armanyous/335338bf557a4c92de584d5ab1b8f69d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import psycopg2 | |
import os | |
import tempfile | |
import pytest | |
from flaskr import flaskr | |
con = psycopg2.connect(database="postgres", user="cs162_user", | |
password="cs162_password", host="127.0.0.1", port="1234") | |
print("Database opened successfully") | |
cur = con.cursor() | |
cur.execute("SELECT id, text, value, now from Expression") | |
rows = cur.fetchall() | |
for row in rows: | |
print("id =", row[0]) | |
print("text =", row[1]) | |
print("value =", row[2]) | |
print("now =", row[3], "\n") | |
print("Operation done successfully") | |
con.close() | |
def test_valid_expression(): | |
# Create a test client using the Flask application configured for testing | |
with flask_app.test_client() as test_client: | |
response = test_client.post('http://localhost:5000/add', input="2+2") | |
assert response.status_code == 200 | |
def test_invalid_expression(): | |
# Create a test client using the Flask application configured for testing | |
with flask_app.test_client() as test_client: | |
response = test_client.post('http://localhost:5000/add', input="i+h") | |
assert response.status_code != 200 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment