from pathlib import Path


def test_gcp(func):
    """A very simple test to see if we're on Pangeo GCP environment

    Check existence of jovyan homedir and worker-template to determine if on
    Kubernetes based cluster. Not very robust, but ok for now.

    Raises:
        NotImplementedError: Causes ASV to skip this test with assumption we're
        not on Pangeo GCP environment

    """
    pod_conf = Path('/home/jovyan/worker-template.yaml')

    def func_wrapper(*args, **kwargs):
        if not pod_conf.is_file():
            if func.__name__ == 'setup':
                raise NotImplementedError("Not on GCP Pangeo environment... skipping")
            else:
                return
        else:
            func(*args, **kwargs)
    return func_wrapper