From 665a46e86dd919b3cf66a33ed55d76b580d1baec Mon Sep 17 00:00:00 2001 From: John-Mark Gurney Date: Sun, 2 Jun 2019 23:12:12 -0700 Subject: [PATCH] make genfixtures use ObjectStore so it's like what the cli uses.. --- ui/Makefile | 2 +- ui/fixtures/genfixtures.py | 30 +++++++++++++++++------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/ui/Makefile b/ui/Makefile index 36c3074..de25223 100644 --- a/ui/Makefile +++ b/ui/Makefile @@ -8,4 +8,4 @@ env: pip install -r requirements.txt) fixtures/sample.data.pasn1: fixtures/genfixtures.py - (. ./p/bin/activate && cd fixtures && python genfixtures.py ) + (. ./p/bin/activate && cd fixtures && PYTHONPATH=.. python genfixtures.py ) diff --git a/ui/fixtures/genfixtures.py b/ui/fixtures/genfixtures.py index 7c1fe74..232c925 100644 --- a/ui/fixtures/genfixtures.py +++ b/ui/fixtures/genfixtures.py @@ -1,16 +1,20 @@ import pasn1 +import cli import datetime -open('sample.data.pasn1', 'w').write(pasn1.dumps( -[ - { - 'type': 'metadata', - 'uuid': '3e466e06-45de-4ecc-84ba-2d2a3d970e96', - 'created_by_ref': '867c7563-79ae-435c-a265-9d8509cefac5', - 'modified': datetime.datetime(2019, 5, 31, 14, 5, 3), - 'dc:author': u'John-Mark Gurney', - 'hashes': [ 'sha256:91751cee0a1ab8414400238a761411daa29643ab4b8243e9a91649e25be53ada' ], - 'lang': 'en' - } -] -)) +objst = cli.ObjectStore() +map(objst.loadobj, + [ + { + 'type': 'metadata', + 'uuid': '3e466e06-45de-4ecc-84ba-2d2a3d970e96', + 'created_by_ref': '867c7563-79ae-435c-a265-9d8509cefac5', + 'modified': datetime.datetime(2019, 5, 31, 14, 5, 3), + 'dc:author': u'John-Mark Gurney', + 'hashes': [ 'sha256:91751cee0a1ab8414400238a761411daa29643ab4b8243e9a91649e25be53ada' ], + 'lang': 'en' + } + ] +) + +objst.store('sample.data.pasn1')