Ejemplo n.º 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'] == '*****@*****.**'
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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': '*****@*****.**'
    }]
Ejemplo n.º 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': '*****@*****.**'
    }]
Ejemplo n.º 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': '*****@*****.**'}
        ]
Ejemplo n.º 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': '*****@*****.**'}]
Ejemplo n.º 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': '*****@*****.**'
    }
Ejemplo n.º 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': '*****@*****.**'
        },
    ]
Ejemplo n.º 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': '*****@*****.**'}
Ejemplo n.º 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': '*****@*****.**'},
        ]
Ejemplo n.º 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': '*****@*****.**'},
        ]
Ejemplo n.º 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': '*****@*****.**'
        },
    ]
Ejemplo n.º 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'] == '*****@*****.**'
Ejemplo n.º 15
0
def test_cannot_merge_diff_names():
    uc = UserCache()
    uc.update('Eric Clapton')
    uc.update('Eric Johnson')

    assert uc.all() == []
Ejemplo n.º 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'] == '*****@*****.**'
Ejemplo n.º 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'] == '*****@*****.**'
Ejemplo n.º 18
0
def test_cannot_merge_diff_names():
    uc = UserCache()
    uc.update('Eric Clapton')
    uc.update('Eric Johnson')

    assert uc.all() == []