from __future__ import absolute_import

from sentry.utils.avatar import get_letter_avatar


def test_letter_avatar():
    # Test name as display name and email as identifier
    letter_avatar = get_letter_avatar('Jane Doe', 'janedoe@example.com')
    assert 'JD' in letter_avatar
    assert '#E56AA6' in letter_avatar
    assert 'svg' in letter_avatar

    # Test email as display name and id as identifier
    letter_avatar = get_letter_avatar('johnsmith@example.com', 2)
    assert 'J' in letter_avatar
    assert '#6FBA57' in letter_avatar

    # Test no display name and ip address as identifier
    letter_avatar = get_letter_avatar(None, '127.0.0.1')
    assert '?' in letter_avatar
    assert '#E35141' in letter_avatar

    # Test display name with trailing spaces
    letter_avatar = get_letter_avatar('johnsmith@example.com ', 2)
    assert 'J' in letter_avatar
    assert '#6FBA57' in letter_avatar

    # Test name as display name and email as identifier for html
    letter_avatar = get_letter_avatar('Jane Doe', 'janedoe@example.com', use_svg=False)
    assert 'JD' in letter_avatar
    assert '#E56AA6' in letter_avatar
    assert 'span' in letter_avatar

    # Test email as display name and id as identifier for html
    letter_avatar = get_letter_avatar('johnsmith@example.com', 2, use_svg=False)
    assert 'J' in letter_avatar
    assert '#6FBA57' in letter_avatar

    # Test no display name and ip address as identifier for html
    letter_avatar = get_letter_avatar(None, '127.0.0.1', use_svg=False)
    assert '?' in letter_avatar
    assert '#E35141' in letter_avatar

@@ -278,38 +278,38 @@
 ar%0A    assert '#
-E56AA6
+f868bc
 ' in letter_avat
@@ -302,32 +302,40 @@
 in letter_avatar
+  # pink
 %0A    assert 'svg
@@ -511,38 +511,38 @@
 ar%0A    assert '#
-6FBA57
+57be8c
 ' in letter_avat
@@ -535,32 +535,41 @@
 in letter_avatar
+  # green
 %0A%0A    # Test no 
@@ -704,38 +704,38 @@
 ar%0A    assert '#
-E35141
+ec5e44
 ' in letter_avat
@@ -728,32 +728,39 @@
 in letter_avatar
+  # red
 %0A%0A    # Test dis
@@ -894,38 +894,38 @@
 ar%0A    assert '#
-6FBA57
+57be8c
 ' in letter_avat
@@ -918,32 +918,41 @@
 in letter_avatar
+  # green
 %0A%0A    # Test nam
@@ -1140,14 +1140,14 @@
 t '#
-E56AA6
+f868bc
 ' in
@@ -1152,32 +1152,40 @@
 in letter_avatar
+  # pink
 %0A    assert 'spa
@@ -1398,14 +1398,14 @@
 t '#
-6FBA57
+57be8c
 ' in
@@ -1410,32 +1410,41 @@
 in letter_avatar
+  # green
 %0A%0A    # Test no 
@@ -1615,14 +1615,14 @@
 t '#
-E35141
+ec5e44
 ' in
@@ -1619,25 +1619,32 @@
 ec5e44' in letter_avatar
+  # red
 %0A

fix letter avatar python test