Adding FileUpload control and updated related components
This commit is contained in:
@@ -106,6 +106,52 @@ def test_i_can_init_from_db_with_dataclass(session, db_manager):
|
||||
assert dummy.number == 34
|
||||
|
||||
|
||||
def test_i_do_not_save_when_prefixed_by_underscore_or_ns(session, db_manager):
|
||||
class DummyObject(DbObject):
|
||||
def __init__(self, sess: dict):
|
||||
super().__init__(sess, "DummyObject", db_manager)
|
||||
|
||||
with self.initializing():
|
||||
self.to_save: str = "value"
|
||||
self._not_to_save: str = "value"
|
||||
self.ns_not_to_save: str = "value"
|
||||
|
||||
to_save: str = "value"
|
||||
_not_to_save: str = "value"
|
||||
ns_not_to_save: str = "value"
|
||||
|
||||
dummy = DummyObject(session)
|
||||
dummy.to_save = "other_value"
|
||||
dummy.ns_not_to_save = "other_value"
|
||||
dummy._not_to_save = "other_value"
|
||||
|
||||
in_db = db_manager.load("DummyObject")
|
||||
assert in_db["to_save"] == "other_value"
|
||||
assert "_not_to_save" not in in_db
|
||||
assert "ns_not_to_save" not in in_db
|
||||
|
||||
|
||||
def test_i_do_not_save_when_prefixed_by_underscore_or_ns_with_dataclass(session, db_manager):
|
||||
@dataclass
|
||||
class DummyObject(DbObject):
|
||||
def __init__(self, sess: dict):
|
||||
super().__init__(sess, "DummyObject", db_manager)
|
||||
|
||||
to_save: str = "value"
|
||||
_not_to_save: str = "value"
|
||||
ns_not_to_save: str = "value"
|
||||
|
||||
dummy = DummyObject(session)
|
||||
dummy.to_save = "other_value"
|
||||
dummy.ns_not_to_save = "other_value"
|
||||
dummy._not_to_save = "other_value"
|
||||
|
||||
in_db = db_manager.load("DummyObject")
|
||||
assert in_db["to_save"] == "other_value"
|
||||
assert "_not_to_save" not in in_db
|
||||
assert "ns_not_to_save" not in in_db
|
||||
|
||||
|
||||
def test_db_is_updated_when_attribute_is_modified(session, db_manager):
|
||||
@dataclass
|
||||
class DummyObject(DbObject):
|
||||
|
||||
Reference in New Issue
Block a user