From ab160b3eaa8c92f76fc879eefb6c83da4a54d7d6 Mon Sep 17 00:00:00 2001 From: Einar Forselv Date: Tue, 16 Apr 2019 02:19:20 +0200 Subject: [PATCH] Fixtures module for generating containers --- tests/fixtures.py | 65 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 tests/fixtures.py diff --git a/tests/fixtures.py b/tests/fixtures.py new file mode 100644 index 0000000..7280cbb --- /dev/null +++ b/tests/fixtures.py @@ -0,0 +1,65 @@ +"""Generate test fixtures""" + + +def containers(project="default", containers=None): + """ + Args: + project (str): Name of the compose project + containers (dict): + { + 'containers: [ + + ] + } + """ + def wrapper(*args, **kwargs): + return { + 'HostConfig': {'NetworkMode': 'restic-volume-backup_default'}, + 'Id': '58d550e8f450129fa757820446e4021822a660918a61437e95115d3dc48ddde8', + 'Image': 'restic-volume-backup_backup', + 'ImageID': 'sha256:4d9a81206af7d65563b85d06be160dc90dc20ade94edcf544261f0e1db4472b3', + 'Labels': { + 'com.docker.compose.oneoff': 'True', + 'com.docker.compose.project': project, + 'com.docker.compose.service': 'backup', + }, + 'Mounts': [ + { + 'Destination': '/restic-volume-backup', + 'Mode': 'rw', + 'RW': True, + 'Source': '/Users/einarforselv/Documents/projects/contraz/restic-volume-backup', + 'Type': 'bind', + }, + { + 'Destination': '/tmp/docker.sock', + 'Mode': 'ro', + 'RW': False, + 'Source': '/var/run/docker.sock', + 'Type': 'bind', + }, + ], + 'Names': ['/restic-volume-backup_backup_run_58d1699be0d8'], + 'NetworkSettings': { + 'Networks': { + 'restic-volume-backup_default': { + 'Aliases': None, + 'DriverOpts': None, + 'EndpointID': '96ac233ec96ae2318a15419c4d211bbc0d130fc33baaaba6dcd8c13328ba4b8f', + 'Gateway': '172.22.0.1', + 'GlobalIPv6Address': '', + 'GlobalIPv6PrefixLen': 0, + 'IPAMConfig': None, + 'IPAddress': '172.22.0.2', + 'IPPrefixLen': 16, + 'IPv6Gateway': '', + 'Links': None, + 'MacAddress': '02:42:ac:16:00:02', + 'NetworkID': '98886e14fddc2b3d31d15fbbfc3ea1b339626374ba2ff6c2dad406b1617ee09c', + } + } + }, + 'State': 'running', + }, + + return wrapper