Commits

Matt Chaput committed 02557b8

Added wheel to setup.py output.
Added unit tests.

  • Participants
  • Parent commits c6af0c1

Comments (0)

Files changed (4)

+[wheel]
+universal = 1
+
 [build_sphinx]
 build-dir = docs/build
 source-dir = docs/source
 formats = zip,gztar
 
 [aliases]
-push = sdist upload
+push = sdist bdist_wheel upload
 pushdocs = build_sphinx upload_sphinx
 
 [pytest]

tests/test_parsing.py

     qp = default.QueryParser("f", schema)
     _ = qp.parse(u("Dahmen ANDMAYBE @year:[2000 TO]"))
 
+
+def test_quoted_prefix():
+    qp = default.QueryParser("f", None)
+
+    expr = r"(^|(?<=[ (]))(?P<text>\w+|[*]):"
+    qp.replace_plugin(plugins.FieldsPlugin(expr))
+
+    q = qp.parse(u('foo url:http://apple.com:8080/bar* baz'))
+    assert isinstance(q, query.And)
+    assert q[0] == query.Term("f", "foo")
+    assert q[1] == query.Prefix("url", "http://apple.com:8080/bar")
+    assert q[2] == query.Term("f", "baz")
+    assert len(q) == 3

tests/test_results.py

         words = u("foo bar baz qux barney").split()
         with ix.writer() as w:
             for x in xrange(100):
-                t = "even" if x % 2 == 0 else "odd"
+                t = u("even" if x % 2 == 0 else "odd")
                 c = words[x % len(words)]
                 w.add_document(title=t, content=c)
 

tests/test_sorting.py

         r = s.search(q, sortedby="age", reverse=True)
         assert [hit["id"] for hit in r] == [0, 7, 5, 6]
 
+
+def test_compound_sort():
+    fspec = fields.KEYWORD(stored=True, sortable=True)
+    schema = fields.Schema(a=fspec, b=fspec, c=fspec)
+    ix = RamStorage().create_index(schema)
+
+    alist = u("alfa bravo alfa bravo alfa bravo alfa bravo alfa bravo").split()
+    blist = u("alfa bravo charlie alfa bravo charlie alfa bravo charlie alfa").split()
+    clist = u("alfa bravo charlie delta echo foxtrot golf hotel india juliet").split()
+    assert all(len(ls) == 10 for ls in (alist, blist, clist))
+
+    with ix.writer() as w:
+        for i in xrange(10):
+            w.add_document(a=alist[i], b=blist[i], c=clist[i])
+
+    with ix.searcher() as s:
+        q = query.Every()
+        sortedby = [sorting.FieldFacet("a"),
+                    sorting.FieldFacet("b", reverse=True),
+                    sorting.FieldFacet("c")]
+
+        r = s.search(q, sortedby=sortedby)
+        output = []
+        for hit in r:
+            output.append(" ".join((hit["a"], hit["b"], hit["c"])))
+
+        assert output == [
+            "alfa charlie charlie",
+            "alfa charlie india",
+            "alfa bravo echo",
+            "alfa alfa alfa",
+            "alfa alfa golf",
+            "bravo charlie foxtrot",
+            "bravo bravo bravo",
+            "bravo bravo hotel",
+            "bravo alfa delta",
+            "bravo alfa juliet",
+        ]
+