Beispiel #1
0
def test_empty_text_loop():
    price_tracker = price_tracker_fake("45")
    twilio = twilio_fake()
    texter = Texter()
    texter.set_clients(price_tracker, twilio.send_message)

    texter.check_alerts()
    assert len(twilio.messages) == 0
    assert len(twilio.to) == 0
Beispiel #2
0
def test_invalid_number_below(capsys):
    price_tracker = price_tracker_fake("45")
    send_message = Mock()
    send_message.side_effect = (twilio.base.exceptions.TwilioRestException(
        Mock(), Mock()))
    texter = Texter()
    texter.set_clients(price_tracker, send_message)
    alert = Alert(symbol='BTC', price=100.0, condition=0, phone_number='5555')
    db.session.add(alert)
    db.session.commit()
    texter.check_alerts()
    out, err = capsys.readouterr()
    assert "Invalid number" in out
Beispiel #3
0
def test_price_tracker_integration():
    price_tracker = PriceTracker()
    twilio = twilio_fake()
    texter = Texter()
    texter.set_clients(price_tracker, twilio.send_message)
    alert = Alert(symbol='BTC',
                  price=100.0,
                  condition=1,
                  phone_number='555-555-5555',
                  market='coinbase')
    db.session.add(alert)
    db.session.commit()

    texter.check_alerts()
Beispiel #4
0
def test_single_entry_no_text():
    price_tracker = price_tracker_fake("45")
    twilio = twilio_fake()
    texter = Texter()
    texter.set_clients(price_tracker, twilio.send_message)
    alert = Alert(symbol='BTC',
                  price=100.0,
                  condition=1,
                  phone_number='555-555-5555')
    db.session.add(alert)
    db.session.commit()

    texter.check_alerts()
    assert len(twilio.messages) == 0
    assert len(twilio.to) == 0
Beispiel #5
0
def test_single_text_loop_below():
    price_tracker = price_tracker_fake("5")
    twilio = twilio_fake()
    texter = Texter()
    texter.set_clients(price_tracker, twilio.send_message)

    alert = Alert(symbol='BTC',
                  price=10.0,
                  condition=0,
                  phone_number='555-555-5555')
    db.session.add(alert)
    db.session.commit()

    texter.check_alerts()
    assert len(twilio.messages) == 1
    assert len(twilio.to) == 1
    assert 'below' in twilio.messages[0]
    assert 'BTC' in twilio.messages[0]
    assert twilio.to[0] == '555-555-5555'
Beispiel #6
0
def test_include_market_above():
    price_tracker = price_tracker_fake("5")
    twilio = twilio_fake()
    texter = Texter()
    texter.set_clients(price_tracker, twilio.send_message)

    alert = Alert(symbol='ETH',
                  price=2,
                  condition=1,
                  phone_number='1234567890',
                  market='coinbase')
    db.session.add(alert)
    db.session.commit()

    texter.check_alerts()
    assert len(twilio.messages) == 1
    assert len(twilio.to) == 1
    assert 'above' in twilio.messages[0]
    assert 'ETH' in twilio.messages[0]
    assert twilio.to[0] == '1234567890'
Beispiel #7
0
def test_single_text_loop_decrease():
    price_tracker = price_tracker_fake("5", "-5")
    twilio = twilio_fake()
    texter = Texter()
    texter.set_clients(price_tracker, twilio.send_message)

    alert = Alert(symbol='BTC',
                  percent=4.0,
                  percent_duration=86400,
                  condition=3,
                  phone_number='555-555-5555')
    db.session.add(alert)
    db.session.commit()

    texter.check_alerts()
    assert len(twilio.messages) == 1
    assert len(twilio.to) == 1
    assert 'decreased by' in twilio.messages[0]
    assert '24 hours' in twilio.messages[0]
    assert 'BTC' in twilio.messages[0]
    assert twilio.to[0] == '555-555-5555'