# Copyright (c) 2008-2009 gocept gmbh & co. kg
# See also LICENSE.txt

import os
import pkg_resources
import unittest
import zeit.cms.testing
import zeit.find.search
import zope.app.testing.functional

product_config = """\
<product-config zeit.solr>
    solr-url file://%s
</product-config>
""" % pkg_resources.resource_filename(__name__, 'testdata')


SearchLayer = zope.app.testing.functional.ZCMLLayer(
    os.path.join(os.path.dirname(__file__), 'ftesting.zcml'),
    __name__, 'SearchLayer', allow_teardown=True,
    product_config=product_config)


class QueryTest(zeit.cms.testing.FunctionalTestCase):

    layer = SearchLayer

    def test_query(self):
        q = zeit.find.search.query('Obama')
        result = zeit.find.search.search(q)
        self.assertEquals(606, result.hits)
        self.assertEquals(
            'http://xml.zeit.de/online/2009/26/obama-tabakgesetz',
            result.docs[0]['uniqueId'])


def test_suite():
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(QueryTest))
    return suite

@@ -267,16 +267,46 @@
 le://%25s%0A
+    public-solr-url file://%25s%0A
 %3C/produc
@@ -321,16 +321,17 @@
 %3E%0A%22%22%22 %25 
+(
 pkg_reso
@@ -375,16 +375,79 @@
 stdata')
+,%0A       pkg_resources.resource_filename(__name__, 'testdata'))
 %0A%0A%0ASearc

add public solr to config