Ejemplo n.º 1
0
 def test_sftp_failure(self, sftp_hook_mock):
     sftp_hook_mock.return_value.get_mod_time.side_effect = OSError(
         SFTP_FAILURE, 'SFTP failure')
     sftp_sensor = SFTPSensor(task_id='unit_test',
                              path='/path/to/file/1970-01-01.txt')
     context = {'ds': '1970-01-01'}
     with self.assertRaises(OSError):
         sftp_sensor.poke(context)
         sftp_hook_mock.return_value.get_mod_time.assert_called_with(
             '/path/to/file/1970-01-01.txt')
Ejemplo n.º 2
0
 def test_sftp_failure(self, sftp_hook_mock):
     sftp_hook_mock.return_value.get_mod_time.side_effect = IOError(
         SFTP_FAILURE, 'SFTP failure')
     sftp_sensor = SFTPSensor(
         task_id='unit_test',
         path='/path/to/file/1970-01-01.txt')
     context = {
         'ds': '1970-01-01'
     }
     with self.assertRaises(IOError):
         sftp_sensor.poke(context)
         sftp_hook_mock.return_value.get_mod_time.assert_called_with(
             '/path/to/file/1970-01-01.txt')
Ejemplo n.º 3
0
 def test_file_present(self, sftp_hook_mock):
     sftp_hook_mock.return_value.get_mod_time.return_value = '19700101000000'
     sftp_sensor = SFTPSensor(task_id='unit_test',
                              path='/path/to/file/1970-01-01.txt')
     context = {'ds': '1970-01-01'}
     output = sftp_sensor.poke(context)
     sftp_hook_mock.return_value.get_mod_time.assert_called_with(
         '/path/to/file/1970-01-01.txt')
     self.assertTrue(output)
Ejemplo n.º 4
0
 def test_file_absent(self, sftp_hook_mock):
     sftp_hook_mock.return_value.get_mod_time.side_effect = OSError(
         SFTP_NO_SUCH_FILE, 'File missing')
     sftp_sensor = SFTPSensor(task_id='unit_test',
                              path='/path/to/file/1970-01-01.txt')
     context = {'ds': '1970-01-01'}
     output = sftp_sensor.poke(context)
     sftp_hook_mock.return_value.get_mod_time.assert_called_with(
         '/path/to/file/1970-01-01.txt')
     self.assertFalse(output)
Ejemplo n.º 5
0
 def test_file_present(self, sftp_hook_mock):
     sftp_hook_mock.return_value.get_mod_time.return_value = '19700101000000'
     sftp_sensor = SFTPSensor(
         task_id='unit_test',
         path='/path/to/file/1970-01-01.txt')
     context = {
         'ds': '1970-01-01'
     }
     output = sftp_sensor.poke(context)
     sftp_hook_mock.return_value.get_mod_time.assert_called_with(
         '/path/to/file/1970-01-01.txt')
     self.assertTrue(output)
Ejemplo n.º 6
0
 def test_file_absent(self, sftp_hook_mock):
     sftp_hook_mock.return_value.get_mod_time.side_effect = IOError(
         SFTP_NO_SUCH_FILE, 'File missing')
     sftp_sensor = SFTPSensor(
         task_id='unit_test',
         path='/path/to/file/1970-01-01.txt')
     context = {
         'ds': '1970-01-01'
     }
     output = sftp_sensor.poke(context)
     sftp_hook_mock.return_value.get_mod_time.assert_called_with(
         '/path/to/file/1970-01-01.txt')
     self.assertFalse(output)