Ejemplo n.º 1
0
 def pull_image(tag_name):
     with open("tests/data/container/fake_images.json") as image_file:
         image_data = json.load(image_file)
     for image in image_data:
         if tag_name in image["RepoTags"]:
             return MockStub(image)
     raise Broker.ProviderError(f"Unable to find image: {tag_name}")
Ejemplo n.º 2
0
 def __init__(self, **kwargs):
     in_dict = {
         "images": [MockStub({"tags": "ch-d:ubi8"})],  # self.runtime.images
         "containers":
         [MockStub({"tags": "f37d3058317f"})],  # self.runtime.containers
         "name":
         "f37d3058317f",  # self.runtime.get_attrs(cont_inst)["name"]
     }
     if "job_id" in kwargs:
         # we need to load in an image object
         super().__init__(self._load_image(kwargs.pop("job_id")))
     elif "name" in kwargs:
         # we need to load in a container object
         super().__init__(self._load_container(kwargs.pop("name")))
     else:
         super().__init__(in_dict=in_dict, **kwargs)
Ejemplo n.º 3
0
 def create_container(self, container_host, **kwargs):
     with open(
             "tests/data/container/fake_containers.json") as container_file:
         container_data = json.load(container_file)
     image_data = self.pull_image(container_host)
     for container in container_data:
         if container["Config"]["Image"] == image_data.RepoTags[0]:
             container["id"] = container[
                 "Id"]  # hostname = cont_inst.id[:12]
             return MockStub(container)
Ejemplo n.º 4
0
def config_stub():
    yield MockStub()
Ejemplo n.º 5
0
 def get_related(self, related=None):
     with open("tests/data/ansible_tower/fake_children.json") as child_file:
         child_data = json.load(child_file)
     return MockStub({"results": [MockStub(child) for child in child_data]})