Skip to content

Commit 47555af

Browse files
committed
Specify own behaviours
Problem: For testing internally one needs to be able to specify behaviours explicitly without encouraging users to do so. Solution: Insert default behaviours into props argument when creating asset such that any specified on the argument list take precedence. Signed-off-by: Paul Hewlett <phewlett76@gmail.com>
1 parent af9d2a8 commit 47555af

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

archivist/assets.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,10 @@ def create(
141141
142142
"""
143143
LOGGER.debug("Create Asset %s", attrs)
144-
data = self.__query(props, attrs)
145-
data["behaviours"] = BEHAVIOURS
144+
# default behaviours are added first - any set in user-specified fixtures or
145+
# in the method args will overide...
146+
newprops = _deepmerge({"behaviours": BEHAVIOURS}, props)
147+
data = self.__query(newprops, attrs)
146148
return self.create_from_data(data, confirm=confirm)
147149

148150
def create_from_data(self, data: Dict, *, confirm: bool = False) -> Asset:

unittests/testassets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@
7676
"storage_integrity": StorageIntegrity.TENANT_STORAGE.name,
7777
}
7878
REQUEST = {
79+
"behaviours": BEHAVIOURS,
7980
"storage_integrity": StorageIntegrity.TENANT_STORAGE.name,
8081
"attributes": ATTRS,
81-
"behaviours": BEHAVIOURS,
8282
}
8383
REQUEST_DATA = json.dumps(REQUEST)
8484

0 commit comments

Comments
 (0)