예제 #1
0
	def test_delete_doc(self):
		server = FrappeClient(get_url(), "Administrator", "admin", verify=False)
		frappe.db.delete("Note", {"title": "delete"})
		frappe.db.commit()

		server.insert_many([
			{"doctype": "Note", "public": True, "title": "delete"},
		])
		server.delete("Note", "delete")

		self.assertFalse(frappe.db.get_value('Note', {'title': 'delete'}))
예제 #2
0
class FrappeConnection(BaseConnection):
    def __init__(self, connector):
        self.connector = connector
        self.connection = FrappeClient(self.connector.hostname,
                                       self.connector.username,
                                       self.get_password())
        self.name_field = 'name'

    def insert(self, doctype, doc):
        doc = frappe._dict(doc)
        doc.doctype = doctype
        return self.connection.insert(doc)

    def update(self, doctype, doc, migration_id):
        doc = frappe._dict(doc)
        doc.doctype = doctype
        doc.name = migration_id
        return self.connection.update(doc)

    def delete(self, doctype, migration_id):
        return self.connection.delete(doctype, migration_id)

    def get(self,
            doctype,
            fields='"*"',
            filters=None,
            start=0,
            page_length=20,
            parent=None):
        return self.connection.get_list(doctype,
                                        fields=fields,
                                        filters=filters,
                                        limit_start=start,
                                        limit_page_length=page_length,
                                        parent=parent)
예제 #3
0
    def test_delete_doc(self):
        server = FrappeClient(frappe.get_site_config().host_name,
                              "Administrator",
                              "admin",
                              verify=False)
        frappe.db.sql('delete from `tabNote` where title = "delete"')
        frappe.db.commit()

        server.insert_many([
            {
                "doctype": "Note",
                "public": True,
                "title": "delete"
            },
        ])
        server.delete("Note", "delete")

        self.assertFalse(frappe.db.get_value('Note', {'title': 'delete'}))
예제 #4
0
class FrappeConnection(BaseConnection):
	def __init__(self, connector):
		self.connector = connector
		self.connection = FrappeClient(self.connector.hostname,
			self.connector.username, self.get_password())
		self.name_field = 'name'

	def insert(self, doctype, doc):
		doc = frappe._dict(doc)
		doc.doctype = doctype
		return self.connection.insert(doc)

	def update(self, doctype, doc, migration_id):
		doc = frappe._dict(doc)
		doc.doctype = doctype
		doc.name = migration_id
		return self.connection.update(doc)

	def delete(self, doctype, migration_id):
		return self.connection.delete(doctype, migration_id)

	def get(self, doctype, fields='"*"', filters=None, start=0, page_length=20):
		return self.connection.get_list(doctype, fields=fields, filters=filters,
				limit_start=start, limit_page_length=page_length)