Esempio n. 1
0
def test_driver_get_fails_with_no_records():
    '''
    Tests retrieval of a record fails if there are no records.
    '''
    driver = SQLAlchemyIndexDriver('sqlite:///index.sq3')

    with pytest.raises(NoRecordFound):
        driver.get('some_record_that_does_not_exist')
def test_driver_get_fails_with_no_records():
    '''
    Tests retrieval of a record fails if there are no records.
    '''
    driver = SQLAlchemyIndexDriver('sqlite:///index.sq3')

    with pytest.raises(NoRecordFound):
        driver.get('some_record_that_does_not_exist')
Esempio n. 3
0
def test_driver_get_record():
    '''
    Tests retrieval of a record.
    '''
    with sqlite3.connect('index.sq3') as conn:

        driver = SQLAlchemyIndexDriver('sqlite:///index.sq3')

        did = str(uuid.uuid4())
        rev = str(uuid.uuid4())[:8]
        size = 512
        form = 'object'

        conn.execute(
            '''
            INSERT INTO index_record VALUES (?,?,?,?)
        ''', (did, rev, form, size))

        conn.commit()

        record = driver.get(did)

        assert record['did'] == did, 'record id does not match'
        assert record['rev'] == rev, 'record revision does not match'
        assert record['size'] == size, 'record size does not match'
        assert record['form'] == form, 'record form does not match'
Esempio n. 4
0
def test_driver_get_record():
    '''
    Tests retrieval of a record.
    '''
    with sqlite3.connect('index.sq3') as conn:

        driver = SQLAlchemyIndexDriver('sqlite:///index.sq3')

        did = str(uuid.uuid4())
        baseid = str(uuid.uuid4())
        rev = str(uuid.uuid4())[:8]
        size = 512
        form = 'object'
        baseid = str(uuid.uuid4())
        created_date = datetime.now()
        updated_date = datetime.now()

        conn.execute(
            '''
            INSERT INTO index_record(did, baseid, rev, form, size, created_date, updated_date) VALUES (?,?,?,?,?,?,?)
        ''', (did, baseid, rev, form, size, created_date, updated_date))

        conn.commit()

        record = driver.get(did)

        assert record['did'] == did, 'record id does not match'
        assert record['baseid'] == baseid, 'record id does not match'
        assert record['rev'] == rev, 'record revision does not match'
        assert record['size'] == size, 'record size does not match'
        assert record['form'] == form, 'record form does not match'
        assert record['created_date'] == created_date.isoformat(
        ), 'created date does not match'
        assert record['updated_date'] == updated_date.isoformat(
        ), 'updated date does not match'
def test_driver_get_record():
    '''
    Tests retrieval of a record.
    '''
    with sqlite3.connect('index.sq3') as conn:
        
        driver = SQLAlchemyIndexDriver('sqlite:///index.sq3')
        
        did = str(uuid.uuid4())
        rev = str(uuid.uuid4())[:8]
        size = 512
        form = 'object'
        
        conn.execute('''
            INSERT INTO index_record VALUES (?,?,?,?)
        ''', (did, rev, form, size))
        
        conn.commit()
        
        record = driver.get(did)
        
        assert record['did'] == did, 'record id does not match'
        assert record['rev'] == rev, 'record revision does not match'
        assert record['size'] == size, 'record size does not match'
        assert record['form'] == form, 'record form does not match'
def test_driver_get_fails_with_invalid_id():
    '''
    Tests retrieval of a record fails if the record id is not found.
    '''
    with sqlite3.connect('index.sq3') as conn:
        
        driver = SQLAlchemyIndexDriver('sqlite:///index.sq3')
        
        did = str(uuid.uuid4())
        rev = str(uuid.uuid4())[:8]
        form = 'object'
        
        conn.execute('''
            INSERT INTO index_record VALUES (?,?,?,?)
        ''', (did, rev, form, None))
        
        conn.commit()
        
        with pytest.raises(NoRecordFound):
            driver.get('some_record_that_does_not_exist')
Esempio n. 7
0
def test_driver_get_fails_with_invalid_id():
    '''
    Tests retrieval of a record fails if the record id is not found.
    '''
    with sqlite3.connect('index.sq3') as conn:

        driver = SQLAlchemyIndexDriver('sqlite:///index.sq3')

        did = str(uuid.uuid4())
        rev = str(uuid.uuid4())[:8]
        form = 'object'

        conn.execute(
            '''
            INSERT INTO index_record VALUES (?,?,?,?)
        ''', (did, rev, form, None))

        conn.commit()

        with pytest.raises(NoRecordFound):
            driver.get('some_record_that_does_not_exist')
def test_driver_get_fails_with_invalid_id():
    """
    Tests retrieval of a record fails if the record id is not found.
    """
    with sqlite3.connect("index.sq3") as conn:

        driver = SQLAlchemyIndexDriver("sqlite:///index.sq3")

        did = str(uuid.uuid4())
        baseid = str(uuid.uuid4())
        rev = str(uuid.uuid4())[:8]
        form = "object"

        conn.execute(
            """
            INSERT INTO index_record(did, baseid, rev, form, size) VALUES (?,?,?,?,?)
        """,
            (did, baseid, rev, form, None),
        )

        conn.commit()

        with pytest.raises(NoRecordFound):
            driver.get("some_record_that_does_not_exist")
def test_driver_get_record():
    """
    Tests retrieval of a record.
    """
    with sqlite3.connect("index.sq3") as conn:

        driver = SQLAlchemyIndexDriver("sqlite:///index.sq3")

        did = str(uuid.uuid4())
        baseid = str(uuid.uuid4())
        rev = str(uuid.uuid4())[:8]
        size = 512
        form = "object"
        baseid = str(uuid.uuid4())
        created_date = datetime.now()
        updated_date = datetime.now()

        conn.execute(
            """
            INSERT INTO index_record(did, baseid, rev, form, size, created_date, updated_date) VALUES (?,?,?,?,?,?,?)
        """,
            (did, baseid, rev, form, size, created_date, updated_date),
        )

        conn.commit()

        record = driver.get(did)

        assert record["did"] == did, "record id does not match"
        assert record["baseid"] == baseid, "record id does not match"
        assert record["rev"] == rev, "record revision does not match"
        assert record["size"] == size, "record size does not match"
        assert record["form"] == form, "record form does not match"
        assert (
            record["created_date"] == created_date.isoformat()
        ), "created date does not match"
        assert (
            record["updated_date"] == updated_date.isoformat()
        ), "updated date does not match"