예제 #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 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'] == '*****@*****.**'
예제 #3
0
def test_merge_full_and_email():
    uc = UserCache()
    uc.update('David Bowie <*****@*****.**>')
    uc.update('*****@*****.**')

    assert uc.all() == [{
        'first_name': 'David',
        'last_name': 'Bowie',
        'email': '*****@*****.**'
    }]
예제 #4
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': '*****@*****.**'
    }
예제 #5
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
예제 #6
0
def test_cannot_merge_name_and_email():
    uc = UserCache()
    uc.update('David Bowie')
    uc.update('*****@*****.**')

    assert uc.all() == [
        {
            'first_name': '',
            'last_name': '',
            'email': '*****@*****.**'
        },
    ]
예제 #7
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': '*****@*****.**'
    }]
예제 #8
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': '*****@*****.**'
        },
    ]
예제 #9
0
def test_cannot_merge_diff_names():
    uc = UserCache()
    uc.update('Eric Clapton')
    uc.update('Eric Johnson')

    assert uc.all() == []