Drop *doc_or_id* polymorphism from MetaStore API (use *doc* only)
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Dmedia |
Fix Released
|
High
|
Jason Gerard DeRose |
Bug Description
Originally the MetaStore API was conceived as wrapping the FileStore API plus adding in the corresponding meta-data updates. So this made sense:
FileStore.
But then I realized that when Dmedia calls something like MetaStore.verify(), you've typically already retrieved the doc, so I changed all such methods to take a *doc_or_id* argument, which could be the doc (a `dict`) if you've already retrieved it, or could be the _id (an `str`), in which case the doc would be retrieved for you:
MetaStore.
The big problem with this is the combinatorial explosion: if all these methods can take either a doc or an _id, then you really need to unit test each scenario. MetaStore involves complex, scary, data critical operations that often require highly complex unit tests, so 2x the complexity just for the fun of it is not something we want here.
As most often you'll already have the doc, I'm proposing that we rework all such methods to *only* take the doc, eg:
MetaStore.
This new approach has a nice bonus too: the MetaStore unit tests don't have to account for NotFound being raised when trying to retrieve the doc. Less complexity, moar better.
No doubt MetaStore will still have 99 problems, but polymorphism wont be one :P
Related branches
- David Jordan: Approve
-
Diff: 738 lines (+282/-249)3 files modifieddmedia/client.py (+3/-2)
dmedia/metastore.py (+19/-16)
dmedia/tests/test_metastore.py (+260/-231)
description: | updated |
description: | updated |
Changed in dmedia: | |
assignee: | nobody → Jason Gerard DeRose (jderose) |
status: | Triaged → In Progress |
Changed in dmedia: | |
status: | In Progress → Fix Committed |
Changed in dmedia: | |
status: | Fix Committed → Fix Released |