• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python test_utils.assert_soon函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mongo_connector.test_utils.assert_soon函数的典型用法代码示例。如果您正苦于以下问题:Python assert_soon函数的具体用法?Python assert_soon怎么用?Python assert_soon使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了assert_soon函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_remove

 def test_remove(self):
     """Tests remove
     """
     self.conn['test']['test'].insert_one({'name': 'paulie'})
     assert_soon(lambda: sum(1 for _ in self.solr_conn.search("*:*")) == 1)
     self.conn['test']['test'].delete_one({'name': 'paulie'})
     assert_soon(lambda: sum(1 for _ in self.solr_conn.search("*:*")) == 0)
开发者ID:boxrice007,项目名称:mongo-connector,代码行数:7,代码来源:test_solr.py


示例2: test_many_targets

    def test_many_targets(self):
        """Test that one OplogThread is capable of replicating to more than
        one target.
        """
        doc_managers = [DocManager(), DocManager(), DocManager()]
        self.opman.doc_managers = doc_managers

        # start replicating
        self.opman.start()
        self.primary_conn["test"]["test"].insert_one(
            {"name": "kermit", "color": "green"}
        )
        self.primary_conn["test"]["test"].insert_one(
            {"name": "elmo", "color": "firetruck red"}
        )

        assert_soon(
            lambda: sum(len(d._search()) for d in doc_managers) == 6,
            "OplogThread should be able to replicate to multiple targets",
        )

        self.primary_conn["test"]["test"].delete_one({"name": "elmo"})

        assert_soon(
            lambda: sum(len(d._search()) for d in doc_managers) == 3,
            "OplogThread should be able to replicate to multiple targets",
        )
        for d in doc_managers:
            self.assertEqual(d._search()[0]["name"], "kermit")
开发者ID:mongodb-labs,项目名称:mongo-connector,代码行数:29,代码来源:test_oplog_manager.py


示例3: test_create_collection

 def test_create_collection(self):
     self.initOplogThread()
     pymongo.collection.Collection(
         self.primary_conn['test'], 'test', create=True)
     assert_soon(lambda: self.docman.commands)
     command = self.docman.commands[0]
     self.assertEqual(command['create'], 'test')
开发者ID:cn3c3p,项目名称:mongo-connector,代码行数:7,代码来源:test_command_replication.py


示例4: test_filter_fields

    def test_filter_fields(self):
        docman = self.opman.doc_managers[0]
        conn = self.opman.primary_client

        include_fields = ["a", "b", "c"]
        exclude_fields = ["d", "e", "f"]

        # Set fields to care about
        self.opman.fields = include_fields
        # Documents have more than just these fields
        doc = {
            "a": 1, "b": 2, "c": 3,
            "d": 4, "e": 5, "f": 6,
            "_id": 1
        }
        db = conn['test']['test']
        db.insert_one(doc)
        assert_soon(lambda: db.count() == 1)
        self.opman.dump_collection()

        result = docman._search()[0]
        keys = result.keys()
        for inc, exc in zip(include_fields, exclude_fields):
            self.assertIn(inc, keys)
            self.assertNotIn(exc, keys)
开发者ID:sliwinski-milosz,项目名称:mongo-connector,代码行数:25,代码来源:test_filter_fields.py


示例5: test_skipped_oplog_entry_updates_checkpoint

    def test_skipped_oplog_entry_updates_checkpoint(self):
        repl_set = ReplicaSetSingle().start()
        conn = repl_set.client()
        opman = OplogThread(
            primary_client=conn,
            doc_managers=(DocManager(),),
            oplog_progress_dict=LockingDict(),
            namespace_config=NamespaceConfig(namespace_set=["test.test"]),
        )
        opman.start()

        # Insert a document into an included collection
        conn["test"]["test"].insert_one({"test": 1})
        last_ts = opman.get_last_oplog_timestamp()
        assert_soon(
            lambda: last_ts == opman.checkpoint,
            "OplogThread never updated checkpoint to non-skipped " "entry.",
        )
        self.assertEqual(len(opman.doc_managers[0]._search()), 1)

        # Make sure that the oplog thread updates its checkpoint on every
        # oplog entry.
        conn["test"]["ignored"].insert_one({"test": 1})
        last_ts = opman.get_last_oplog_timestamp()
        assert_soon(
            lambda: last_ts == opman.checkpoint,
            "OplogThread never updated checkpoint to skipped entry.",
        )
        opman.join()
        conn.close()
        repl_set.stop()
