def test_executeCorrectness(self): fakeCommand = "some fake command to passed as a list" pOpen = self.__patchPOpen() services.execute(fakeCommand) expected = [ call(services.formatCommandLine(fakeCommand), bufsize=1, universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT), call().communicate() ] self.assertCalls(pOpen, expected)
def test_executeForOutputCorrectness(self): fakeCommand = "some fake command to passed as a list" pOpen = self.patch( CUT, '.'.join([subprocess.__name__, subprocess.Popen.__name__])) pOpen.return_value.communicate.return_value = ('', None) services.executeForOutput(fakeCommand) expected = [ call(services.formatCommandLine(fakeCommand), bufsize=1, universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT), call().communicate() ] self.assertCalls(pOpen, expected)
def test_createLinkOnWindowsForDirectory(self): patcher = self.patch(CUT, subprocess.__name__) self.patch(CUT, 'platform.system', return_value='Windows') self._fakeOs.path.addMockForFunction('isdir', True) source = "/home/product/fw/inc" target = "/home/tests/fw/inc" services.createLink(source, target) self.assertEqual(0, len(self._fakeOs['symlink'])) commandLine = services.formatCommandLine( 'cmd /c mklink /D "{target}" "{source}" >nul'.format( target=services.toWindowsPath(target), source=services.toWindowsPath("../../product/fw/inc"))) self.assertCalls( patcher, [call.Popen(commandLine, shell=True), call.Popen().wait()])