def test_create_remove(): """ Ensure that credentials can be created and removed """ store = CredentialStore() req = FakeCred() info = store.create(req) assert info is store[req] store.remove(info) with pytest.raises(KeyError): store.remove(info) with pytest.raises(KeyError): _ = store[req]
def test_len(): """ Ensure that the credential count is updated correctly """ store = CredentialStore() store.create(FakeCred()) assert len(store) == 1 store.create(FakeCred(vo='some_other_vo')) assert len(store) == 2 store.create(FakeCred()) assert len(store) == 2, 'Adding a repeated requirement should not increase the size of the store' assert len(store.get_all_matching_type(FakeCred)) == 2 store.remove(store[FakeCred()]) assert len(store) == 1 store.clear() assert len(store) == 0