Beit-Hatfutsot / dbs-back

The MoJP RESTfull API server
GNU Affero General Public License v3.0
1 stars 4 forks source link

[Task] research + fix failing tests due to merge of PR #182 (person places param search) #183

Closed OriHoch closed 7 years ago

OriHoch commented 7 years ago

@Libisch - tests are failing, probably because some tests didn't run locally for you

you should try to run all tests locally then, you can also setup codeship for your dbs-back fork - that way it will run on every push you make to one of your branches

I think the failure is due to having the additional persons in the mock ElasticSearch

============================= test session starts ==============================
platform linux2 -- Python 2.7.13, pytest-3.1.1, py-1.4.34, pluggy-0.4.0
rootdir: /home/rof/src/github.com/Beit-Hatfutsot/dbs-back, inifile: pytest.ini
plugins: mock-1.2, flask-0.4.0, cov-2.4.0
collected 67 items 

tests/test_geo_places.py ...
tests/test_item.py ...
tests/test_migration.py ......F
tests/test_mjs.py ........
tests/test_persons.py .......
tests/test_search.py ............................
tests/test_slugs.py ....
tests/test_trees.py ..
tests/test_user.py ....
bhs_api/utils.py .

=================================== FAILURES ===================================
_____________________________ test_ensure_metadata _____________________________

app = <Flask 'bhs_api'>
mock_db = Database(mongomock.MongoClient('localhost', 27017), 'db')

    def test_ensure_metadata(app, mock_db):
        app.data_db = mock_db
        given_local_elasticsearch_client_with_test_data(app)
        assert es_search(app, "personalities", "UnitId:1") == []
        assert es_search(app, "personalities", "UnitId:2") == []
        assert es_search(app, "places", "UnitId:3") == []
        assert es_search(app, "persons", "person_id:I2") == []  # living person (in mongo)
        assert es_search(app, "persons", "person_id:I3") == []  # dead person (in mongo)
        assert [h["person_id"] for h in es_search(app, "persons", "person_id:I687")] == ["I687"]  # living person in ES
>       assert set(given_ensure_required_metadata_ran(app)) == {('places', 'ADDED_ITEM', 3),
                                                                ('places', 'DELETED_ITEM', 71255),
                                                                ('places', 'DELETED_ITEM', 71236),
                                                                # item is not allowed for viewing, and is already not in ES so no update needed
                                                                ('places', 'NO_UPDATE_NEEDED', PLACE_BIELSK_NOT_FOR_VIEWING["UnitId"]),
                                                                ('familyNames', 'DELETED_ITEM', 77321),
                                                                ('familyNames', 'DELETED_ITEM', 77323),
                                                                ('photoUnits', 'DELETED_ITEM', 140068),
                                                                ('photoUnits', 'DELETED_ITEM', 137523),
                                                                ('personalities', 'ADDED_ITEM', 1),
                                                                ('personalities', 'NO_UPDATE_NEEDED', 2),
                                                                ('personalities', 'DELETED_ITEM', 93967),
                                                                ('personalities', 'DELETED_ITEM', 93968),
                                                                ('movies', 'DELETED_ITEM', 111554),
                                                                ('movies', 'DELETED_ITEM', 111553),
                                                                ('persons', 'NO_UPDATE_NEEDED', (1, 0, 'I2')),
                                                                ('persons', 'ADDED_ITEM', (1, 0, 'I3')),
                                                                ('persons', 'DELETED_ITEM', (1933, 0, 'I687')),
                                                                ('persons', 'DELETED_ITEM', (1196, 0, 'I686'))}
E       AssertionError: assert set([('family... 93967), ...]) == set([('familyN... 93967), ...])
E         Extra items in the left set:
E         ('persons', 'DELETED_ITEM', (6654, 0, 'I7787'))
E         ('persons', 'DELETED_ITEM', (6654, 0, 'I7788'))
E         Use -v to get the full diff

tests/test_migration.py:211: AssertionError
----------------------------- Captured stdout call -----------------------------
creating index..
Great success!
processing collection places
processing mongo item (UnitId=3)
indexed successfully (inserted)
added item to es: (UnitId=3)
.processing mongo item (UnitId=71253)
item should not be shown and doesn't exist in ES - no action needed (UnitId=71253)
.processed 2 mongo items
processing elasticsearch item (UnitId=71236)
deleted an item which exists in elastic but not in mongo
.processing elasticsearch item (UnitId=71255)
deleted an item which exists in elastic but not in mongo
.processed 2 elasticsearch items
total 4 items were processed:
added 1 items
deleted 2 items
1 items did not require update
done

processing collection familyNames
no items found in mongo
processing elasticsearch item (UnitId=77321)
deleted an item which exists in elastic but not in mongo
.processing elasticsearch item (UnitId=77323)
deleted an item which exists in elastic but not in mongo
.processed 2 elasticsearch items
total 2 items were processed:
deleted 2 items
done

processing collection photoUnits
no items found in mongo
processing elasticsearch item (UnitId=137523)
deleted an item which exists in elastic but not in mongo
.processing elasticsearch item (UnitId=140068)
deleted an item which exists in elastic but not in mongo
.processed 2 elasticsearch items
total 2 items were processed:
deleted 2 items
done

processing collection personalities
processing mongo item (UnitId=1)
indexed successfully (inserted)
added item to es: (UnitId=1)
.processing mongo item (UnitId=2)
item should not be shown and doesn't exist in ES - no action needed (UnitId=2)
.processed 2 mongo items
processing elasticsearch item (UnitId=93967)
deleted an item which exists in elastic but not in mongo
.processing elasticsearch item (UnitId=93968)
deleted an item which exists in elastic but not in mongo
.processed 2 elasticsearch items
total 4 items were processed:
added 1 items
deleted 2 items
1 items did not require update
done

processing collection movies
no items found in mongo
processing elasticsearch item (UnitId=111554)
deleted an item which exists in elastic but not in mongo
.processing elasticsearch item (UnitId=111553)
deleted an item which exists in elastic but not in mongo
.processed 2 elasticsearch items
total 2 items were processed:
deleted 2 items
done

processing collection persons
processing mongo item ((tree_num,version,id=1,0,I2))
item should not be shown and doesn't exist in ES - no action needed ((tree_num,version,id=1,0,I2))
.processing mongo item ((tree_num,version,id=1,0,I3))
indexed successfully (inserted)
added item to es: ((tree_num,version,id=1,0,I3))
.processed 2 mongo items
processing elasticsearch item ((tree_num,version,id=1933,0,I687))
deleted an item which exists in elastic but not in mongo
.processing elasticsearch item ((tree_num,version,id=6654,0,I7787))
deleted an item which exists in elastic but not in mongo
.processing elasticsearch item ((tree_num,version,id=6654,0,I7788))
deleted an item which exists in elastic but not in mongo
.processing elasticsearch item ((tree_num,version,id=1196,0,I686))
deleted an item which exists in elastic but not in mongo
.processed 4 elasticsearch items
total 6 items were processed:
added 1 items
deleted 4 items
1 items did not require update
done

===================== 1 failed, 66 passed in 10.54 seconds =====================
OriHoch commented 7 years ago

related issues: #180, #181

OriHoch commented 7 years ago

fixed in 3d68c6e4e9aca06afe8f2730d3a1d62faa35de96