Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- case_obj = get_or_create_model('UnlockCase', {'client': client_obj,
- 'client2': client_obj,
- 'address': address_obj,
- 'state': 'TestState'})
- def get_or_create_model():
- def _get_or_create_model(modelname: str, data: dict):
- model_cls = getattr(models, modelname, None)
- if model_cls:
- model = model_cls.get(**data)
- if not model:
- model = model_cls(**data)
- commit()
- return model
- else:
- raise AttributeError('This model does not exists')
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- def test_get_user_ok(self, login, get_or_create_model, generate_address_model):
- email = 't@t.t'
- client_obj = get_or_create_model('Client', {'email': email,
- 'first_name': 'fn',
- 'last_name': 'ln'})
- address_obj = generate_address_model('full_addr', '12345', 'city', 'state')
- > case_obj = get_or_create_model('UnlockCase', {'client': client_obj,
- 'client2': client_obj,
- 'address': address_obj,
- 'state': 'TestState'})
- test_api/test_user.py:11:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- conftest.py:40: in _get_or_create_model
- model = model_cls.get(**data)
- ../../.venv/lib/python3.8/site-packages/pony/orm/core.py:4001: in get
- try: return entity._find_one_(kwargs) # can throw MultipleObjectsFoundError
- ../../.venv/lib/python3.8/site-packages/pony/orm/core.py:4104: in _find_one_
- if obj is None: obj = entity._find_in_db_(avdict, unique, for_update, nowait, skip_locked)
- ../../.venv/lib/python3.8/site-packages/pony/orm/core.py:4160: in _find_in_db_
- sql, adapter, attr_offsets = entity._construct_sql_(query_attrs, False, limit, for_update, nowait, skip_locked)
- ../../.venv/lib/python3.8/site-packages/pony/orm/core.py:4260: in _construct_sql_
- elif not attr.columns: throw(NotImplementedError)
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- exc_type = <class 'NotImplementedError'>, args = (), kwargs = {}
- def throw(exc_type, *args, **kwargs):
- if isinstance(exc_type, Exception):
- assert not args and not kwargs
- exc = exc_type
- else: exc = exc_type(*args, **kwargs)
- exc.__cause__ = None
- try:
- if not (pony.MODE == 'INTERACTIVE' and options.CUT_TRACEBACK):
- > raise exc
- E NotImplementedError
- ../../.venv/lib/python3.8/site-packages/pony/utils/utils.py:106: NotImplementedError
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement