Skip to content

Commit 22b4de0

Browse files
committed
Add test for ReadOnly
1 parent c517f07 commit 22b4de0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tests.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from unittest import TestCase
66

77
from postgres import Postgres, TooFew, TooMany
8+
from postgres.orm import ReadOnly
89
from psycopg2.extras import RealDictCursor
910
from psycopg2 import InterfaceError, ProgrammingError
1011

@@ -250,6 +251,12 @@ def test_updating_attributes_works(self):
250251
bar = self.db.one("SELECT bar FROM foo WHERE bar='blah'")
251252
assert bar == one.bar
252253

254+
def test_attributes_are_read_only(self):
255+
one = self.db.one("SELECT foo.*::foo FROM foo WHERE bar='baz'")
256+
def assign():
257+
one.bar = "blah"
258+
self.assertRaises(ReadOnly, assign)
259+
253260

254261
# cursor_factory
255262
# ==============

0 commit comments

Comments
 (0)