Пример #1
0
    def test_import_single(self):
        structure = {
            "person:id" : dict(_id = "person:id", seq = 11),
            "account:id" : dict(_id = "account:id", seq = 33)
        }
        data = json.dumps(structure)
        data = appier.legacy.bytes(data)

        adapter = appier.get_adapter()
        manager = appier.ExportManager(
            adapter,
            multiple = self.app.resolve()
        )

        collection = adapter.collection("counter")
        manager._import_single(collection, data, key = "_id")

        values = collection.find()
        values = [value for value in values]

        self.assertEqual(type(values), list)
        self.assertEqual(len(values), 2)

        value = collection.find_one(dict(_id = "person:id"))

        self.assertEqual(value["seq"], 11)
Пример #2
0
    def test_import_single(self):
        structure = {
            "person:id": dict(_id="person:id", seq=11),
            "account:id": dict(_id="account:id", seq=33)
        }
        data = json.dumps(structure)
        data = appier.legacy.bytes(data)

        adapter = appier.get_adapter()
        manager = appier.ExportManager(adapter, multiple=self.app.resolve())

        collection = adapter.collection("counter")
        manager._import_single(collection, data, key="_id")

        values = collection.find()
        values = [value for value in values]

        self.assertEqual(type(values), list)
        self.assertEqual(len(values), 2)

        value = collection.find_one(dict(_id="person:id"))

        self.assertEqual(value["seq"], 11)
Пример #3
0
    def test_import_multiple(self):
        data = [("person:id",
                 appier.legacy.bytes(json.dumps(dict(_id="person:id", seq=11)),
                                     encoding="utf-8")),
                ("account:id",
                 appier.legacy.bytes(json.dumps(dict(_id="account:id",
                                                     seq=33)),
                                     encoding="utf-8"))]

        adapter = appier.get_adapter()
        manager = appier.ExportManager(adapter, multiple=self.app.resolve())

        collection = adapter.collection("counter")
        manager._import_multiple(collection, data, key="_id")

        values = collection.find()
        values = [value for value in values]

        self.assertEqual(type(values), list)
        self.assertEqual(len(values), 2)

        value = collection.find_one(dict(_id="person:id"))

        self.assertEqual(value["seq"], 11)
Пример #4
0
    def test_import_multiple(self):
        data = [
            (
                "person:id",
                appier.legacy.bytes(
                    json.dumps(dict(_id = "person:id", seq = 11)),
                    encoding = "utf-8"
                )
            ),
            (
                "account:id",
                appier.legacy.bytes(
                    json.dumps(dict(_id = "account:id", seq = 33)),
                    encoding = "utf-8"
                )
            )
        ]

        adapter = appier.get_adapter()
        manager = appier.ExportManager(
            adapter,
            multiple = self.app.resolve()
        )

        collection = adapter.collection("counter")
        manager._import_multiple(collection, data, key = "_id")

        values = collection.find()
        values = [value for value in values]

        self.assertEqual(type(values), list)
        self.assertEqual(len(values), 2)

        value = collection.find_one(dict(_id = "person:id"))

        self.assertEqual(value["seq"], 11)
Пример #5
0
 def tearDown(self):
     self.app.unload()
     adapter = appier.get_adapter()
     adapter.drop_db()
Пример #6
0
 def tearDown(self):
     self.app.unload()
     adapter = appier.get_adapter()
     adapter.drop_db()