示例#1
0
    def setUp(self):
        self._dbconn = qvarn.DatabaseConnection()
        self._dbconn.set_sql(qvarn.SqliteAdapter())

        vs = qvarn.VersionedStorage()
        vs.set_resource_type(self.resource_type)
        vs.start_version(u'first-version', None)
        vs.add_prototype(self.prototype)
        vs.add_prototype(qvarn.listener_prototype, auxtable=u'listener')
        vs.add_prototype(qvarn.notification_prototype,
                         auxtable=u'notification')
        with self._dbconn.transaction() as t:
            vs.prepare_storage(t)

        self.ro = qvarn.ReadOnlyStorage()
        self.ro.set_item_prototype(self.resource_type, self.prototype)

        self.wo = qvarn.WriteOnlyStorage()
        self.wo.set_item_prototype(self.resource_type, self.prototype)

        self.listener = qvarn.ListenerResource()
        self.listener.set_top_resource_path(self.resource_type,
                                            self.resource_type)
        self.listener.prepare_resource(self._dbconn)

        self.resource = qvarn.ListResource()
        self.resource.set_path(self.resource_type)
        self.resource.set_item_type(self.resource_type)
        self.resource.set_item_prototype(self.prototype)
        self.resource.set_listener(self.listener)
        self.resource.prepare_resource(self._dbconn)
示例#2
0
    def setUp(self):
        self.dbconn = qvarn.DatabaseConnection()
        self.dbconn.set_sql(qvarn.SqliteAdapter())

        vs = qvarn.VersionedStorage()
        vs.set_resource_type(self.resource_type)
        vs.start_version(u'1', None)
        vs.add_prototype(self.prototype)
        vs.add_prototype(self.subitem_prototype, subpath=self.subitem_name)
        with self.dbconn.transaction() as t:
            vs.prepare_storage(t)

        self.wo = qvarn.WriteOnlyStorage()
        self.wo.set_item_prototype(self.person[u'type'], self.prototype)
        self.wo.set_subitem_prototype(self.person[u'type'], self.subitem_name,
                                      self.subitem_prototype)

        self.ro = qvarn.ReadOnlyStorage()
        self.ro.set_item_prototype(self.person[u'type'], self.prototype)
        self.ro.set_subitem_prototype(self.person[u'type'], self.subitem_name,
                                      self.subitem_prototype)
示例#3
0
    def setUp(self):
        self._dbconn = qvarn.DatabaseConnection()
        self._dbconn.set_sql(qvarn.SqliteAdapter())

        vs = qvarn.VersionedStorage()
        vs.set_resource_type(self.resource_type)
        vs.start_version(u'first-version')
        vs.add_prototype(self.prototype)
        with self._dbconn.transaction() as t:
            vs.prepare_storage(t)

        self.ro = qvarn.ReadOnlyStorage()
        self.ro.set_item_prototype(self.resource_type, self.prototype)

        self.wo = qvarn.WriteOnlyStorage()
        self.wo.set_item_prototype(self.resource_type, self.prototype)

        self.resource = qvarn.ListResource()
        self.resource.set_path(self.resource_type)
        self.resource.set_item_type(self.resource_type)
        self.resource.set_item_prototype(self.prototype)
        self.resource.set_listener(FakeListenerResource())
        self.resource.prepare_resource(self._dbconn)
示例#4
0
 def _create_resource_ro_storage(self, resource_name, prototype):
     ro = qvarn.ReadOnlyStorage()
     ro.set_item_prototype(resource_name, prototype)
     return ro
示例#5
0
 def _create_ro_storage(self):  # pragma: no cover
     ro = qvarn.ReadOnlyStorage()
     ro.set_item_prototype(self._item_type, self._item_prototype)
     for subitem_name, prototype in self._subitem_prototypes.get_all():
         ro.set_subitem_prototype(self._item_type, subitem_name, prototype)
     return ro