From 0a863fe766fb7a7716c7c7f953665c718dc37b5c Mon Sep 17 00:00:00 2001 From: jpic Date: Thu, 13 Feb 2020 04:18:22 +0100 Subject: [PATCH] black --- tests/test_build.py | 91 --------------------------------------------- 1 file changed, 91 deletions(-) delete mode 100644 tests/test_build.py diff --git a/tests/test_build.py b/tests/test_build.py deleted file mode 100644 index 6b34b45..0000000 --- a/tests/test_build.py +++ /dev/null @@ -1,91 +0,0 @@ -import difflib -import os -import sys - -from podctl.container import Container -from podctl.build import Build -from podctl.visitors import ( - Base, - Copy, - Packages, - Run, - User, -) - - -from unittest import mock -from podctl.visitors import packages -packages.subprocess.check_call = mock.Mock() - -os.environ['CACHE_DIR'] = '/test' -os.environ['CI'] = '1' - - -def script_test(name, *visitors): - result = str(Container(*visitors).script('build')) - path = os.path.join( - os.path.dirname(__file__), - f'test_{name}.sh', - ) - - if os.getenv('TEST_REWRITE') and os.path.exists(path): - os.unlink(path) - - if not os.path.exists(path): - with open(path, 'w+') as f: - f.write(result) - raise Exception(f'Fixture created test_{name}.sh') - - with open(path, 'r') as f: - expected = f.read() - result = difflib.unified_diff( - expected, - result, - fromfile='expected', - tofile='result' - ) - assert not list(result), sys.stdout.writelines(result) - - -def test_build_empty(): - script_test( - 'build_empty', - Base('alpine'), - ) - - -def test_build_packages(): - script_test( - 'build_packages', - Base('alpine'), - Packages('bash'), - ) - - -def test_build_user(): - script_test( - 'build_user', - Base('alpine'), - User('app', 1000, '/app'), - ) - - -def test_build_copy(): - script_test( - 'build_copy', - Base('alpine'), - Copy('/test', '/app'), - ) - - -def test_build_run(): - script_test( - 'build_run', - Base('alpine'), - Run('foo'), - Run('sudo bar'), - Run('sudo bar > test'), - Run(''' - bar - '''), - )