Created
February 28, 2012 08:20
-
-
Save rufuspollock/1930787 to your computer and use it in GitHub Desktop.
CKAN ES Webstore Test Full (Read/Write)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'''This is a test using the real setup with elasticsearch. | |
It requires you to run nginx on port 8088 with config as per | |
https://github.com/okfn/elastic-proxy/blob/master/elasticproxy plus, | |
obviously, elasticsearch on port 9200. | |
''' | |
import json | |
import paste.fixture | |
import paste.proxy | |
app = paste.proxy.Proxy('http://localhost:8088') | |
testapp = paste.fixture.TestApp(app) | |
class TestReadWrite: | |
def test_01(self): | |
resource_id = 'a687ea97-c4d6-4386-b5ac-365744c59662' | |
offset = '/api/rest/resource/%s/data' % resource_id | |
res = testapp.get(offset, status=400) | |
assert res.status == 400 | |
data = { | |
"user": "hamlet", | |
"post_date": "2009-11-15T13:12:00", | |
"message": "Trying out elasticsearch, so far so good?" | |
} | |
data = json.dumps(data) | |
testapp.put(offset + '/1', data) | |
out = testapp.get(offset + '/1') | |
outdata = json.loads(out.body) | |
assert outdata['_source']['user'] == 'hamlet', outdata |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment