From 65b7050930c8a0dee92ad032dc1a3304cbf24996 Mon Sep 17 00:00:00 2001 From: Einar Forselv Date: Tue, 16 Apr 2019 18:22:28 +0200 Subject: [PATCH] Generate random sha256 for each container fixture --- tests/fixtures.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/fixtures.py b/tests/fixtures.py index 1470a34..8de68bd 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -1,4 +1,13 @@ """Generate test fixtures""" +from datetime import datetime +import hashlib + + +def generate_sha256(): + """Generate a unique sha256""" + h = hashlib.sha256() + h.update(str(datetime.now().timestamp()).encode()) + return h.hexdigest() def containers(project="default", containers=[]): @@ -8,6 +17,7 @@ def containers(project="default", containers=[]): containers (dict): { 'containers: [ + 'id': 'something' 'service': 'service_name', 'mounts: [{ 'Source': '/home/user/stuff', @@ -21,7 +31,7 @@ def containers(project="default", containers=[]): return [ { 'HostConfig': {'NetworkMode': 'restic-volume-backup_default'}, - 'Id': '58d550e8f450129fa757820446e4021822a660918a61437e95115d3dc48ddde8', + 'Id': container.get('id', generate_sha256()), 'Image': 'restic-volume-backup_backup', 'ImageID': 'sha256:4d9a81206af7d65563b85d06be160dc90dc20ade94edcf544261f0e1db4472b3', 'Labels': {