- a length check should come before the access, so you can verify
whether the access will succeed.
- Also removed some tests which can't work, due to the filter
changes. In fact, a lot of these tests should probably be
removed or changed if we want to disallow running
apply_common_filters() on plain dicts. They will often
coincidentally still succeed though, so I left them in.
Timestamp properties can now be checked against filter values
which are either strings or datetime objects, using datetime
semantics (previously, it reduced to a string compare).
If a stix object property is datetime-valued and the filter
value is a string, the string is parsed to a datetime object,
rather than the other way around.
Filtering in the filesystem store now parses JSON dicts to
_STIXBase objects before applying the filters.
Due to the parsing change, bad JSON content can produce a
different kind of error, so I had to change one of the tests.
datastore test suite. Add a new test corpus file, located so
as to test the backward compatibility functionality of
FileSystemSource. Add a test to the suite which ensures that
this new file is found.
test data corpus. Updated filesystem store tests accordingly:
- Remove comments from all_versions tests stating that multiple
versions are not supported. Improve the tests to ensure that
all versions are in fact retrieved.
- Update the get() test to assure that it gets only the latest
version, when there is more than one version.
- Update some count checks, since there are more objects now
- Fix some typos
store:
- Use utils.get_type_from_id() instead of my own (I didn't know it
was already there)
- Use dict-style instead of attribute-style access to get stix
object properties
- Convert timezone-aware timestamps to UTC in _timestamp2filename()
to ensure that different times always result in different
filenames.
Also added a couple new tests for _timestamp2filename(), which
exercises the timezone conversion code.
Factored out the _is_marking() function from the memory datastore
module to utils so it can be reused, and changed both filesystem
and memory datastore modules to import and use it.