Skip to content

Commit

Permalink
Add PostgreSQL tests for SQLAlchemy2 refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
catileptic committed Jul 17, 2023
1 parent 5c2dc8d commit 109e35d
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions test/test_sqlalchemy_refactoring.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import unittest
from datetime import datetime

from dataset import connect

from .sample_data import TEST_DATA

POSTGRES_URL = ""


class SQLAlchemyTestCasePostgreSQL(unittest.TestCase):
def setUp(self):
self.db = connect(POSTGRES_URL)
self.tbl = self.db["weather"]
for row in TEST_DATA:
self.tbl.insert(row)

def tearDown(self):
# self.tbl.drop()
pass

def test_insert(self):
last_id = self.tbl.insert(
{"date": datetime(2011, 1, 2), "temperature": -10, "place": "Berlin"}
)

assert self.tbl.find_one(id=last_id)["place"] == "Berlin"

def test_insert_and_change_schema(self):
last_id = self.tbl.insert(
{"date": datetime(2022, 3, 4), "temperature": 22, "place": "Brașov"}
)

assert self.tbl.find_one(id=last_id)["place"] == "Brașov"

last_id = self.tbl.insert(
{"date": datetime(2022, 3, 4), "temperature": 22, "place": "Brașov", "feels_like": 20}
)

# assert self.tbl.find_one(id=last_id)["feels_like"] == 20

0 comments on commit 109e35d

Please sign in to comment.