当前位置: 首页>>代码示例>>Python>>正文


Python NuleculeComponent.apply_pointers方法代码示例

本文整理汇总了Python中atomicapp.nulecule.base.NuleculeComponent.apply_pointers方法的典型用法代码示例。如果您正苦于以下问题:Python NuleculeComponent.apply_pointers方法的具体用法?Python NuleculeComponent.apply_pointers怎么用?Python NuleculeComponent.apply_pointers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在atomicapp.nulecule.base.NuleculeComponent的用法示例。


在下文中一共展示了NuleculeComponent.apply_pointers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestNuleculeXpathing

# 需要导入模块: from atomicapp.nulecule.base import NuleculeComponent [as 别名]
# 或者: from atomicapp.nulecule.base.NuleculeComponent import apply_pointers [as 别名]
class TestNuleculeXpathing(unittest.TestCase):

    # Create a temporary directory for our setup as well as load the required NuleculeComponent
    def setUp(self):
        self.tmpdir = tempfile.mkdtemp(prefix = "atomicapp-test", dir = "/tmp")
        self.artifact_path = os.path.dirname(__file__) + '/artifact_xpath_test/xpath.json'
        self.artifact_content = open(self.artifact_path, 'r').read();
        self.test = NuleculeComponent(name = None, basepath = self.tmpdir, params = None)

    def tearDown(self):
        pass

    # Let's check to see that xpathing is actually working. Fake the params get call
    @mock.patch("atomicapp.nulecule.base.NuleculeComponent.grab_artifact_params", mock_params_get_call)
    def test_xpathing_parse(self):
        self.test.apply_pointers(content=self.artifact_content, params={"image": ["/spec/containers/0/image"]})

    # Fail if we're unable to replace the /spec/containers/1/image pointer
    @mock.patch("atomicapp.nulecule.base.NuleculeComponent.grab_artifact_params", mock_params_get_call)
    def test_xpathing_not_found(self):
        with pytest.raises(NuleculeException):
            self.test.apply_pointers(content=self.artifact_content, params={"image": ["/spec/containers/1/image"]})

    # Test using the artifact path
    def test_artifact_path(self):
        self.test.artifacts = {"docker": [{"file://artifacts/docker/hello-apache-pod_run"}], "kubernetes": [{"file://artifacts/kubernetes/hello-apache-pod.json"}]}
        self.test.get_artifact_paths_for_provider("kubernetes")

    # Test the artifact with the "resource: " pointer
    def test_artifact_path_with_resource(self):
        self.test.artifacts = {"docker": [{"resource":"file://artifacts/docker/hello-apache-pod_run"}], "kubernetes": [{"resource":"file://artifacts/kubernetes/hello-apache-pod.json"}]}
        self.test.get_artifact_paths_for_provider("kubernetes")

    # Test combination of using "resource" and not
    def test_artifact_path_with_resource_and_old(self):
        self.test.artifacts = {"docker": [{"resource":"file://artifacts/docker/hello-apache-pod_run"}], "kubernetes": [{"file://artifacts/kubernetes/hello-apache-pod.json"}]}
        self.test.get_artifact_paths_for_provider("kubernetes")
开发者ID:schmerk,项目名称:atomicapp,代码行数:39,代码来源:test_xpathing.py


注:本文中的atomicapp.nulecule.base.NuleculeComponent.apply_pointers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。