Skip to content

Instantly share code, notes, and snippets.

@Verina-Armanyous
Created April 5, 2021 17:45
Show Gist options
  • Save Verina-Armanyous/335338bf557a4c92de584d5ab1b8f69d to your computer and use it in GitHub Desktop.
Save Verina-Armanyous/335338bf557a4c92de584d5ab1b8f69d to your computer and use it in GitHub Desktop.
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