本文整理汇总了Python中keywords.MobileRestClient.MobileRestClient.delete_doc方法的典型用法代码示例。如果您正苦于以下问题:Python MobileRestClient.delete_doc方法的具体用法?Python MobileRestClient.delete_doc怎么用?Python MobileRestClient.delete_doc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类keywords.MobileRestClient.MobileRestClient
的用法示例。
在下文中一共展示了MobileRestClient.delete_doc方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_auto_prune_listener_keeps_conflicts_sanity
# 需要导入模块: from keywords.MobileRestClient import MobileRestClient [as 别名]
# 或者: from keywords.MobileRestClient.MobileRestClient import delete_doc [as 别名]
def test_auto_prune_listener_keeps_conflicts_sanity(setup_client_syncgateway_test):
""""
1. Create db on LiteServ and add docs
2. Create db on sync_gateway and add docs with the same id
3. Create one shot push / pull replication
4. Update LiteServ 50 times
5. Assert that pruned conflict is still present
6. Delete the current revision and check that a GET returns the old conflict as the current rev
"""
cluster_config = setup_client_syncgateway_test["cluster_config"]
ls_url = setup_client_syncgateway_test["ls_url"]
sg_url = setup_client_syncgateway_test["sg_url"]
sg_admin_url = setup_client_syncgateway_test["sg_admin_url"]
client = MobileRestClient()
sg_helper = SyncGateway()
sg_helper.start_sync_gateway(
cluster_config=cluster_config, url=sg_url, config="{}/walrus.json".format(SYNC_GATEWAY_CONFIGS)
)
log_info("Running 'test_auto_prune_listener_keeps_conflicts_sanity' ...")
log_info("ls_url: {}".format(ls_url))
log_info("sg_url: {}".format(sg_url))
log_info("sg_admin_url: {}".format(sg_admin_url))
num_docs = 1
num_revs = 100
sg_db = "db"
ls_db = "ls_db"
sg_user_name = "sg_user"
sg_user_channels = ["NBC"]
client.create_user(url=sg_admin_url, db=sg_db, name=sg_user_name, password="password", channels=sg_user_channels)
sg_session = client.create_session(url=sg_admin_url, db=sg_db, name=sg_user_name)
ls_db = client.create_database(url=ls_url, name=ls_db)
# Create docs with same prefix to create conflicts when the dbs complete 1 shot replication
ls_db_docs = client.add_docs(url=ls_url, db=ls_db, number=num_docs, id_prefix="doc", channels=sg_user_channels)
assert len(ls_db_docs) == num_docs
sg_db_docs = client.add_docs(
url=sg_url, db=sg_db, number=num_docs, id_prefix="doc", channels=sg_user_channels, auth=sg_session
)
assert len(sg_db_docs) == num_docs
# Setup one shot pull replication and wait for idle.
client.start_replication(url=ls_url, continuous=False, from_url=sg_admin_url, from_db=sg_db, to_db=ls_db)
client.wait_for_no_replications(url=ls_url)
# There should now be a conflict on the client
conflicting_revs = client.get_conflict_revs(url=ls_url, db=ls_db, doc=ls_db_docs[0])
# Get the doc with conflict rev
client.get_doc(url=ls_url, db=ls_db, doc_id=ls_db_docs[0]["id"], rev=conflicting_revs[0])
# Update doc past revs limit and make sure conflict is still available
updated_doc = client.update_doc(url=ls_url, db=ls_db, doc_id=ls_db_docs[0]["id"], number_updates=num_revs)
client.get_doc(url=ls_url, db=ls_db, doc_id=ls_db_docs[0]["id"], rev=conflicting_revs[0])
# Delete doc and ensure that the conflict is now the current rev
client.delete_doc(url=ls_url, db=ls_db, doc_id=ls_db_docs[0]["id"], rev=updated_doc["rev"])
current_doc = client.get_doc(url=ls_url, db=ls_db, doc_id=ls_db_docs[0]["id"])
assert current_doc["_rev"] == conflicting_revs[0]
示例2: test_non_winning_revisions
# 需要导入模块: from keywords.MobileRestClient import MobileRestClient [as 别名]
# 或者: from keywords.MobileRestClient.MobileRestClient import delete_doc [as 别名]
#.........这里部分代码省略.........
seth_user_info = userinfo.UserInfo(
name="seth",
password="pass",
channels=["NATGEO"],
roles=[]
)
seth_auth = client.create_user(
url=sg_admin_url,
db=sg_db,
name=seth_user_info.name,
password=seth_user_info.password,
channels=seth_user_info.channels
)
test_doc_body = document.create_doc(doc_id="test_doc", channels=seth_user_info.channels)
rev_gen_1_doc = client.add_doc(url=sg_url, db=sg_db, doc=test_doc_body, auth=seth_auth)
rev_gen_6_doc = client.update_doc(url=sg_url, db=sg_db, doc_id=rev_gen_1_doc["id"], number_updates=5, auth=seth_auth)
assert rev_gen_6_doc["rev"].startswith("6-")
# Get changes until rev generation 6 document shows up
start = time.time()
last_seq = 0
while True:
if time.time() - start > keywords.constants.CLIENT_REQUEST_TIMEOUT:
raise keywords.exceptions.TimeoutError("Wait for Replication Status Idle: TIMEOUT")
changes_1 = client.get_changes(url=sg_url, db=sg_db, since=last_seq, auth=seth_auth, skip_user_docs=True)
last_seq = changes_1["last_seq"]
# break when expected rev shows up in changes feed
if changes_1["results"] and changes_1["results"][0]["changes"][0]["rev"].startswith("6-"):
break
assert len(changes_1["results"]) == 1
assert changes_1["results"][0]["id"] == "test_doc"
assert changes_1["results"][0]["changes"][0]["rev"].startswith("6-")
# Create a conflict off of rev one
rev_gen_2_doc_conflict = client.add_conflict(
url=sg_url,
db=sg_db,
doc_id=rev_gen_1_doc["id"],
parent_revisions=rev_gen_1_doc["rev"],
new_revision="2-foo",
auth=seth_auth
)
assert rev_gen_2_doc_conflict["id"] == "test_doc"
assert rev_gen_2_doc_conflict["rev"] == "2-foo"
# Issue changes since changes_1 last_seq above
changes_2 = client.get_changes(url=sg_url, db=sg_db, since=changes_1["last_seq"], auth=seth_auth)
assert len(changes_2["results"]) == 1
assert changes_2["results"][0]["id"] == "test_doc"
assert changes_2["results"][0]["changes"][0]["rev"].startswith("6-")
# Issue changes since 0, strip user doc and make sure the doc is still the '6-' rev
changes_from_0_one = client.get_changes(url=sg_url, db=sg_db, since=0, auth=seth_auth, skip_user_docs=True)
assert len(changes_from_0_one["results"]) == 1
assert changes_from_0_one["results"][0]["id"] == "test_doc"
assert changes_from_0_one["results"][0]["changes"][0]["rev"].startswith("6-")
# Create a 3-foo rev with 2-foo as the parent
rev_gen_3_doc_conflict = client.add_conflict(
url=sg_url,
db=sg_db,
doc_id=rev_gen_2_doc_conflict["id"],
parent_revisions=rev_gen_2_doc_conflict["rev"],
new_revision="3-foo",
auth=seth_auth
)
assert rev_gen_3_doc_conflict["id"] == "test_doc"
assert rev_gen_3_doc_conflict["rev"] == "3-foo"
# Issue changes since changes_2 last_seq above
changes_3 = client.get_changes(url=sg_url, db=sg_db, since=changes_2["last_seq"], auth=seth_auth)
assert len(changes_3["results"]) == 1
assert changes_3["results"][0]["id"] == "test_doc"
assert changes_3["results"][0]["changes"][0]["rev"].startswith("6-")
# Issue changes since 0, strip user doc and make sure the doc is still the '6-' rev
changes_from_0_two = client.get_changes(url=sg_url, db=sg_db, since=0, auth=seth_auth, skip_user_docs=True)
assert len(changes_from_0_two["results"]) == 1
assert changes_from_0_two["results"][0]["id"] == "test_doc"
assert changes_from_0_two["results"][0]["changes"][0]["rev"].startswith("6-")
# Delete test_doc at rev 6-*
client.delete_doc(url=sg_url, db=sg_db, doc_id=rev_gen_6_doc["id"], rev=rev_gen_6_doc["rev"], auth=seth_auth)
# Issue changes since changes_3 last_seq above
changes_4 = client.get_changes(url=sg_url, db=sg_db, since=changes_3["last_seq"], auth=seth_auth)
assert len(changes_4["results"]) == 1
assert changes_4["results"][0]["id"] == "test_doc"
assert changes_4["results"][0]["changes"][0]["rev"] == "3-foo"
# Issue a oneshot changes since changes_4 last_seq and assert no results are returned
changes_5 = client.get_changes(url=sg_url, db=sg_db, since=changes_4["last_seq"], feed="normal", auth=seth_auth)
assert len(changes_5["results"]) == 0