Пример #1
0
def test_fsearch_range(mock_db):
    for i in [{
        'name_lc': ['albert', 'einstein'],
        'deceased': True,
        'tree_num': 2,
        'tree_version': 0,
        'id': 'I3',
        'archived': True,
        'Slug': {'En': 'person_1;0.I2'},
        'birth_year': 1863,
    }, {
        'name_lc': ['albert', 'einstein'],
        'deceased': True,
        'tree_num': 2,
        'tree_version': 1,
        'id': 'I7',
        'Slug': {'En': 'person_1;0.I7'},
        'birth_year': 1860,
        "marriage_years": [1875, 1888]
    }]:
        mock_db['persons'].insert(i)
    total, persons = fsearch(birth_year=["1862:2"], db=mock_db)
    assert total == 1
    assert persons[0]["birth_year"] == 1860
    total, persons = fsearch(marriage_year=["1876:2"], db=mock_db)
    assert total == 1
    assert persons[0]["id"] == "I7"
    assert persons[0]["marriage_years"] == [1875, 1888]
Пример #2
0
def test_fsearch_api(mock_db):
    for i in [{
            'name_lc': ['albert', 'einstein'],
            'deceased': True,
            'tree_num': 2,
            'tree_version': 0,
            'id': 'I3',
            'archived': True,
            'Slug': {'En': 'person_1;0.I2'},
        },{
            'name_lc': ['albert', 'einstein'],
            'deceased': True,
            'tree_num': 2,
            'tree_version': 1,
            'id': 'I7',
            'Slug': {'En': 'person_1;0.I7'},
            'BIRT_PLAC_lc': "acapulco"
        },{
            'name_lc': ['cookie', 'monster'],
            'deceased': False,
            'tree_num': 2,
            'tree_version': 1,
            'id': 'I9',
            'Slug': {'En': 'person_1;0.I9'},
            'BIRT_PLAC_lc': "acapulco"
        }]:
            mock_db['persons'].insert(i)
    total, persons = fsearch(last_name=['Einstein'], db=mock_db)
    assert total == 1
    assert persons[0]['tree_version'] == 1
    # searching with living person details should not return any living persons
    total, persons = fsearch(birth_place=["Acapulco"], db=mock_db)
    assert total == 1
    assert persons[0]['id'] == "I7"
Пример #3
0
def test_fsearch_range(mock_db):
    for i in [{
            'name_lc': ['albert', 'einstein'],
            'deceased': True,
            'tree_num': 2,
            'tree_version': 0,
            'id': 'I3',
            'archived': True,
            'Slug': {
                'En': 'person_1;0.I2'
            },
            'birth_year': 1863,
    }, {
            'name_lc': ['albert', 'einstein'],
            'deceased': True,
            'tree_num': 2,
            'tree_version': 1,
            'id': 'I7',
            'Slug': {
                'En': 'person_1;0.I7'
            },
            'birth_year': 1860,
            "marriage_years": [1875, 1888]
    }]:
        mock_db['persons'].insert(i)
    total, persons = fsearch(birth_year=["1862:2"], db=mock_db)
    assert total == 1
    assert persons[0]["birth_year"] == 1860
    total, persons = fsearch(marriage_year=["1876:2"], db=mock_db)
    assert total == 1
    assert persons[0]["id"] == "I7"
    assert persons[0]["marriage_years"] == [1875, 1888]
Пример #4
0
def test_fsearch_api(client, mock_db):
    for i in [{
            'name_lc': ['albert', 'einstein'],
            'deceased': True,
            'tree_num': 2,
            'tree_version': 0,
            'id': 'I3',
            'archived': True,
            'Slug': {
                'En': 'person_1;0.I2'
            },
    }, {
            'name_lc': ['albert', 'einstein'],
            'deceased': True,
            'tree_num': 2,
            'tree_version': 1,
            'id': 'I7',
            'Slug': {
                'En': 'person_1;0.I7'
            },
    }]:
        mock_db['persons'].insert(i)
    total, persons = fsearch(last_name=['Einstein'], db=mock_db)
    assert total == 1
    assert persons[0]['tree_version'] == 1
Пример #5
0
def test_fsearch_results_limit(mock_db):
    mock_db['persons'].remove()
    for i in range(0, 100):
        mock_db['persons'].insert({
            'name_lc': ['firstname{}'.format(i), 'lastname{}'.format(i)],
            'deceased': True,
            'tree_num': 2,
            'tree_version': 0,
            'id': 'I26{}'.format(i),
            'Slug': {'En': 'person_{};0.I26{}'.format(i, i)},
        })
    total, persons = fsearch(max_results=3, db=mock_db)
    assert total == 100
    assert len(persons) == 3
    total, persons = fsearch(max_results=3, max_count_results=5, db=mock_db)
    assert total == 5
    assert len(persons) == 3
Пример #6
0
def ftree_search():
    args = request.args
    keys = args.keys()
    if len(keys) == 0:
        em = "At least one search field has to be specified"
        abort (400, em)
    if len(keys) == 1 and keys[0]=='sex':
        em = "Sex only is not enough"
        abort (400, em)
    total, items = fsearch(**args)
    return humanify({"items": items, "total": total})
Пример #7
0
def test_fsearch_api(mock_db):
    for i in [{
            'name_lc': ['albert', 'einstein'],
            'deceased': True,
            'tree_num': 2,
            'tree_version': 0,
            'id': 'I3',
            'archived': True,
            'Slug': {
                'En': 'person_1;0.I2'
            },
    }, {
            'name_lc': ['albert', 'einstein'],
            'deceased': True,
            'tree_num': 2,
            'tree_version': 1,
            'id': 'I7',
            'Slug': {
                'En': 'person_1;0.I7'
            },
            'BIRT_PLAC_lc': "acapulco"
    }, {
            'name_lc': ['cookie', 'monster'],
            'deceased': False,
            'tree_num': 2,
            'tree_version': 1,
            'id': 'I9',
            'Slug': {
                'En': 'person_1;0.I9'
            },
            'BIRT_PLAC_lc': "acapulco"
    }]:
        mock_db['persons'].insert(i)
    total, persons = fsearch(last_name=['Einstein'], db=mock_db)
    assert total == 1
    assert persons[0]['tree_version'] == 1
    # searching with living person details should not return any living persons
    total, persons = fsearch(birth_place=["Acapulco"], db=mock_db)
    assert total == 1
    assert persons[0]['id'] == "I7"
Пример #8
0
def test_fsearch_results_limit(mock_db):
    mock_db['persons'].remove()
    for i in range(0, 100):
        mock_db['persons'].insert({
            'name_lc': ['firstname{}'.format(i), 'lastname{}'.format(i)],
            'deceased':
            True,
            'tree_num':
            2,
            'tree_version':
            0,
            'id':
            'I26{}'.format(i),
            'Slug': {
                'En': 'person_{};0.I26{}'.format(i, i)
            },
        })
    total, persons = fsearch(max_results=3, db=mock_db)
    assert total == 100
    assert len(persons) == 3
    total, persons = fsearch(max_results=3, max_count_results=5, db=mock_db)
    assert total == 5
    assert len(persons) == 3