Skip to content

Commit

Permalink
sqla_proxy test fix -must past in **obj not obj itself to MetriqueObject
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Ward committed Jul 1, 2014
1 parent cd54d9f commit 4a2dc28
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion metrique/core_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
from metrique.utils import utcnow, jsonhash, load, autoschema
from metrique.utils import batch_gen, dt2ts, configure, to_encoding
from metrique.utils import is_empty, is_true, is_null, is_array, is_defined
from metrique import parse

ETC_DIR = os.environ.get('METRIQUE_ETC')
CACHE_DIR = os.environ.get('METRIQUE_CACHE') or '/tmp'
Expand All @@ -59,7 +58,9 @@ class MetriqueObject(MutableMapping):

def __init__(self, _oid, _id=None, _hash=None, _start=None, _end=None,
_e=None, _v=None, id=None, _schema=None, **kwargs):
print _oid, '*'*1000
is_defined(_oid, "_oid must be defined!")
print 'Z'*100
# NOTE: we completely ignore incoming 'id' keys!
# id is RESERVED and ALWAYS expected to be 'autoincrement'
# upon insertion into DB (though, its optional, depending
Expand Down
13 changes: 12 additions & 1 deletion tests/test_sqla_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,24 @@ def db_tester(proxy):

assert p.ls() == []

# must pass _oid as kwarg
obj = {'col_1': 1, 'col_3': _date}
try:
O({'col_1': 1, 'col_3': _date})
O(**obj)
except TypeError:
pass
else:
assert False

# _oid can't be null
obj = {'_oid': None, 'col_1': 1, 'col_3': _date}
try:
O(**obj)
except RuntimeError:
pass
else:
assert False

_obj_1 = {'_oid': 1, 'col_1': 1, 'col_3': _date}
obj_1 = [O(**_obj_1)]

Expand Down

0 comments on commit 4a2dc28

Please sign in to comment.