def test_eval_args(self): with mock.patch('downstream_farmer.shell.check_connectivity') as check: check.side_effect = ConnectError('Oops') m = mock.Mock() with self.assertRaises(SystemExit): shell.eval_args(m) self.assertTrue(check.called) with mock.patch('downstream_farmer.shell.check_connectivity'): m.number = -1 with self.assertRaises(SystemExit): shell.eval_args(m) with mock.patch('downstream_farmer.shell.run_prototype') as rp: m.number = 2 shell.eval_args(m) self.assertTrue(rp.called)
def test_eval_args_catchall(self): with mock.patch('downstream_farmer.shell.Farmer') as farmer: farmer.side_effect = BaseException('error') with self.assertRaises(SystemExit): shell.eval_args(None)
def test_eval_args_downstream_error(self): with mock.patch('downstream_farmer.shell.Farmer') as farmer: farmer.side_effect = DownstreamError('error') with self.assertRaises(SystemExit): shell.eval_args(None)
def test_eval_args_run(self): with mock.patch('downstream_farmer.shell.Farmer') as farmer: shell.eval_args(mock.MagicMock()) self.assertTrue(farmer.called) self.assertTrue(farmer.return_value.run.called)
def test_eval_args_catchall(self): with mock.patch('downstream_farmer.shell.Farmer') as farmer: farmer.side_effect = BaseException('error') with self.assertRaises(SystemExit): shell.eval_args(None)
def test_eval_args_downstream_error(self): with mock.patch('downstream_farmer.shell.Farmer') as farmer: farmer.side_effect = DownstreamError('error') with self.assertRaises(SystemExit): shell.eval_args(None)
def test_eval_args_run(self): with mock.patch('downstream_farmer.shell.Farmer') as farmer: shell.eval_args(mock.MagicMock()) self.assertTrue(farmer.called) self.assertTrue(farmer.return_value.run.called)