def test_new_record(settings):
    expected_result = {}
    test_data = 'emerald/201808/protein.png'
    cata = datacatalog.CatalogStore(settings['mongodb'],
                                    settings['catalogstore'])
    rec = cata.new_record(test_data)
    assert isinstance(rec, dict)
def test_create_record(settings):
    from pymongo import results
    test_data = 'emerald/201808/protein.png'
    cata = datacatalog.CatalogStore(settings['mongodb'],
                                    settings['catalogstore'])
    rec = cata.create_update_record(test_data)
    assert isinstance(rec, dict)
def test_normalize(settings):
    expected_result = 'emerald/201808/protein.png'
    test_data = '/uploads/emerald/201808/protein.png'
    cata = datacatalog.CatalogStore(settings['mongodb'],
                                    settings['catalogstore'])
    npath = cata.normalize(test_data)
    assert npath == expected_result
def test_abspath(settings):
    expected_result = './tests/store/uploads/emerald/201808/protein.png'
    test_data = 'emerald/201808/protein.png'
    cata = datacatalog.CatalogStore(settings['mongodb'],
                                    settings['catalogstore'])
    abspath = cata.abspath(test_data)
    assert abspath == expected_result
def test_update_record_revision_incremented(settings):
    from pymongo import results
    from time import sleep
    sleep(1)
    test_data = 'emerald/201808/protein.png'
    cata = datacatalog.CatalogStore(settings['mongodb'],
                                    settings['catalogstore'])
    rec = cata.create_update_record(test_data)
    assert rec['properties']['revision'] > 0
def test_update_record(settings):
    import copy
    from time import sleep
    expected_result = {}
    test_data = 'emerald/201808/protein.png'
    cata = datacatalog.CatalogStore(settings['mongodb'],
                                    settings['catalogstore'])
    rec1 = cata.new_record(test_data)
    rec1a = copy.deepcopy(rec1)
    sleep(1)
    rec2 = cata.update_record(test_data, rec1)
    assert rec1a['properties']['revision'] != rec2['properties']['revision']
    assert rec1a['properties']['modified_date'] != rec2['properties'][
        'modified_date']
def test_init_CatalogStore(settings):
    cata = datacatalog.CatalogStore(settings['mongodb'],
                                    settings['catalogstore'])
    assert cata.base is not None
    assert cata.store is not None
def test_delete_record(settings):
    test_data = 'emerald/201808/protein.png'
    cata = datacatalog.CatalogStore(settings['mongodb'],
                                    settings['catalogstore'])
    resp = cata.delete_record(test_data)
    assert resp['n'] > 0