Ejemplo n.º 1
0
def test_process_mail(capsys):
    sch = Scheduler()
    event = Scheduler.create_event('test', '2221-01-30 19:25:00', how='mail')

    sch.process_event(event)

    events = sch.get_events()
    p = capsys.readouterr()
    cp = capsys.readouterr()
    assert not cp.out
    assert not cp.err
    assert events
Ejemplo n.º 2
0
def test_process_sms(capsys):
    sch = Scheduler()
    event = Scheduler.create_event('test', '2221-01-30 19:25:00', how='SMS')

    with pytest.raises(Exception) as excinfo:
        sch.process_event(event)

    events = sch.get_events()
    p = capsys.readouterr()
    cp = capsys.readouterr()
    assert not cp.out
    assert not cp.err
    assert not events
Ejemplo n.º 3
0
def add_event():
    """Adds event to scheduler."""
    for atr in ['name', 'when', 'how']:
        if atr not in request.get_json():
            abort(400)
    
    if not verify_signature(request):
        abort(400)

    json = request.get_json()
    event = Scheduler.create_event(name=json.get('name'), when=json.get('when'), how=json.get('how'),  receiver=json.get('receiver'), message=json.get('message'), subject=json.get('subject'))
    sch.process_event(event)

    return '', 200
Ejemplo n.º 4
0
def test_create_event_with_wrong_date(capsys):
    with pytest.raises(Exception) as excinfo:
        Scheduler.create_event('test', 'test')
    cp = capsys.readouterr()
    assert not cp.out
    assert 'Could not match input to any of' in str(excinfo.value)
Ejemplo n.º 5
0
def test_create_event(capsys):
    Scheduler.create_event('test', '2021-01-30 19:25:00')
    cp = capsys.readouterr()
    assert not cp.err