def test_dump_reminders_one_tellee(tmpdir): tellee = 'Exirel' teller = 'dgw' verb = 'tell' timenow = '1569488444' msg_1 = 'You forgot an S in "élèves".' msg_2 = 'You forgot another S in "garçons".' tmpfile = tmpdir.join('tell.db') tell.dump_reminders(tmpfile.strpath, { tellee: [ (teller, verb, timenow, msg_1), (teller, verb, timenow, msg_2), ] }) assert os.path.exists(tmpfile.strpath) results = tell.load_reminders(tmpfile.strpath) assert len(results.keys()) == 1, 'There should be one key in results' assert tellee in results assert len(results[tellee]) == 2, 'There should be 2 messages in results' assert (teller, verb, timenow, msg_1) in results[tellee] assert (teller, verb, timenow, msg_2) in results[tellee]
def test_dump_reminders_multiple_tellees(tmpdir): tellee_1 = 'Exirel' tellee_2 = 'HumorBaby' teller = 'dgw' verb = 'tell' timenow = '1569488444' msg = 'Review requested for "àçé"' tmpfile = tmpdir.join('tell.db') tell.dump_reminders( tmpfile.strpath, { tellee_1: [(teller, verb, timenow, msg)], tellee_2: [(teller, verb, timenow, msg)], }) assert os.path.exists(tmpfile.strpath) results = tell.load_reminders(tmpfile.strpath) assert len(results.keys()) == 2, 'There should be two keys in results' assert tellee_1 in results assert tellee_2 in results assert len(results[tellee_1]) == 1, ('There should be 1 message for %s' % tellee_1) assert len(results[tellee_2]) == 1, ('There should be 1 message for %s' % tellee_2) assert (teller, verb, timenow, msg) in results[tellee_1] assert (teller, verb, timenow, msg) in results[tellee_2]
def test_dump_reminders_empty(tmpdir): tmpfile = tmpdir.join('tell.db') tell.dump_reminders(tmpfile.strpath, {}) assert os.path.exists(tmpfile.strpath) with io.open(tmpfile.strpath, 'r', encoding='utf-8') as fd: data = fd.read() assert not data, 'Data for empty tell should be empty'