Fix elasticsearch test

dictionary object was serialized in random key order, fix that by
comparing the deserialized dict directly.
This commit is contained in:
Sida Chen 2019-02-14 11:30:23 -05:00
parent d24127d8ce
commit 2e7725cfa4
2 changed files with 5 additions and 5 deletions

View file

@ -56,8 +56,7 @@ INDEX_REQUEST_2019_01 = [
233, 233,
"datetime": "datetime":
"2019-01-01T03:30:00", "2019-01-01T03:30:00",
"metadata_json": "metadata_json": json.loads("{\"\\ud83d\\ude02\": \"\\ud83d\\ude02\\ud83d\\udc4c\\ud83d\\udc4c\\ud83d\\udc4c\\ud83d\\udc4c\", \"key\": \"value\", \"time\": 1520479800}"),
"{\"\\ud83d\\ude02\": \"\\ud83d\\ude02\\ud83d\\udc4c\\ud83d\\udc4c\\ud83d\\udc4c\\ud83d\\udc4c\", \"key\": \"value\", \"time\": 1520479800}",
"performer_id": "performer_id":
1, 1,
"kind_id": "kind_id":
@ -77,8 +76,7 @@ INDEX_REQUEST_2017_03 = [
233, 233,
"datetime": "datetime":
"2017-03-08T03:30:00", "2017-03-08T03:30:00",
"metadata_json": "metadata_json": json.loads("{\"\\ud83d\\ude02\": \"\\ud83d\\ude02\\ud83d\\udc4c\\ud83d\\udc4c\\ud83d\\udc4c\\ud83d\\udc4c\", \"key\": \"value\", \"time\": 1520479800}"),
"{\"\\ud83d\\ude02\": \"\\ud83d\\ude02\\ud83d\\udc4c\\ud83d\\udc4c\\ud83d\\udc4c\\ud83d\\udc4c\", \"key\": \"value\", \"time\": 1520479800}",
"performer_id": "performer_id":
1, 1,
"kind_id": "kind_id":

View file

@ -143,7 +143,9 @@ def mock_elasticsearch():
@urlmatch(netloc=FAKE_ES_HOST_PATTERN, path=r'/logentry_[0-9\-]*/doc') @urlmatch(netloc=FAKE_ES_HOST_PATTERN, path=r'/logentry_[0-9\-]*/doc')
def index(url, req): def index(url, req):
index = url.path.split('/')[1] index = url.path.split('/')[1]
return mock.index(index, json.loads(req.body)) body = json.loads(req.body)
body['metadata_json'] = json.loads(body['metadata_json'])
return mock.index(index, body)
@urlmatch(netloc=FAKE_ES_HOST_PATTERN, path=r'/logentry_\*/doc/_count') @urlmatch(netloc=FAKE_ES_HOST_PATTERN, path=r'/logentry_\*/doc/_count')
def count(_, req): def count(_, req):