本文整理汇总了Python中dictalchemy.tests.Named类的典型用法代码示例。如果您正苦于以下问题:Python Named类的具体用法?Python Named怎么用?Python Named使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Named类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_excluded_pk_with_allow_pk_will_not_be_changed
def test_excluded_pk_with_allow_pk_will_not_be_changed(self):
named = Named('a name')
self.session.add(named)
self.session.commit()
original_id = named.id
named.fromdict({'id': original_id + 1}, allow_pk=True, exclude=['id'])
assert named.id == original_id
示例2: test_dictalchemy_include_doesnt_override_pk
def test_dictalchemy_include_doesnt_override_pk(self):
h = Named('a name')
try:
h.fromdict({'id': 1}, include=['id'])
assert False
except DictalchemyError:
assert True
示例3: test_fromdict_allow_pk
def test_fromdict_allow_pk(self):
s = self.session
named = Named('a name')
s.add(named)
s.commit()
new = {'id': 7}
named.fromdict(new, allow_pk=True)
assert named.asdict() == {'id': new['id'], 'name': named.name}
示例4: test_simple
def test_simple(self):
s = self.session
named = Named('a name')
s.add(named)
s.commit()
new = {'name': 'other name'}
named.fromdict(new)
assert named.asdict() == {'id': named.id, 'name': new['name']}
示例5: test_exluded_pk_will_not_raise_exception
def test_exluded_pk_will_not_raise_exception(self):
named = Named('a name')
self.session.add(named)
self.session.commit()
original_id = named.id
named.fromdict({'id': original_id + 1}, exclude=['id'])
assert named.id == original_id
示例6: test_simple_aborts_on_pk
def test_simple_aborts_on_pk(self):
s = self.session
named = Named('a name')
s.add(named)
s.commit()
new = {'id': 7}
try:
named.fromdict(new)
except:
pass
else:
assert False
示例7: test_named_with_save
def test_named_with_save(self):
named = Named('a name')
self.session.add(named)
self.session.commit()
assert named.asdict() == {'id': named.id, 'name': named.name}
示例8: test_named_without_save
def test_named_without_save(self):
named = Named('a name')
assert named.asdict() == {'id': None, 'name': named.name}
示例9: test_exclude_pk
def test_exclude_pk(self):
named = Named('a name')
self.session.add(named)
self.session.commit()
assert named.asdict(exclude_pk=True) == {'name': named.name}
示例10: test_exclude_flag
def test_exclude_flag(self):
named = Named('a name')
assert named.asdict(exclude=['id']) == {'name': 'a name'}
示例11: test_dict
def test_dict(self):
named = Named('a name')
named.asdict() == dict(named)
示例12: test_only_overrides_exclude
def test_only_overrides_exclude(self):
named = Named('a name')
assert 'name' in dict(named)
assert 'id' in dict(named)
assert 'name' not in named.asdict(only=['id'], exclude=['id'])
assert 'id' not in named.asdict(only=['name'], exclude=['name'])
示例13: test_only
def test_only(self):
named = Named('a name')
assert 'name' in dict(named)
assert 'id' in dict(named)
assert 'name' not in named.asdict(only=['id'])
assert 'id' not in named.asdict(only=['name'])
示例14: test_exclude
def test_exclude(self):
h = Named('a name')
h.fromdict({'name': 'other name'}, exclude=['name'])
assert h.name == 'a name'
示例15: test_only_overrides_exclude
def test_only_overrides_exclude(self):
named = Named('a name')
named.fromdict({'name': 'other name'}, exclude='name', only=['name'])
assert named.name == 'other name'