def test_help(capsys): main = PiWheelsSlave() with pytest.raises(SystemExit): main(['--help']) out, err = capsys.readouterr() assert out.startswith('usage:') assert '--master' in out
def test_no_root(caplog): main = PiWheelsSlave() with mock.patch('os.geteuid') as geteuid: geteuid.return_value = 0 assert main([]) != 0 assert find_message(caplog.records, message='Slave must not be run as root')
def test_bad_clock(caplog): main = PiWheelsSlave() with mock.patch('piwheels.slave.datetime') as dt: dt.side_effect = datetime dt.now.return_value = datetime(2000, 1, 1, tzinfo=timezone.utc) assert main([]) != 0 assert find_message(caplog.records, message='System clock is far in the past')
def test_version(capsys): main = PiWheelsSlave() with pytest.raises(SystemExit): main(['--version']) out, err = capsys.readouterr() assert out.strip() == __version__
def slave_thread(request, mock_context, mock_systemd, tmpdir): main = PiWheelsSlave() slave_thread = Thread(daemon=True, target=main, args=([], )) yield slave_thread