def test_version_info_id_constraint(session): # type: (Session) -> None session.add(VersionInfoModel(schema_version=1, library_version='0.0.1')) session.commit() # Test check constraint of version_info_id. session.add(VersionInfoModel(version_info_id=2, schema_version=2, library_version='0.0.2')) pytest.raises(IntegrityError, lambda: session.commit())
def test_commit(): # type: () -> None storage = create_test_storage() session = storage.scoped_session() # This object violates the unique constraint of version_info_id. v = VersionInfoModel(version_info_id=1, schema_version=1, library_version='0.0.1') session.add(v) with pytest.raises(StorageInternalError): storage._commit(session)