Beispiel #1
0
 def test_memoization(self):
     self.assertEqual(ModelTestProxy,
                      model_proxy.create_model_proxy(ModelTest))
     self.assertNotEqual(ModelTestProxy,
                         model_proxy.create_model_proxy(ModelTest2))
Beispiel #2
0
 def types(self):
     if self._types is None:
         self._types = (model_proxy.create_model_proxy(
             model_framework.get_model(self._model), ), )
     return self._types
Beispiel #3
0
    def method(self):
        return 1


@mf.construct_nb_db_model
class ModelTest2(mf.ModelBase):
    topic = fields.StringField()


@mf.construct_nb_db_model
class RefferingModel(mf.ModelBase):
    model_test = df_fields.ReferenceField(ModelTest)
    other_field = fields.StringField()


ModelTestProxy = model_proxy.create_model_proxy(ModelTest)


class TestObjectProxy(tests_base.BaseTestCase):
    def setUp(self):
        super(TestObjectProxy, self).setUp()
        self.db_store = mock.MagicMock()
        self.get_inst_mock = mock.patch(
            'dragonflow.db.db_store.get_instance',
            return_value=self.db_store
        )
        self.addCleanup(self.get_inst_mock.stop)
        self.get_inst_mock.start()

    def test_proxied_objects_equal(self):
        obj1 = RefferingModel(id="id",