Exemple #1
0
 def test_run_jobs(self, capsys):
     with patch.multiple(pbm,
                         autospec=True,
                         logger=DEFAULT,
                         parse_args=DEFAULT,
                         set_log_debug=DEFAULT,
                         set_log_info=DEFAULT,
                         Config=DEFAULT,
                         EcsJobsRunner=DEFAULT) as mocks:
         mocks['parse_args'].return_value = MockArgs(
             ACTION='run',
             SCHEDULES=[],
             verbose=1,
             jobs=['joba', 'jobb'],
             only_email_if_problems=True)
         main(['run', '-j', 'joba', '--job=jobb'])
     assert mocks['logger'].mock_calls == []
     assert mocks['parse_args'].mock_calls == [
         call(['run', '-j', 'joba', '--job=jobb'])
     ]
     assert mocks['set_log_debug'].mock_calls == []
     assert mocks['set_log_info'].mock_calls == [call(logging.getLogger())]
     assert mocks['Config'].mock_calls == [call()]
     assert mocks['EcsJobsRunner'].mock_calls == [
         call(mocks['Config'].return_value, only_email_if_problems=True),
         call().run_job_names(['joba', 'jobb'])
     ]
Exemple #2
0
 def test_list_schedules(self, capsys):
     with patch.multiple(pbm,
                         autospec=True,
                         logger=DEFAULT,
                         parse_args=DEFAULT,
                         set_log_debug=DEFAULT,
                         set_log_info=DEFAULT,
                         Config=DEFAULT,
                         EcsJobsRunner=DEFAULT) as mocks:
         mocks['parse_args'].return_value = MockArgs(
             ACTION='list-schedules')
         type(mocks['Config'].return_value).schedule_names = \
             PropertyMock(return_value=['foo', 'bar', 'baz'])
         with pytest.raises(SystemExit) as exc:
             main(['list-schedules'])
     assert exc.value.code == 0
     assert mocks['logger'].mock_calls == []
     assert mocks['parse_args'].mock_calls == [call(['list-schedules'])]
     assert mocks['set_log_debug'].mock_calls == []
     assert mocks['set_log_info'].mock_calls == []
     assert mocks['Config'].mock_calls == [call()]
     assert mocks['EcsJobsRunner'].mock_calls == []
     out, err = capsys.readouterr()
     assert err == ''
     assert out == "foo\nbar\nbaz\n"
Exemple #3
0
 def test_version(self):
     with patch.multiple(pbm,
                         autospec=True,
                         logger=DEFAULT,
                         parse_args=DEFAULT,
                         set_log_debug=DEFAULT,
                         set_log_info=DEFAULT,
                         Config=DEFAULT,
                         EcsJobsRunner=DEFAULT) as mocks:
         mocks['parse_args'].side_effect = SystemExit(0)
         with patch('%s.sys.argv' % pbm, ['foo', '-V']):
             with pytest.raises(SystemExit):
                 main()
     assert mocks['logger'].mock_calls == []
     assert mocks['parse_args'].mock_calls == [call(['-V'])]
     assert mocks['set_log_debug'].mock_calls == []
     assert mocks['set_log_info'].mock_calls == []
     assert mocks['Config'].mock_calls == []
     assert mocks['EcsJobsRunner'].mock_calls == []
Exemple #4
0
 def test_validate(self):
     with patch.multiple(pbm,
                         autospec=True,
                         logger=DEFAULT,
                         parse_args=DEFAULT,
                         set_log_debug=DEFAULT,
                         set_log_info=DEFAULT,
                         Config=DEFAULT,
                         EcsJobsRunner=DEFAULT) as mocks:
         mocks['parse_args'].return_value = MockArgs(ACTION='validate',
                                                     verbose=2)
         with pytest.raises(SystemExit) as exc:
             main(['validate'])
     assert exc.value.code == 0
     assert mocks['logger'].mock_calls == []
     assert mocks['parse_args'].mock_calls == [call(['validate'])]
     assert mocks['set_log_debug'].mock_calls == [call(logging.getLogger())]
     assert mocks['set_log_info'].mock_calls == []
     assert mocks['Config'].mock_calls == [call()]
     assert mocks['EcsJobsRunner'].mock_calls == []