예제 #1
0
    def test_do_su(self, ms):
        ms.Popen = mock_popen('root')

        self.assertEqual('root', do('whoami', su=True))
        ms.Popen.assert_called_with('sudo whoami', env=None,
                                    stdout=ms.PIPE, stderr=ms.PIPE,
                                    shell=True)
예제 #2
0
    def test_do_called_right(self, ms):
        ms.Popen = mock_popen('ubuntu')

        self.assertEqual('ubuntu', do('whoami', env={'HOME': 'heartis'}))
        ms.Popen.assert_called_with(['whoami'], env={'HOME': 'heartis'},
                                    stdout=ms.PIPE, stderr=ms.PIPE,
                                    shell=False)
예제 #3
0
    def test_do_str(self, ms):
        ms.Popen = mock_popen('user')

        self.assertEqual('user', do('whoami'))
예제 #4
0
    def test_do(self, ms):
        ms.Popen = mock_popen('user')

        self.assertEqual('user', do(['whoami']))