Drop *doc_or_id* polymorphism from MetaStore API (use *doc* only)

Bug #1252104 reported by Jason Gerard DeRose
6
This bug affects 1 person
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.verify(_id) => MetaStore.verify(fs, _id)

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.verify(fs, doc_or_id)

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.verify(fs, doc)

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

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
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.