def test_driver_delete_record(): ''' Tests deletion of a record. ''' 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() driver.delete(did, rev) count = conn.execute(''' SELECT COUNT(*) FROM index_record ''').fetchone()[0] assert count == 0, 'records remain after deletion'
def test_driver_delete_record(): ''' Tests deletion of a record. ''' 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() driver.delete(did, rev) count = conn.execute(''' SELECT COUNT(*) FROM index_record ''').fetchone()[0] assert count == 0, 'records remain after deletion'
def _test_driver_delete_record(): """ Tests deletion 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] form = "object" conn.execute( """ INSERT INTO index_record(did, baseid, rev, form, size) VALUES (?,?,?,?,?) """, (did, baseid, rev, form, None), ) conn.commit() driver.delete(did, rev) count = conn.execute( """ SELECT COUNT(*) FROM index_record """ ).fetchone()[0] assert count == 0, "records remain after deletion"
def test_driver_delete_fails_with_no_records(): ''' Tests deletion of a record fails if there are no records. ''' driver = SQLAlchemyIndexDriver('sqlite:///index.sq3') with pytest.raises(NoRecordFound): driver.delete('some_record_that_does_not_exist', 'some_revision')
def test_driver_delete_fails_with_no_records(): """ Tests deletion of a record fails if there are no records. """ driver = SQLAlchemyIndexDriver("sqlite:///index.sq3") with pytest.raises(NoRecordFound): driver.delete("some_record_that_does_not_exist", "some_revision")
def test_driver_delete_fails_with_invalid_rev(): ''' Tests deletion of a record fails if the record rev is not invalid. ''' 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(RevisionMismatch): driver.delete(did, 'some_revision')
def test_driver_delete_fails_with_invalid_id(): ''' Tests deletion 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.delete('some_record_that_does_not_exist', rev)
def test_driver_delete_fails_with_invalid_rev(): ''' Tests deletion of a record fails if the record rev is not invalid. ''' 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(RevisionMismatch): driver.delete(did, 'some_revision')
def test_driver_delete_fails_with_invalid_id(): ''' Tests deletion 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.delete('some_record_that_does_not_exist', rev)
def test_driver_delete_fails_with_invalid_rev(): """ Tests deletion of a record fails if the record rev is not invalid. """ 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(RevisionMismatch): driver.delete(did, "some_revision")
def test_driver_delete_fails_with_invalid_id(): """ Tests deletion 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.delete("some_record_that_does_not_exist", rev)