Browse Source

it's creator, not author, add some comments on tests to add and

private members...  also increase coverage back to 100%, delete
outdated comments..
main
John-Mark Gurney 5 years ago
parent
commit
b19d98a07e
3 changed files with 17 additions and 8 deletions
  1. +5
    -0
      README.md
  2. +11
    -7
      ui/cli.py
  3. +1
    -1
      ui/fixtures/genfixtures.py

+ 5
- 0
README.md View File

@@ -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. 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/ [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 [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 # Some thoughts


+ 11
- 7
ui/cli.py View File

@@ -108,6 +108,9 @@ _asn1coder = pasn1.ASN1DictCoder(coerce=_trytodict)
class ObjectStore(object): class ObjectStore(object):
'''A container to store for the various Metadata objects.''' '''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): def __init__(self, created_by_ref):
self._created_by_ref = created_by_ref self._created_by_ref = created_by_ref
self._uuids = {} self._uuids = {}
@@ -373,7 +376,7 @@ class _TestCases(unittest.TestCase):
r = byid r = byid


self.assertEqual(r.uuid, '3e466e06-45de-4ecc-84ba-2d2a3d970e96') 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' fname = 'testfile.pasn1'
objst.store(fname) objst.store(fname)
@@ -392,9 +395,15 @@ class _TestCases(unittest.TestCase):


testfname = os.path.join(self.tempdir, 'test.txt') testfname = os.path.join(self.tempdir, 'test.txt')
self.assertEqual(objst.by_file(testfname), [ byid ]) 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 # 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): def test_main(self):
# Test the main runner, this is only testing things that are # Test the main runner, this is only testing things that are
# specific to running the program, like where the store is # specific to running the program, like where the store is
@@ -417,7 +426,7 @@ class _TestCases(unittest.TestCase):
[ 'progname', '-l', testfname ])) as (stdout, argv): [ 'progname', '-l', testfname ])) as (stdout, argv):
main() main()
self.assertEqual(stdout.getvalue(), 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') eu.assert_called_with('~/.medashare_store.pasn1')


if False: # pragma: no cover if False: # pragma: no cover
@@ -425,8 +434,3 @@ class _TestCases(unittest.TestCase):
with mock.patch('sys.stdout', StringIO.StringIO()) as ssw: with mock.patch('sys.stdout', StringIO.StringIO()) as ssw:
print 'foobar' print 'foobar'
self.assertEqual(ssw.getvalue(), 'foobar\n') 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

+ 1
- 1
ui/fixtures/genfixtures.py View File

@@ -11,7 +11,7 @@ map(objst.loadobj,
'uuid': '3e466e06-45de-4ecc-84ba-2d2a3d970e96', 'uuid': '3e466e06-45de-4ecc-84ba-2d2a3d970e96',
'created_by_ref': cbr, 'created_by_ref': cbr,
'modified': datetime.datetime(2019, 5, 31, 14, 5, 3), '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' ], 'hashes': [ 'sha256:91751cee0a1ab8414400238a761411daa29643ab4b8243e9a91649e25be53ada', 'sha512:7d5768d47b6bc27dc4fa7e9732cfa2de506ca262a2749cb108923e5dddffde842bbfee6cb8d692fb43aca0f12946c521cce2633887914ca1f96898478d10ad3f' ],
'lang': 'en' 'lang': 'en'
} }


Loading…
Cancel
Save