def test_create_document(self): """Test create document""" with self.app.app_context(): inst_doc = Document(self.db_inst.collection) doc = inst_doc.create_document({'_key': 'doc04', 'value': 1}) doc = {'_key': doc['_key'], '_id': doc['_id'], } self.assertDictEqual( doc, {'_key': 'doc04', '_id': 'test_collection_db/doc04', })
def test_create_document(self): """Test get document""" inst_doc = Document(self.db_inst.collection) doc = inst_doc.create_document({'_key': 'doc04', 'value': 1}) doc = {'_key': doc['_key'], '_id': doc['_id'], } self.assertDictEqual( doc, {'_key': 'doc04', '_id': 'test_collection_db/doc04', })
def create_query(data): """Create query in Database""" query = make_query(data) constructor = Constructor() inst_coll = constructor.factory(kind='Collection', name=app.config['META_QUERY']) inst_doc = Document(inst_coll) doc = inst_doc.create_document(query) return doc
def create_meta_collection_doc(data, kind): """Create document in meta_collection""" constructor = Constructor() inst_coll = constructor.factory( kind='Collection', name=config.META_COLLECTION) inst_doc = Document(inst_coll) document = { '_key': data.get('name'), 'name': data.get('name'), 'alias': data.get('alias'), 'kind': kind, 'icon': data.get('icon'), } doc = inst_doc.create_document(document) return doc
def create_meta_graph_doc(data): """Create document in meta_graph""" constructor = Constructor() inst_coll = constructor.factory(kind='Collection', name=app.config['META_GRAPH']) inst_doc = Document(inst_coll) document = { '_key': data.get('name'), 'name': data.get('name'), 'links': data.get('links'), 'alias': data.get('alias'), 'icon': data.get('icon'), 'description': data.get('description'), } doc = inst_doc.create_document(document) return doc
def create_edge(name, data): """Create document-edge in Database""" constructor = Constructor() inst_edge = constructor.factory(kind='Edges', name=name) edge = { '_key': util.make_key(data), '_from': data['from'], '_to': data['to'], 'id': data['id'], 'name': data.get('name', ''), 'provider': data['provider'], 'timestamp': data['timestamp'], 'properties': data.get('properties'), 'properties_metadata': data.get('properties_metadata') } inst_doc = Document(inst_edge) doc = inst_doc.create_document(edge) return doc
def create_document(name, data): """Create document in Database""" constructor = Constructor() inst_coll = constructor.factory(kind='Collection', name=name) document = data document = { '_key': util.make_key(data), 'id': data['id'], 'name': data.get('name', ''), 'provider': data['provider'], 'timestamp': data['timestamp'], 'properties': data.get('properties'), 'properties_metadata': data.get('properties_metadata') } inst_doc = Document(inst_coll) doc = inst_doc.create_document(document) return doc
def create_document(name, data): """Create document in Database""" spec = app.config['SPECS'].get('documents') util.json_validate(spec).validate(data) constructor = Constructor() inst_coll = constructor.factory(kind='Collection', name=name) document = data document = { '_key': util.make_key(data), 'id': data['id'], 'name': data['name'], 'provider': data['provider'], 'timestamp': data['timestamp'], 'properties': data.get('properties'), 'metadata': data.get('metadata') } inst_doc = Document(inst_coll) doc = inst_doc.create_document(document) return doc
def create_edge(name, data): """Create document-edge in Database""" spec = app.config['SPECS'].get('edges') util.json_validate(spec).validate(data) constructor = Constructor() inst_edge = constructor.factory(kind='Edges', name=name) edge = { '_key': util.make_key(data), '_from': data['from'], '_to': data['to'], 'id': data['id'], 'name': data['name'], 'provider': data['provider'], 'timestamp': data['timestamp'], 'properties': data.get('properties'), 'metadata': data.get('metadata') } inst_doc = Document(inst_edge) doc = inst_doc.create_document(edge) return doc