当前位置: 首页>>代码示例>>Python>>正文


Python test_utils.assert_soon函数代码示例

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


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


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