def test_mixed_query(self):
        self.assertRaises(ArgumentError,
                          self.cb.query,
                          "d",
                          "v",
                          query=Query(),
                          limit=10)

        self.cb.query("d", "v", query=Query(limit=5).update(skip=15))
Beispiel #2
0
    def test_mixed_query(self):
        self.assertRaises(InvalidArgumentException,
                          self.cb.query,
                          "d",
                          "v",
                          query=Query(),
                          limit=10)

        self.cb.query("d", "v", query=Query(limit=5).update(skip=15))
    def test_key_query(self):
        q = Query()
        q.mapkey_single = ["abbaye_de_maredsous"]
        ret = self.cb.query("beer", "brewery_beers", query=q)
        rows = list(ret)
        self.assertEqual(len(rows), 1)

        q.mapkey_single = UNSPEC
        q.mapkey_multi = [["abbaye_de_maredsous"],
                          ["abbaye_de_maredsous", "abbaye_de_maredsous-8"]]
        ret = self.cb.query("beer", "brewery_beers", query=q)
        rows = list(ret)
        self.assertEqual(len(rows), 2)
    def test_row_processor(self):
        rp = BreweryBeerRowProcessor()
        q = Query(limit=20)

        ret = self.cb.query("beer",
                            "brewery_beers",
                            query=q,
                            row_processor=rp,
                            include_docs=True)

        beers = list(ret)
        for b in beers:
            self.assertIsInstance(b, Beer)
            self.assertIsInstance(b.brewery, Brewery)

        ret = self.cb.query("beer",
                            "brewery_beers",
                            query=q,
                            row_processor=rp,
                            include_docs=False)

        list(ret)

        ret = self.cb.query("beer",
                            "brewery_beers",
                            row_processor=rp,
                            include_docs=False,
                            limit=40)

        self.assertRaises(ValueError, list, ret)
Beispiel #5
0
    def _assert_vopteq_multi(self, d, key, value):
        q = Query(**{key: value})
        enc = q.encoded
        res = {}
        for kvp in enc.split("&"):
            k, v = kvp.split("=")
            res[k] = v

        d = d.copy()
        for k in d:
            d[k] = ulp.quote(d[k])

        self.assertEqual(res, d)
    def test_long_uri(self):
        qobj = Query()
        qobj.mapkey_multi = [str(x) for x in xrange(MAX_URI_LENGTH)]
        ret = self.cb.query("beer", "brewery_beers", query=qobj)
        # No assertions, just make sure it didn't break
        for row in ret:
            raise Exception("...")

        # Apparently only the "keys" parameter is supposed to be in POST.
        # Let's fetch 100 items now
        keys = [
            r.key for r in self.cb.query("beer", "brewery_beers", limit=100)
        ]
        self.assertEqual(100, len(keys))

        kslice = keys[90:]
        self.assertEqual(10, len(kslice))
        rows = [
            x for x in self.cb.query(
                "beer", "brewery_beers", mapkey_multi=kslice, limit=5)
        ]
        self.assertEqual(5, len(rows))
        for row in rows:
            self.assertTrue(row.key in kslice)
    def test_range_query(self):
        q = Query()

        q.mapkey_range = [["abbaye_de_maredsous"],
                          ["abbaye_de_maredsous", Query.STRING_RANGE_END]]

        q.inclusive_end = True

        ret = self.cb.query("beer", "brewery_beers", query=q)
        rows = list(ret)
        self.assertEqual(len(rows), 4)

        q.mapkey_range = [["u"], ["v"]]
        ret = self.cb.query("beer", "brewery_beers", query=q)
        self.assertEqual(len(list(ret)), 88)

        q.mapkey_range = [["u"], ["uppper" + Query.STRING_RANGE_END]]
        ret = self.cb.query("beer", "brewery_beers", query=q)
        rows = list(ret)
        self.assertEqual(len(rows), 56)
 def test_http_data_streaming(self):
     q = Query(limit=30, debug=True)
     self._verify_data(
         self.cb.query("beer", "brewery_beers", streaming=True, query=q))