Example #1
0
def test_add_note():
    """Assert that notes are added to the usernotes wiki page."""
    un = UserNotes(r, my_sub, lazy_start=True)
    note_message = 'test note {}'.format(random.random())
    new_note = Note('teaearlgraycold', note_message, warning='gooduser')
    un.add_note(new_note)
    stored_json = un.get_json()
    messages = {x['n'] for x in stored_json['users']['teaearlgraycold']['ns']}

    assert note_message in messages
Example #2
0
def test_init_notes():
    """Assert that the puni init_notes function sends new JSON to the wiki page"""

    un = UserNotes(r, my_sub)
    un.init_notes()
    stored_json = un.get_json()

    assert stored_json['ver'] == un.schema
    assert stored_json['users'] == {}
    assert stored_json['constants']['users'] == [x.name for x in my_sub.get_moderators()]
    assert stored_json['constants']['warnings'] == Note.warnings
Example #3
0
def test_init_notes():
    """Assert that the puni init_notes function sends new JSON to the wiki page."""
    un = UserNotes(r, my_sub)
    un._init_notes()
    stored_json = un.get_json()
    moderators = [x.name for x in my_sub.moderator()]

    assert stored_json['ver'] == un.schema
    assert stored_json['users'] == {}
    assert stored_json['constants']['users'] == moderators
    assert stored_json['constants']['warnings'] == Note.warnings
Example #4
0
def test_add_note():
    """Assert that notes are added to the usernotes wiki page"""
    un = UserNotes(r, my_sub, lazy_start=True)

    note_message = "test note {}".format(random.random())
    new_note = Note("teaearlgraycold", note_message, warning='gooduser')

    un.add_note(new_note)
    stored_json = un.get_json()

    for note in stored_json['users']['teaearlgraycold']['ns']:
        if note['n'] == note_message:
            break
    else:
        assert False  # Did not reach a note with the sent message
Example #5
0
def test_add_note():
    """Assert that notes are added to the usernotes wiki page"""
    un = UserNotes(r, my_sub, lazy_start=True)

    note_message = "test note {}".format(random.random())
    new_note = Note("teaearlgraycold", note_message, warning='gooduser')

    un.add_note(new_note)
    stored_json = un.get_json()

    for note in stored_json['users']['teaearlgraycold']['ns']:
        if note['n'] == note_message:
            break
    else:
        assert False  # Did not reach a note with the sent message