diff --git a/README.md b/README.md index 35b3232..efd3f7f 100644 --- a/README.md +++ b/README.md @@ -138,7 +138,12 @@ Should a file system reference point to the blob hash or the uuidv4 of the blog 1. Does a track of a CD deserve it's own "meta data" object? Thinking yes, as the track may be played on radio, etc. And the Album object can point to the tracks. This also helps solve the compilation problem as the artists and other details are easier to represent separately. +# Notes + +The [Dublin Core] standard is also noted by [RFC5013]. + [Dublin Core]: http://dublincore.org/documents/dces/ +[RFC5013]: https://tools.ietf.org/html/rfc5013 [STIX v2.0 Part 1]: http://docs.oasis-open.org/cti/stix/v2.0/cs01/part1-stix-core/stix-v2.0-cs01-part1-stix-core.html # Some thoughts diff --git a/ui/cli.py b/ui/cli.py index f93be6f..b759262 100644 --- a/ui/cli.py +++ b/ui/cli.py @@ -108,6 +108,9 @@ _asn1coder = pasn1.ASN1DictCoder(coerce=_trytodict) class ObjectStore(object): '''A container to store for the various Metadata objects.''' + # The _uuids property contains both the UUIDv4 for objects, and + # looking up the UUIDv5 for FileObjects. + def __init__(self, created_by_ref): self._created_by_ref = created_by_ref self._uuids = {} @@ -373,7 +376,7 @@ class _TestCases(unittest.TestCase): r = byid self.assertEqual(r.uuid, '3e466e06-45de-4ecc-84ba-2d2a3d970e96') - self.assertEqual(r['dc:author'], 'John-Mark Gurney') + self.assertEqual(r['dc:creator'], 'John-Mark Gurney') fname = 'testfile.pasn1' objst.store(fname) @@ -392,9 +395,15 @@ class _TestCases(unittest.TestCase): testfname = os.path.join(self.tempdir, 'test.txt') self.assertEqual(objst.by_file(testfname), [ byid ]) + self.assertEqual(objst.by_file(testfname), [ byid ]) + + self.assertRaises(KeyError, objst.by_file, '/dev/null') # XXX make sure that object store contains fileobject + # Tests to add: + # Non-duplicates when same metadata is located by multiple hashes. + def test_main(self): # Test the main runner, this is only testing things that are # specific to running the program, like where the store is @@ -417,7 +426,7 @@ class _TestCases(unittest.TestCase): [ 'progname', '-l', testfname ])) as (stdout, argv): main() self.assertEqual(stdout.getvalue(), - 'dc:author:\tJohn-Mark Gurney\nhashes:\tsha256:91751cee0a1ab8414400238a761411daa29643ab4b8243e9a91649e25be53ada\nhashes:\tsha512:7d5768d47b6bc27dc4fa7e9732cfa2de506ca262a2749cb108923e5dddffde842bbfee6cb8d692fb43aca0f12946c521cce2633887914ca1f96898478d10ad3f\nlang:\ten\n') + 'dc:creator:\tJohn-Mark Gurney\nhashes:\tsha256:91751cee0a1ab8414400238a761411daa29643ab4b8243e9a91649e25be53ada\nhashes:\tsha512:7d5768d47b6bc27dc4fa7e9732cfa2de506ca262a2749cb108923e5dddffde842bbfee6cb8d692fb43aca0f12946c521cce2633887914ca1f96898478d10ad3f\nlang:\ten\n') eu.assert_called_with('~/.medashare_store.pasn1') if False: # pragma: no cover @@ -425,8 +434,3 @@ class _TestCases(unittest.TestCase): with mock.patch('sys.stdout', StringIO.StringIO()) as ssw: print 'foobar' self.assertEqual(ssw.getvalue(), 'foobar\n') - - -# XXX - how to do created_by for object store? -# store it in the loaded object? -# if so, have to restructure how we handle loading diff --git a/ui/fixtures/genfixtures.py b/ui/fixtures/genfixtures.py index fee8ce2..568a22d 100644 --- a/ui/fixtures/genfixtures.py +++ b/ui/fixtures/genfixtures.py @@ -11,7 +11,7 @@ map(objst.loadobj, 'uuid': '3e466e06-45de-4ecc-84ba-2d2a3d970e96', 'created_by_ref': cbr, 'modified': datetime.datetime(2019, 5, 31, 14, 5, 3), - 'dc:author': u'John-Mark Gurney', + 'dc:creator': u'John-Mark Gurney', 'hashes': [ 'sha256:91751cee0a1ab8414400238a761411daa29643ab4b8243e9a91649e25be53ada', 'sha512:7d5768d47b6bc27dc4fa7e9732cfa2de506ca262a2749cb108923e5dddffde842bbfee6cb8d692fb43aca0f12946c521cce2633887914ca1f96898478d10ad3f' ], 'lang': 'en' }