-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot_tests.py
55 lines (42 loc) · 2.01 KB
/
bot_tests.py
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import bot
import unittest
class TestBot(unittest.TestCase):
def setUp(self):
self.vendors = bot.load_vendors()
def test_name_present(self):
mentions = bot.get_vendors_mentioned("like What-Cha like", self.vendors)
self.assertTrue(mentions)
def test_name_present_casing(self):
mentions = bot.get_vendors_mentioned("like wHat-Cha like", self.vendors)
self.assertTrue(mentions)
def test_name_present_yunnan_sourcing(self):
mentions = bot.get_vendors_mentioned("like yunnan sourcing like", self.vendors)
self.assertTrue(mentions)
def test_exact_name_not_present_yunnan_sourcing(self):
mentions = bot.get_vendors_mentioned("like yunnan-sourcing like", self.vendors)
self.assertFalse(mentions)
def test_username_present(self):
mentions = bot.get_vendors_mentioned("like /u/yunnanSourcing like", self.vendors)
self.assertTrue(mentions)
def test_username_not_present(self):
mentions = bot.get_vendors_mentioned("like /u/yunnanSourcin like", self.vendors)
self.assertFalse(mentions)
def test_url_present(self):
mentions = bot.get_vendors_mentioned("like https://yunnanSourcing.com like", self.vendors)
self.assertTrue(mentions)
def test_nickname_present(self):
mentions = bot.get_vendors_mentioned("like whatCHA like", self.vendors)
self.assertTrue(mentions)
def test_nickname_present_punctuation(self):
mentions = bot.get_vendors_mentioned("like whatCHA's like", self.vendors)
self.assertTrue(mentions)
def test_multiple_mentions(self):
t = "like WhatCha or Yunnan Sourcing or Yunomi?"
mentions = bot.get_vendors_mentioned(t, self.vendors)
self.assertTrue(len(mentions) == 3)
def test_duplicate_mentions(self):
t = "like WhatCha or whatcha or what-cha or what-cha.com?"
mentions = bot.get_vendors_mentioned(t, self.vendors)
self.assertTrue(len(mentions) == 1)
if __name__ == "__main__":
unittest.main()