示例#1
0
def test_add_from_yaml():
    """Should add the specified YAML string to the bundle."""
    path = os.path.join(MY_DIRECTORY, "test-get.yaml")
    with open(path) as f:
        contents = f.read()

    bundle = kuber.ResourceBundle()
    bundle.add_from_yaml(contents)
    assert len(bundle.resources) > 0
def _initialize_bundle() -> kuber.ResourceBundle:
    """Creates an initial bundle populated with pod resources."""
    bundle = kuber.ResourceBundle(bundle_name="test",
                                  kubernetes_version="latest")
    bundle.push(_make_pod("p1"))
    bundle.push(_make_pod("p2"))
    bundle.push(_make_pod("p3"))
    bundle.push(_make_pod("p4"))
    bundle.push(_make_pod("p5"))
    return bundle
示例#3
0
def test_add_file():
    """Should add the specified YAML file to the bundle."""
    bundle = kuber.ResourceBundle()
    bundle.add_file(os.path.join(MY_DIRECTORY, "test-get.yaml"))
    assert len(bundle.resources) > 0
示例#4
0
def test_add_file_invalid():
    """Should raise an IOError for unknown file types."""
    bundle = kuber.ResourceBundle()
    with pytest.raises(IOError):
        bundle.add_file(os.path.join(MY_DIRECTORY, "name.foo"))
示例#5
0
def test_add_resource():
    """Should create a new resource from specified arguments."""
    bundle = kuber.ResourceBundle()
    bundle.add(api_version="core/v1", kind="ConfigMap", name="foo")
    assert len(bundle.resources) == 1
    assert bundle.resources[0].kind == "ConfigMap"