本文整理汇总了Python中atomicapp.nulecule.base.NuleculeComponent.get_artifact_paths_for_provider方法的典型用法代码示例。如果您正苦于以下问题:Python NuleculeComponent.get_artifact_paths_for_provider方法的具体用法?Python NuleculeComponent.get_artifact_paths_for_provider怎么用?Python NuleculeComponent.get_artifact_paths_for_provider使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类atomicapp.nulecule.base.NuleculeComponent
的用法示例。
在下文中一共展示了NuleculeComponent.get_artifact_paths_for_provider方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_artifact_paths_for_provider
# 需要导入模块: from atomicapp.nulecule.base import NuleculeComponent [as 别名]
# 或者: from atomicapp.nulecule.base.NuleculeComponent import get_artifact_paths_for_provider [as 别名]
def test_artifact_paths_for_provider(
self, mock_get_artifact_paths_for_path):
provider_key = 'some-provider'
expected_artifact_paths = [
'some/path/relative/path/to/artifact1',
'/abs/path/to/artifact2',
'some/path/x/artifact3'
]
mock_get_artifact_paths_for_path.side_effect = lambda path: [path]
nc = NuleculeComponent(name='some-app', basepath='some/path')
nc.artifacts = {
provider_key: [
'file://relative/path/to/artifact1',
'file:///abs/path/to/artifact2',
{
'inherit': ['x-provider']
}
],
'x-provider': [
'file://x/artifact3'
]
}
self.assertEqual(nc.get_artifact_paths_for_provider(provider_key),
expected_artifact_paths)
示例2: TestNuleculeXpathing
# 需要导入模块: from atomicapp.nulecule.base import NuleculeComponent [as 别名]
# 或者: from atomicapp.nulecule.base.NuleculeComponent import get_artifact_paths_for_provider [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")