def test_get(): """ Make sure that the ``get()`` method works as expected """ store = CredentialStore() req = FakeCred() assert store.get(req) is None info = store.create(req) assert store.get(req) is info
def test_get_missing_credential(): """ Check that asking for a non-existent credential fails """ store = CredentialStore() req = FakeCred() with pytest.raises(KeyError): _ = store[req]
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