Python oslo_db.sqlalchemy.models.ModelBase() Examples
The following are 5
code examples of oslo_db.sqlalchemy.models.ModelBase().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
oslo_db.sqlalchemy.models
, or try the search function
.
Example #1
Source File: test_async_eventlet.py From oslo.db with Apache License 2.0 | 6 votes |
def setUp(self): super(EventletTestMixin, self).setUp() BASE = sa_decl.declarative_base() class TmpTable(BASE, models.ModelBase): __tablename__ = 'test_async_eventlet' id = sa.Column('id', sa.Integer, primary_key=True, nullable=False) foo = sa.Column('foo', sa.Integer) __table_args__ = ( sa.UniqueConstraint('foo', name='uniq_foo'), ) self.test_table = TmpTable TmpTable.__table__.create(self.engine) self.addCleanup(lambda: TmpTable.__table__.drop(self.engine))
Example #2
Source File: test_models.py From oslo.db with Apache License 2.0 | 5 votes |
def setUp(self): super(ModelBaseTest, self).setUp() self.mb = models.ModelBase() self.ekm = ExtraKeysModel()
Example #3
Source File: test_models.py From oslo.db with Apache License 2.0 | 5 votes |
def test_modelbase_has_dict_methods(self): dict_methods = ('__getitem__', '__setitem__', '__contains__', 'get', 'update', 'save', 'items', 'iteritems', 'keys') for method in dict_methods: self.assertTrue(hasattr(models.ModelBase, method), "Method %s() is not found" % method)
Example #4
Source File: test_models.py From oslo.db with Apache License 2.0 | 5 votes |
def test_modelbase_is_iterable(self): self.assertTrue(issubclass(models.ModelBase, abc.Iterable))
Example #5
Source File: test_models.py From oslo.db with Apache License 2.0 | 5 votes |
def test_modelbase_contains(self): mb = models.ModelBase() h = {'a': '1', 'b': '2'} mb.update(h) for key in h.keys(): # Test 'in' syntax (instead of using .assertIn) self.assertIn(key, mb) self.assertNotIn('non-existent-key', mb)