-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_quote.py
More file actions
47 lines (36 loc) · 1.61 KB
/
Copy pathtest_quote.py
File metadata and controls
47 lines (36 loc) · 1.61 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
39
40
41
42
43
44
45
46
47
import os
import unittest
import quote
from errbot.backends.test import FullStackTest
class TestFileFunctions(unittest.TestCase):
def test_get_quote(self):
qv = quote.get_quote()
self.assertEqual(qv['quote'], 'What gets measured, gets managed.')
self.assertEqual(qv['attribution'], 'Peter Drucker')
class TestQuoteBotCommands(FullStackTest):
def setUp(self):
super(TestQuoteBotCommands, self).setUp(
extra_plugin_dir='/home/jeffx/Projects/errbot/plugins',
loglevel=50)
def test_quote(self):
self.assertCommand('!quote',
'What gets measured, gets managed.\n'
' --Peter Drucker')
def test_quote_add(self):
self.assertCommand('!quote add If heavy metal bands ruled the world,'
' we\'d be a lot better off;Bruce Dickinson',
'Quote added')
def test_quote_add_no_attribution(self):
self.assertCommand('!quote add I\'m a bad quote',
'Usage: !quote <quote>, <attribution>')
def test_quote_add_usage(self):
self.assertCommand('!quote add',
'Usage: !quote <quote>, <attribution>')
def test_quote_add_quote_in_file(self):
self.push_message('!quote add Message in file;Mary Sue')
rv = self.pop_message()
location = os.path.dirname(__file__)
quote_file = "{}/data/quotes.txt".format(location)
with open(quote_file, 'r') as fh:
contents = fh.read().splitlines()
assert contents[-1] == "Message in file;Mary Sue"