Пример #1
0
def test_get_by_email():
    uc = UserCache()
    uc.update('David Bowie')
    uc.update('David Robert Jones <*****@*****.**>')
    uc.update('David Bowie <*****@*****.**>')
    uc.update('*****@*****.**')

    assert uc.get('*****@*****.**')['email'] == '*****@*****.**'
Пример #2
0
def build_user_cache(rawdata):
    """
    Go over all scm data to build a full UserCache
    """
    uc = UserCache()
    for typ, data in rawdata:
        for role in ROLES & set(data.keys()):
            for ustring in data[role]:
                uc.update(ustring)
    return uc
Пример #3
0
def build_user_cache(rawdata):
    """
    Go over all scm data to build a full UserCache
    """
    uc = UserCache()
    for typ, data in rawdata:
        for role in ROLES & set(data.keys()):
            for ustring in data[role]:
                uc.update(ustring)
    return uc
Пример #4
0
def test_user_without_email_will_be_ignored():
    uc = UserCache()
    uc.update('Brian May')
    uc.update('Roger Taylor')
    uc.update('Freddie Mercury <*****@*****.**>')

    assert uc.get('Brian May') is None
    assert uc.all() == [{
        'first_name': 'Freddie',
        'last_name': 'Mercury',
        'email': '*****@*****.**'
    }]
Пример #5
0
def test_merge_3_forms():
    uc = UserCache()
    uc.update('David Bowie')
    uc.update('*****@*****.**')
    uc.update('David Bowie <*****@*****.**>')

    assert uc.all() == [{
        'first_name': 'David',
        'last_name': 'Bowie',
        'email': '*****@*****.**'
    }]
Пример #6
0
def test_user_without_email_will_be_ignored():
    uc = UserCache()
    uc.update('Brian May')
    uc.update('Roger Taylor')
    uc.update('Freddie Mercury <*****@*****.**>')

    assert uc.get('Brian May') is None
    assert uc.all() == [
        {'first_name': 'Freddie',
         'last_name': 'Mercury',
         'email': '*****@*****.**'}
        ]
Пример #7
0
def test_merge_3_forms():
    uc = UserCache()
    uc.update('David Bowie')
    uc.update('*****@*****.**')
    uc.update('David Bowie <*****@*****.**>')

    assert uc.all() == [
        {'first_name': 'David',
         'last_name': 'Bowie',
         'email': '*****@*****.**'}]
Пример #8
0
def test_get_by_full():
    uc = UserCache()
    uc.update('*****@*****.**')
    uc.update('David Bowie <*****@*****.**>')

    assert uc.get('David Bowie <*****@*****.**>') == {
        'first_name': 'David',
        'last_name': 'Bowie',
        'email': '*****@*****.**'
    }
Пример #9
0
def test_cannot_merge_name_and_email():
    uc = UserCache()
    uc.update('David Bowie')
    uc.update('*****@*****.**')

    assert uc.all() == [
        {
            'first_name': '',
            'last_name': '',
            'email': '*****@*****.**'
        },
    ]
Пример #10
0
def test_get_by_name():
    uc = UserCache()
    uc.update('David Bowie')
    uc.update('David Bowie <*****@*****.**>')

    assert uc.get('David Bowie') == {
        'first_name': 'David',
        'last_name': 'Bowie',
        'email': '*****@*****.**'}
Пример #11
0
def test_cannot_merge_diff_emails():
    uc = UserCache()
    uc.update('*****@*****.**')
    uc.update('*****@*****.**')

    assert uc.all() == [
        {'first_name': '', 'last_name': '', 'email': '*****@*****.**'},
        {'first_name': '', 'last_name': '', 'email': '*****@*****.**'},
        ]
Пример #12
0
def test_cannot_merge_name_and_email():
    uc = UserCache()
    uc.update('David Bowie')
    uc.update('*****@*****.**')

    assert uc.all() == [
        {'first_name': '',
         'last_name': '',
         'email': '*****@*****.**'},
        ]
Пример #13
0
def test_cannot_merge_diff_emails():
    uc = UserCache()
    uc.update('*****@*****.**')
    uc.update('*****@*****.**')

    assert uc.all() == [
        {
            'first_name': '',
            'last_name': '',
            'email': '*****@*****.**'
        },
        {
            'first_name': '',
            'last_name': '',
            'email': '*****@*****.**'
        },
    ]
Пример #14
0
def test_different_names_with_the_same_email():
    uc = UserCache()
    uc.update('David Bowie')
    uc.update('David Robert Jones <*****@*****.**>')
    uc.update('David Bowie <*****@*****.**>')
    uc.update('David Robert Jones')
    uc.update('Bowie David <*****@*****.**>')

    users = uc.all()
    assert len(users) == 1 and users[0]['email'] == '*****@*****.**'
Пример #15
0
def test_cannot_merge_diff_names():
    uc = UserCache()
    uc.update('Eric Clapton')
    uc.update('Eric Johnson')

    assert uc.all() == []
Пример #16
0
def test_get_by_email():
    uc = UserCache()
    uc.update('David Bowie')
    uc.update('David Robert Jones <*****@*****.**>')
    uc.update('David Bowie <*****@*****.**>')
    uc.update('*****@*****.**')

    assert uc.get('*****@*****.**')['email'] == '*****@*****.**'
Пример #17
0
def test_different_names_with_the_same_email():
    uc = UserCache()
    uc.update('David Bowie')
    uc.update('David Robert Jones <*****@*****.**>')
    uc.update('David Bowie <*****@*****.**>')
    uc.update('David Robert Jones')
    uc.update('Bowie David <*****@*****.**>')

    users = uc.all()
    assert len(users) == 1 and users[0]['email'] == '*****@*****.**'
Пример #18
0
def test_cannot_merge_diff_names():
    uc = UserCache()
    uc.update('Eric Clapton')
    uc.update('Eric Johnson')

    assert uc.all() == []