Example #1
0
class TFtpDeviceTestCase(unittest.TestCase):
    def setUp(self):
        self.device = TFtpDevice("localhost", 69)

    @patch('subprocess.Popen')
    def test_put_ok(self, Popen):
        self.device.put("any command")

    @patch('subprocess.Popen')
    def test_put_create_popen_fail_value_error(self, Popen):
        Popen.side_effect = Exception('some error...')
        self.assertRaises(tftp.WlTFtpDeviceCallingProcessError,
                          self.device.put, "any command")

    @patch('subprocess.Popen')
    def test_put_create_popen_fail_wait(self, Popen):
        popen = Popen.return_value
        popen.wait.side_effect = Exception('some error...')
        self.assertRaises(tftp.WlTFtpDeviceWaitingCommandError,
                          self.device.put, "any command")

    @patch('subprocess.Popen')
    def test_put_create_popen_fail_reading_stdout(self, Popen):
        popen = Popen.return_value
        popen.stdout.read.side_effect = Exception('some error...')
        self.assertRaises(tftp.WlTFtpDeviceRetrievingOutputFromCommandError,
                          self.device.put, "any command")

    @patch('subprocess.Popen')
    def test_put_create_popen_fail_reading_stderr(self, Popen):
        popen = Popen.return_value
        popen.stderr.read.side_effect = Exception('some error...')
        self.assertRaises(tftp.WlTFtpDeviceRetrievingOutputFromCommandError,
                          self.device.put, "any command")
Example #2
0
class TFtpDeviceTestCase(unittest.TestCase):

    def setUp(self):
        self.device = TFtpDevice("localhost", 69)

    @patch('subprocess.Popen')
    def test_put_ok(self, Popen):
        self.device.put("any command")

    @patch('subprocess.Popen')
    def test_put_create_popen_fail_value_error(self, Popen):
        Popen.side_effect = Exception('some error...')
        self.assertRaises(
            tftp.WlTFtpDeviceCallingProcessError,
            self.device.put,
            "any command"
        )

    @patch('subprocess.Popen')
    def test_put_create_popen_fail_wait(self, Popen):
        popen = Popen.return_value
        popen.wait.side_effect = Exception('some error...')
        self.assertRaises(
            tftp.WlTFtpDeviceWaitingCommandError,
            self.device.put,
            "any command"
        )

    @patch('subprocess.Popen')
    def test_put_create_popen_fail_reading_stdout(self, Popen):
        popen = Popen.return_value
        popen.stdout.read.side_effect = Exception('some error...')
        self.assertRaises(
            tftp.WlTFtpDeviceRetrievingOutputFromCommandError,
            self.device.put,
            "any command"
        )

    @patch('subprocess.Popen')
    def test_put_create_popen_fail_reading_stderr(self, Popen):
        popen = Popen.return_value
        popen.stderr.read.side_effect = Exception('some error...')
        self.assertRaises(
            tftp.WlTFtpDeviceRetrievingOutputFromCommandError,
            self.device.put,
            "any command"
        )
Example #3
0
 def setUp(self):
     self.device = TFtpDevice("localhost", 69)
Example #4
0
 def setUp(self):
     self.device = TFtpDevice("localhost", 69)