def test_execute(self, exec_command): task = gapic_tasks.GapicConfigMoveTask() task.execute('/path/src', '/path/dest') assert exec_command.call_count == 2 expected_cmds = [ 'mkdir -p /path', 'cp /path/src /path/dest', ] assert_calls_equal(exec_command.mock_calls, expected_cmds)
def test_execute_dest_exists(self, exists, exec_command): exists.return_value = True task = gapic_tasks.GapicConfigMoveTask() task.execute('/path/src', '/path/exists') assert exec_command.call_count == 3 expected_cmds = [ 'mv /path/exists /path/exists.old', 'mkdir -p /path', 'cp /path/src /path/exists', ] assert_calls_equal(exec_command.mock_calls, expected_cmds)
def test_execute(self, exec_command): task = gapic_tasks.GapicConfigMoveTask() task.execute('/path/src', ['/path/dest']) assert exec_command.call_count == 2 expected_cmds = ( 'mkdir -p /path', 'cp /path/src /path/dest', ) for call, expected in zip(exec_command.mock_calls, expected_cmds): _, args, _ = call assert ' '.join(args[0]) == expected
def test_execute_dest_exists(self, exists, exec_command): exists.return_value = True task = gapic_tasks.GapicConfigMoveTask() task.execute('/path/src', ['/path/exists']) assert exec_command.call_count == 3 expected_cmds = ( 'mv /path/exists /path/exists.old', 'mkdir -p /path', 'cp /path/src /path/exists', ) for call, expected in zip(exec_command.mock_calls, expected_cmds): _, args, _ = call assert ' '.join(args[0]) == expected
def test_validate(self): task = gapic_tasks.GapicConfigMoveTask() assert task.validate() == []
def test_execute_no_dest(self, exec_command): task = gapic_tasks.GapicConfigMoveTask() with pytest.raises(ValueError): task.execute('/path/src', None) assert exec_command.call_count == 0