def test_slurm_nodelist_groups_partitions():
    os.environ[
        "LIBE_RESOURCES_TEST_NODE_LIST"] = "bdw-[0254,0384,0565-0568],bdwd-[0004,0009]"
    exp_out = [
        'bdw-0254', 'bdw-0384', 'bdw-0565', 'bdw-0566', 'bdw-0567', 'bdw-0568',
        'bdwd-0004', 'bdwd-0009'
    ]
    nodelist = EnvResources.get_slurm_nodelist(
        node_list_env="LIBE_RESOURCES_TEST_NODE_LIST")
    assert nodelist == exp_out, "Nodelist returned does not match expected"
def test_slurm_nodelist_groups_nodash():
    os.environ[
        "LIBE_RESOURCES_TEST_NODE_LIST"] = "nid0[0020-0022,0137-0139,1234]"
    exp_out = [
        'nid00020', 'nid00021', 'nid00022', 'nid00137', 'nid00138', 'nid00139',
        'nid01234'
    ]
    nodelist = EnvResources.get_slurm_nodelist(
        node_list_env="LIBE_RESOURCES_TEST_NODE_LIST")
    assert nodelist == exp_out, "Nodelist returned does not match expected"
def test_slurm_nodelist_reverse_grp():
    os.environ[
        "LIBE_RESOURCES_TEST_NODE_LIST"] = "knl-[0020-0022,0139-0137,1234]"
    exp_out = [
        'knl-0020', 'knl-0021', 'knl-0022', 'knl-0137', 'knl-0138', 'knl-0139',
        'knl-1234'
    ]
    nodelist = EnvResources.get_slurm_nodelist(
        node_list_env="LIBE_RESOURCES_TEST_NODE_LIST")
    assert nodelist == exp_out, "Nodelist returned does not match expected"
def test_slurm_nodelist_groups_longprefix():
    os.environ[
        "LIBE_RESOURCES_TEST_NODE_LIST"] = "super-[000020-000022,000137-000139,001234,023456-023458]"
    exp_out = [
        'super-000020', 'super-000021', 'super-000022', 'super-000137',
        'super-000138', 'super-000139', 'super-001234', 'super-023456',
        'super-023457', 'super-023458'
    ]
    nodelist = EnvResources.get_slurm_nodelist(
        node_list_env="LIBE_RESOURCES_TEST_NODE_LIST")
    assert nodelist == exp_out, "Nodelist returned does not match expected"
def test_slurm_nodelist_bdw_seq():
    os.environ["LIBE_RESOURCES_TEST_NODE_LIST"] = "bdw-[0009-0012]"
    exp_out = ['bdw-0009', 'bdw-0010', 'bdw-0011', 'bdw-0012']
    nodelist = EnvResources.get_slurm_nodelist(
        node_list_env="LIBE_RESOURCES_TEST_NODE_LIST")
    assert nodelist == exp_out, "Nodelist returned does not match expected"
def test_slurm_nodelist_single_nodash():
    os.environ["LIBE_RESOURCES_TEST_NODE_LIST"] = "nid00056"
    exp_out = ["nid00056"]
    nodelist = EnvResources.get_slurm_nodelist(
        node_list_env="LIBE_RESOURCES_TEST_NODE_LIST")
    assert nodelist == exp_out, "Nodelist returned does not match expected"
def test_slurm_nodelist_empty():
    os.environ["LIBE_RESOURCES_TEST_NODE_LIST"] = ""
    exp_out = []  # empty
    nodelist = EnvResources.get_slurm_nodelist(
        node_list_env="LIBE_RESOURCES_TEST_NODE_LIST")
    assert nodelist == exp_out, "Nodelist returned does not match expected"