Skip to content

Commit

Permalink
Fix tests in test_git with hard coded env setter
Browse files Browse the repository at this point in the history
Commands for setting environment variables are platform specific. Tests are failing on Windows, as
they have harded coded commands for setting environment variables. This commit changes to use the
`get_envrionment_variable_setter_command` method in process_utils module to make the tests
cross-platform.
  • Loading branch information
aptxkid committed Jun 29, 2015
1 parent 706b519 commit d8dfade
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions test/unit/project_type/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from app.project_type.git import Git
from app.util.conf.configuration import Configuration
from app.util.process_utils import is_windows
from app.util.process_utils import is_windows, get_environment_variable_setter_command
from test.framework.base_unit_test_case import BaseUnitTestCase
from test.framework.comparators import AnyStringMatching

Expand Down Expand Up @@ -46,12 +46,15 @@ def test_execute_command_in_project_specifies_cwd_if_exists(self):
self.os_path_exists_mock.return_value = True
project_type_popen_patch = self._patch_popen()

fake_project_directory = 'proj_dir'
fake_command = 'some_command'
git_env = Git("ssh://scm.dev.box.net/box/www/current", 'origin', 'refs/changes/78/151978/27')
git_env.project_directory = 'proj_dir'
git_env.execute_command_in_project('some_command')
git_env.project_directory = fake_project_directory
git_env.execute_command_in_project(fake_command)
env_setter = get_environment_variable_setter_command('PROJECT_DIR', fake_project_directory)
project_type_popen_patch.assert_called_once_with(
'export PROJECT_DIR="proj_dir"; some_command',
cwd='proj_dir',
'{} {}'.format(env_setter, fake_command),
cwd=fake_project_directory,
shell=ANY,
stdout=ANY,
stderr=ANY,
Expand All @@ -61,11 +64,14 @@ def test_execute_command_in_project_specifies_cwd_if_exists(self):
def test_execute_command_in_project_type_specifies_cwd_if_doesnt_exist(self):
project_type_popen_patch = self._patch_popen()

fake_project_directory = 'proj_dir'
fake_command = 'some_command'
git_env = Git("ssh://scm.dev.box.net/box/www/current", 'origin', 'refs/changes/78/151978/27')
git_env.project_directory = 'proj_dir'
git_env.execute_command_in_project('some_command')
git_env.project_directory = fake_project_directory
git_env.execute_command_in_project(fake_command)
env_setter = get_environment_variable_setter_command('PROJECT_DIR', fake_project_directory)
project_type_popen_patch.assert_called_once_with(
'export PROJECT_DIR="proj_dir"; some_command',
'{} {}'.format(env_setter, fake_command),
cwd=None,
shell=ANY,
stdout=ANY,
Expand Down

0 comments on commit d8dfade

Please sign in to comment.