|
| 1 | +# Copyright 2016 Google Inc. All Rights Reserved. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
1 | 15 | from google.appengine.api import search |
2 | 16 | import pytest |
3 | | -import time |
| 17 | + |
4 | 18 |
|
5 | 19 | @pytest.fixture |
6 | 20 | def index(): |
7 | | - index = search.Index(name='simple-index', namespace='') |
8 | | - doc = search.Document(doc_id='test_id', fields=[ |
9 | | - search.TextField(name='body', value='hello world'), |
10 | | - ]) |
11 | | - index.put(doc) |
12 | | - return index |
| 21 | + index = search.Index(name='simple-index', namespace='') |
| 22 | + doc = search.Document( |
| 23 | + doc_id='test_id', |
| 24 | + fields=[ |
| 25 | + search.TextField( |
| 26 | + name='body', |
| 27 | + value='hello world'), |
| 28 | + ]) |
| 29 | + index.put(doc) |
| 30 | + return index |
13 | 31 |
|
14 | 32 |
|
15 | 33 | def test_basic_search(index): |
16 | | - resp = index.search('hello') |
17 | | - assert len(resp.results) == 1 |
18 | | - result = resp.results[0] |
19 | | - assert result.doc_id == 'test_id' |
20 | | - assert result.language == 'en' |
21 | | - assert result.fields[0].value == 'hello world' |
22 | | - assert result.fields[0].name == 'body' |
| 34 | + resp = index.search('hello') |
| 35 | + assert len(resp.results) == 1 |
| 36 | + result = resp.results[0] |
| 37 | + assert result.doc_id == 'test_id' |
| 38 | + assert result.language == 'en' |
| 39 | + assert result.fields[0].value == 'hello world' |
| 40 | + assert result.fields[0].name == 'body' |
0 commit comments