-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathtest_emojione.py
More file actions
38 lines (30 loc) · 1.42 KB
/
test_emojione.py
File metadata and controls
38 lines (30 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# -*- coding: utf-8; -*-
from __future__ import unicode_literals
from unittest import TestCase
from emojipy import Emoji
class EmojipyTest(TestCase):
def setUp(self):
pass
def test_unicode_to_image(self):
txt = 'Hello world! 😄 :smile:'
expected = """Hello world! <img class="joypixels" alt="😄" src="https://cdn.jsdelivr.net/joypixels/assets/4.5/png/64/1f604.png"/> :smile:"""
self.assertEqual(Emoji.unicode_to_image(txt), expected)
def test_shortcode_to_image(self):
txt = 'Hello world! 😄 :smile:'
expected = """Hello world! 😄 <img class="joypixels" alt="😄" src="https://cdn.jsdelivr.net/joypixels/assets/4.5/png/64/1f604.png"/>"""
self.assertEqual(Emoji.shortcode_to_image(txt), expected)
Emoji.unicode_alt = False
expected = """Hello world! 😄 <img class="joypixels" alt=":smile:" src="https://cdn.jsdelivr.net/joypixels/assets/4.5/png/64/1f604.png"/>"""
self.assertEqual(Emoji.shortcode_to_image(txt), expected)
Emoji.unicode_alt = True
def test_shortcode_to_ascii(self):
txt = 'Hello world! 😄 :slight_smile:'
expected = [
'Hello world! 😄 :]',
'Hello world! 😄 :-)',
'Hello world! 😄 =)',
'Hello world! 😄 :)',
'Hello world! 😄 =]'
]
output = Emoji.shortcode_to_ascii(txt)
self.assertIn(output, expected)