-
-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add PostgreSQL tests for SQLAlchemy2 refactoring
- Loading branch information
1 parent
5c2dc8d
commit 109e35d
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
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 |