开发者ID:mongodb-labs,项目名称:mongo-connector,代码行数:31,代码来源:test_oplog_manager.py


示例6: check_renamed_insert

 def check_renamed_insert(self, target_coll):
     target_db, target_coll = target_coll.split('.', 1)
     mongo_target = self.mongo_conn[target_db][target_coll]
     assert_soon(lambda: len(list(mongo_target.find({}))))
     target_docs = list(mongo_target.find({}))
     self.assertEqual(len(target_docs), 1)
     self.assertEqual(target_docs[0]["renamed"], 1)
开发者ID:nly,项目名称:mongo-connector,代码行数:7,代码来源:test_mongo.py


示例7: test_remove

 def test_remove(self):
     """Tests remove operations."""
     self.conn['test']['test'].insert_one({'name': 'paulie'})
     assert_soon(lambda: self._count() == 1)
     self.conn['test']['test'].delete_one({'name': 'paulie'})
     assert_soon(lambda: self._count() != 1)
     self.assertEqual(self._count(), 0)
开发者ID:sudheerit11,项目名称:elastic2-doc-manager,代码行数:7,代码来源:test_elastic2.py


示例8: test_drop_collection

 def test_drop_collection(self):
     self.initOplogThread()
     coll = pymongo.collection.Collection(
         self.primary_conn['test'], 'test', create=True)
     coll.drop()
     assert_soon(lambda: len(self.docman.commands) == 2)
     self.assertEqual(self.docman.commands[1], {'drop': 'test'})
开发者ID:cn3c3p,项目名称:mongo-connector,代码行数:7,代码来源:test_command_replication.py


示例9: test_drop_database

 def test_drop_database(self):
     self.initOplogThread()
     pymongo.collection.Collection(
         self.primary_conn['test'], 'test', create=True)
     self.primary_conn.drop_database('test')
     assert_soon(lambda: len(self.docman.commands) == 2)
     self.assertEqual(self.docman.commands[1], {'dropDatabase': 1})
开发者ID:cn3c3p,项目名称:mongo-connector,代码行数:7,代码来源:test_command_replication.py


示例10: test_connector_minimum_privileges

    def test_connector_minimum_privileges(self):
        """Test the Connector works with a user with minimum privileges."""
        if not (db_user and db_password):
            raise SkipTest("Need to set a user/password to test this.")
        client = self.repl_set.client()
        minimum_user = "read_local_and_included_databases"
        minimum_pwd = "password"
        client.admin.add_user(
            minimum_user,
            minimum_pwd,
            roles=[
                {"role": "read", "db": "test"},
                {"role": "read", "db": "wildcard"},
                {"role": "read", "db": "local"},
            ],
        )

        client.test.test.insert_one({"replicated": 1})
        client.test.ignored.insert_one({"replicated": 0})
        client.ignored.ignored.insert_one({"replicated": 0})
        client.wildcard.test.insert_one({"replicated": 1})
        conn = Connector(
            mongo_address=self.repl_set.primary.uri,
            auth_username=minimum_user,
            auth_key=minimum_pwd,
            namespace_options={"test.test": True, "wildcard.*": True},
        )
        conn.start()
        try:
            assert_soon(conn.doc_managers[0]._search)
        finally:
            conn.join()
开发者ID:mongodb-labs,项目名称:mongo-connector,代码行数:32,代码来源:test_mongo_connector.py


示例11: test_drop_collection

 def test_drop_collection(self):
     self.initOplogThread()
     coll = pymongo.collection.Collection(
         self.primary_conn["test"], "test", create=True
     )
     coll.drop()
     assert_soon(lambda: len(self.docman.commands) == 2)
     self.assertEqual(self.docman.commands[1], {"drop": "test"})
开发者ID:mongodb-labs,项目名称:mongo-connector,代码行数:8,代码来源:test_command_replication.py


示例12: test_remove_file

 def test_remove_file(self):
     """Tests removing a gridfs file
     """
     fs = GridFS(self.conn['test'], 'test')
     id = fs.put("test file", filename="test.txt", encoding='utf8')
     assert_soon(lambda: sum(1 for _ in self.solr_conn.search("*:*")) == 1)
     fs.delete(id)
     assert_soon(lambda: sum(1 for _ in self.solr_conn.search("*:*")) == 0)
开发者ID:boxrice007,项目名称:mongo-connector,代码行数:8,代码来源:test_solr.py


