def test_tx_rollback(self): """ Rollback a transaction. """ docs = Documents(self.connection) docs.set_database("Documents") docs.set_content_type("application/json") docs.set_uri("/path/hello.json") docs.delete() trans = Transactions(self.connection) trans.set_database("Documents") trans.create() txid = trans.txid() docs.set_txid(txid) resp = docs.put({"message": "Hello World"}) assert 201 == resp.status_code trans.rollback() docs.set_txid(None) resp = docs.get() assert 404 == resp.status_code
def test_tx_rollback(self): """ Rollback a transaction. """ conn = Connection(tc.hostname, HTTPDigestAuth(tc.admin, tc.password)) docs = Documents(conn) docs.set_database("Documents") docs.set_content_type("application/json") docs.set_uri("/path/hello.json") docs.delete() trans = Transactions(conn) trans.set_database("Documents") trans.create() txid = trans.txid() docs.set_txid(txid) r = docs.put({"message": "Hello World"}) self.assertEqual(201, r.status_code) trans.rollback() docs.set_txid(None) r = docs.get() self.assertEqual(404, r.status_code)
def test_doc_create_json(self): """ Create a JSON document. """ docs = Documents(self.connection) docs.set_database("Documents") docs.set_content_type("application/json") docs.set_uri("/path/hello.json") docs.delete() resp = docs.put({"message": "Hello World"}) assert 201 == resp.status_code resp = docs.delete() assert 204 == resp.status_code
def test_doc_create_xml(self): """ Create an XML document. """ docs = Documents(self.connection) docs.set_database("Documents") docs.set_content_type("application/xml") docs.set_uri("/path/hello.xml") docs.delete() resp = docs.put("<doc>Hello world!</doc>") assert 201 == resp.status_code resp = docs.delete() assert 204 == resp.status_code
def test_doc_create_json(self): """ Create a JSON document. """ conn = Connection(tc.hostname, HTTPDigestAuth(tc.admin, tc.password)) docs = Documents(conn) docs.set_database("Documents") docs.set_content_type("application/json") docs.set_uri("/path/hello.json") docs.delete() r = docs.put({"message": "Hello World"}) self.assertEqual(201, r.status_code) r = docs.delete() self.assertEqual(204, r.status_code)
def test_doc_create_xml(self): """ Create an XML document. """ conn = Connection(tc.hostname, HTTPDigestAuth(tc.admin, tc.password)) docs = Documents(conn) docs.set_database("Documents") docs.set_content_type("application/xml") docs.set_uri("/path/hello.xml") docs.delete() r = docs.put("<doc>Hello world!</doc>") self.assertEqual(201, r.status_code) r = docs.delete() self.assertEqual(204, r.status_code)