示例#1
0
def test_send_sms_does_nothing_if_user_does_not_allow_it(smsoutbox):
    user = OnboardingInfoFactory(can_we_sms=False).user
    assert user.send_sms("hello there") == twilio.SendSmsResult(
        err_code=twilio.TWILIO_USER_OPTED_OUT_ERR)
    user.send_sms_async("hello there")
    user.chain_sms_async(["hello there"])
    assert len(smsoutbox) == 0
示例#2
0
def test_send_sms_works_if_user_allows_it(smsoutbox):
    def assert_sms_was_sent():
        assert len(smsoutbox) == 1
        assert smsoutbox[0].to == "+15551234500"
        assert smsoutbox[0].body == "hello there"
        smsoutbox[:] = []

    user = OnboardingInfoFactory(can_we_sms=True,
                                 user__phone_number="5551234500").user
    assert user.send_sms("hello there")
    assert_sms_was_sent()
    user.send_sms_async("hello there")
    assert_sms_was_sent()
    user.chain_sms_async(["hello there"])
    assert_sms_was_sent()