home
·
contact
·
privacy
projects
/
plomtask
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove and shrink tests under redundancy with test utils defaults.
[plomtask]
/
plomtask
/
versioned_attributes.py
diff --git
a/plomtask/versioned_attributes.py
b/plomtask/versioned_attributes.py
index cbd1c8e348a9230b10176d55b4b6a490fe11ff33..8861c9834ff3924d6459ced5cb9c69629424bb45 100644
(file)
--- a/
plomtask/versioned_attributes.py
+++ b/
plomtask/versioned_attributes.py
@@
-4,7
+4,8
@@
from typing import Any
from sqlite3 import Row
from time import sleep
from plomtask.db import DatabaseConnection
from sqlite3 import Row
from time import sleep
from plomtask.db import DatabaseConnection
-from plomtask.exceptions import HandledException, BadFormatException
+from plomtask.exceptions import (HandledException, BadFormatException,
+ NotFoundException)
TIMESTAMP_FMT = '%Y-%m-%d %H:%M:%S.%f'
TIMESTAMP_FMT = '%Y-%m-%d %H:%M:%S.%f'
@@
-98,6
+99,8
@@
class VersionedAttribute:
def save(self, db_conn: DatabaseConnection) -> None:
"""Save as self.history entries, but first wipe old ones."""
def save(self, db_conn: DatabaseConnection) -> None:
"""Save as self.history entries, but first wipe old ones."""
+ if self.parent.id_ is None:
+ raise NotFoundException('cannot save attribute to parent if no ID')
db_conn.rewrite_relations(self.table_name, 'parent', self.parent.id_,
[[item[0], item[1]]
for item in self.history.items()])
db_conn.rewrite_relations(self.table_name, 'parent', self.parent.id_,
[[item[0], item[1]]
for item in self.history.items()])