示例13: test_drop_database_renamed

 def test_drop_database_renamed(self):
     """Test the dropDatabase command on a renamed database."""
     self.create_renamed_collection("rename.me", "new.target")
     self.create_renamed_collection("rename.me2", "new2.target2")
     # test that drop database removes target databases
     self.conn.drop_database("rename")
     assert_soon(lambda: "new" not in self.mongo_conn.database_names())
     assert_soon(lambda: "new2" not in self.mongo_conn.database_names())
开发者ID:nly,项目名称:mongo-connector,代码行数:8,代码来源:test_mongo.py


示例14: test_bad_int_value

 def test_bad_int_value(self):
     self.conn.test.test.insert_one({
         'inf': float('inf'), 'nan': float('nan'),
         'still_exists': True})
     assert_soon(lambda: self._count() > 0)
     for doc in self._search():
         self.assertNotIn('inf', doc)
         self.assertNotIn('nan', doc)
         self.assertTrue(doc['still_exists'])
开发者ID:sudheerit11,项目名称:elastic2-doc-manager,代码行数:9,代码来源:test_elastic2.py


示例15: test_bad_int_value

 def test_bad_int_value(self):
     self.conn.test.test.insert_one(
         {"inf": float("inf"), "nan": float("nan"), "still_exists": True}
     )
     assert_soon(lambda: self._count() > 0)
     for doc in self._search():
         self.assertNotIn("inf", doc)
         self.assertNotIn("nan", doc)
         self.assertTrue(doc["still_exists"])
开发者ID:mongodb-labs,项目名称:elastic2-doc-manager,代码行数:9,代码来源:test_elastic2.py


示例16: test_rename_collection_renamed

 def test_rename_collection_renamed(self):
     """Test the renameCollection command on a renamed collection to a
     renamed collection.
     """
     self.create_renamed_collection("rename.me", "new.target")
     self.conn.admin.command("renameCollection", "rename.me", to="rename.me2")
     # In the target, 'new.target' should be renamed to 'new2.target2'
     assert_soon(lambda: "target" not in self.mongo_conn.new.collection_names())
     self.check_renamed_insert("new2.target2")
开发者ID:mongodb-labs,项目名称:mongo-connector,代码行数:9,代码来源:test_mongo.py


示例17: test_drop_collection_renamed

 def test_drop_collection_renamed(self):
     """Test the drop collection command on a renamed collection."""
     self.create_renamed_collection("rename.me", "new.target")
     self.create_renamed_collection("rename.me2", "new2.target2")
     # test that drop collection removes target collection
     self.conn.rename.drop_collection("me")
     assert_soon(lambda: "target" not in self.mongo_conn.new.collection_names())
     self.conn.rename.drop_collection("me2")
     assert_soon(lambda: "target2" not in self.mongo_conn.new2.collection_names())
开发者ID:mongodb-labs,项目名称:mongo-connector,代码行数:9,代码来源:test_mongo.py


示例18: check_update

 def check_update(update_spec):
     updated = self.conn.test.command(
         SON([('findAndModify', 'test'),
              ('query', {"a": 0}),
              ('update', update_spec),
              ('new', True)]))['value']
     # Stringify _id to match what will be retrieved from ES
     updated['_id'] = str(updated['_id'])
     assert_soon(lambda: next(self._search()) == updated)
开发者ID:sudheerit11,项目名称:elastic2-doc-manager,代码行数:9,代码来源:test_elastic2.py


示例19: test_rename_collection

 def test_rename_collection(self):
     self.initOplogThread()
     coll = pymongo.collection.Collection(
         self.primary_conn["test"], "test", create=True
     )
     coll.rename("test2")
     assert_soon(lambda: len(self.docman.commands) == 2)
     self.assertEqual(self.docman.commands[1].get("renameCollection"), "test.test")
     self.assertEqual(self.docman.commands[1].get("to"), "test.test2")
开发者ID:mongodb-labs,项目名称:mongo-connector,代码行数:9,代码来源:test_command_replication.py


示例20: test_remove

    def test_remove(self):
        """Tests remove
        """

        self.conn['test']['test'].insert_one({'name': 'paulie'})
        assert_soon(lambda: sum(1 for _ in self._search()) == 1)
        self.conn['test']['test'].delete_one({'name': 'paulie'})
        assert_soon(lambda: sum(1 for _ in self._search()) != 1)
        self.assertEqual(sum(1 for _ in self._search()), 0)
开发者ID:sliwinski-milosz,项目名称:mongo-connector,代码行数:9,代码来源:test_mongo.py



注:本文中的mongo_connector.test_utils.assert_soon函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.bson_ts_to_long函数代码示例发布时间:2022-05-27
下一篇:
Python oplog_manager.OplogThread类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap