def METHOD_NAME(self):
    """test the api_key_optional decorator"""
    a1 = models.Account.make_account(email="a1@example.com", username="a1_user", name="a1_name",
                                     roles=["user", "api"], associated_journal_ids=[])
    a1_key = a1.api_key
    a1.save()               # a1 has api access
    a2 = models.Account.make_account(email="a2@example.com", username="a2_user", name="a2_name",
                                     roles=["user", "api"], associated_journal_ids=[])
    a2_key = a2.api_key     # user gets the key before access is removed
    a2.remove_role('api')
    a2.save(blocking=True)               # a2 does not have api access.
    # There is no a3 - the last test case is just a public call with no API key
    with self.app_test.test_client() as t_client:
        # Check the authorised user can access our function, but the unauthorised one can't.
        response_authorised = t_client.get('/helloopt?api_key=' + a1_key)
        assert response_authorised.data == b"hello, world!"
        assert response_authorised.status_code == 200
        response_denied = t_client.get('/helloopt?api_key=' + a2_key)
        assert response_denied.status_code == 401
        # also check it's ok to not have a key at all
        response_authorised2 = t_client.get('/helloopt')
        assert response_authorised2.data == b"hello, world!"
        assert response_authorised2.status_code == 200
        # but if you do specify a key it needs to exist
        response_denied2 = t_client.get('/helloopt?api_key=nonexistent_key')
        assert response_denied2.status_code == 401