13
13
from unittest .mock import Mock , PropertyMock , mock_open , patch
14
14
15
15
import pytest
16
- from django .test import TestCase
16
+ from django .test import TestCase , override_settings
17
17
from django_dynamic_fixture import get
18
18
from docker .errors import APIError as DockerAPIError
19
19
from docker .errors import DockerException
@@ -356,6 +356,7 @@ def test_failing_execution_with_unexpected_exception(self):
356
356
})
357
357
358
358
359
+ @override_settings (RTD_DOCKER_WORKDIR = '/tmp/' )
359
360
class TestDockerBuildEnvironment (TestCase ):
360
361
361
362
"""Test docker build environment."""
@@ -699,7 +700,8 @@ def test_command_execution(self):
699
700
700
701
self .mocks .docker_client .exec_create .assert_called_with (
701
702
container = 'build-123-project-6-pip' ,
702
- cmd = "/bin/sh -c 'cd /tmp && echo\\ test'" ,
703
+ cmd = "/bin/sh -c 'echo\\ test'" ,
704
+ workdir = '/tmp' ,
703
705
environment = mock .ANY ,
704
706
user = 'docs:docs' ,
705
707
stderr = True ,
@@ -759,7 +761,8 @@ def test_command_not_recorded(self):
759
761
760
762
self .mocks .docker_client .exec_create .assert_called_with (
761
763
container = 'build-123-project-6-pip' ,
762
- cmd = "/bin/sh -c 'cd /tmp && echo\\ test'" ,
764
+ cmd = "/bin/sh -c 'echo\\ test'" ,
765
+ workdir = '/tmp' ,
763
766
environment = mock .ANY ,
764
767
user = 'docs:docs' ,
765
768
stderr = True ,
@@ -806,7 +809,8 @@ def test_record_command_as_success(self):
806
809
807
810
self .mocks .docker_client .exec_create .assert_called_with (
808
811
container = 'build-123-project-6-pip' ,
809
- cmd = "/bin/sh -c 'cd /tmp && echo\\ test'" ,
812
+ cmd = "/bin/sh -c 'echo\\ test'" ,
813
+ workdir = '/tmp' ,
810
814
environment = mock .ANY ,
811
815
user = 'docs:docs' ,
812
816
stderr = True ,
@@ -1010,6 +1014,7 @@ def test_container_timeout(self):
1010
1014
})
1011
1015
1012
1016
1017
+ @override_settings (RTD_DOCKER_WORKDIR = '/tmp/' )
1013
1018
class TestBuildCommand (TestCase ):
1014
1019
1015
1020
"""Test build command creation."""
@@ -1090,6 +1095,7 @@ def test_unicode_output(self, mock_subprocess):
1090
1095
)
1091
1096
1092
1097
1098
+ @override_settings (RTD_DOCKER_WORKDIR = '/tmp/' )
1093
1099
class TestDockerBuildCommand (TestCase ):
1094
1100
1095
1101
"""Test docker build commands."""
@@ -1109,7 +1115,7 @@ def test_wrapped_command(self):
1109
1115
)
1110
1116
self .assertEqual (
1111
1117
cmd .get_wrapped_command (),
1112
- "/bin/sh -c 'cd /tmp/foobar && pip install requests'" ,
1118
+ "/bin/sh -c 'pip install requests'" ,
1113
1119
)
1114
1120
cmd = DockerBuildCommand (
1115
1121
['python' , '/tmp/foo/pip' , 'install' , 'Django>1.7' ],
@@ -1120,7 +1126,7 @@ def test_wrapped_command(self):
1120
1126
cmd .get_wrapped_command (),
1121
1127
(
1122
1128
'/bin/sh -c '
1123
- "'cd /tmp/foobar && PATH=/tmp/foo:$PATH "
1129
+ "'PATH=/tmp/foo:$PATH "
1124
1130
r"python /tmp/foo/pip install Django\>1.7'"
1125
1131
),
1126
1132
)
0 commit comments