Esempio n. 1
0
def test_translate_for_user():
    user = User("testtest")
    user.locale = "en_US"
    uc = UserContext(user)
    assert uc._("New Chat") == "New Chat"
    user.locale = "fr_FR"
    assert uc._("New Chat") == "Nouveau chat"
    user.locale = "ar_AR"
    assert uc._("New Chat") == "دردشة جديدة"
Esempio n. 2
0
def main(args):
    text = "A lot of people are using Chatty.\n" \
           "Let's talk with them!"
    if args.test_to is None:
        from chatty.domain.model import match, notification
        now = datetime.datetime.utcnow()
        session = Session()
        for u in match.User.inactive_user(now, args.limit, args.gender):
            if u.locale != args.locale:
                continue
            print "candidate", u.id
            uc = UserContext(u)
            if not notification.Notification.notified_thesedays(now, u.id):
                try:
                    uc.send_btn(uc._(text),
                                [uc.langb(), uc.new_chat()], "NOTIFICATION1")
                except Exception as e:
                    notification.Notification.create(
                        u.id, "A lot of people are using Chatty", False)
                    logger.error(e)
                else:
                    notification.Notification.create(
                        u.id, "A lot of people are using Chatty", True)
                time.sleep(2)
        session.commit()
        session.close()
    else:
        fb.send_data(fb.button_data(args.test_to, text, "NOTIFICATION"))