~ubuntu-branches/ubuntu/utopic/gozerbot/utopic

« back to all changes in this revision

Viewing changes to plugtests/test_grep.py

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Malcolm
  • Date: 2009-09-14 09:00:29 UTC
  • mfrom: (1.1.4 upstream) (3.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20090914090029-uval0ekt72kmklxw
Tags: 0.9.1.3-3
Changed dependency on python-setuptools to python-pkg-resources
(Closes: #546435) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# tests/test_grep.py
2
 
#
3
 
#
4
 
 
5
 
__copyright__ = 'this file is in the public domain'
6
 
 
7
 
from gozerbot.bot import Bot
8
 
from gozerbot.generic import stringinlist, waitforqueue
9
 
from gozerbot.plugins import plugins
10
 
import unittest, Queue
11
 
 
12
 
plugins.reload('gozerplugs.plugs', 'grep')
13
 
 
14
 
class test_grep(unittest.TestCase):
15
 
    b = Bot()
16
 
    b.userhosts['test'] = 'test@test'
17
 
 
18
 
    def test_grep(self):
19
 
        result = self.b.test('grep')
20
 
        self.assert_(stringinlist('use grep', result))
21
 
 
22
 
    def test_grep2(self):
23
 
        q = Queue.Queue()
24
 
        q.put('b')
25
 
        q.put(None)
26
 
        result = self.b.test('grep', kw = {'inqueue': q })
27
 
        self.assert_(stringinlist('grep <txt>', result))
28
 
 
29
 
    def test_grep3(self):
30
 
        q = Queue.Queue()
31
 
        q.put(None)
32
 
        result = self.b.test('grep a', kw = {'inqueue': q })
33
 
        self.assert_(stringinlist('no data', result))
34
 
 
35
 
    def test_grep4(self):
36
 
        q = Queue.Queue()
37
 
        q.put('a')
38
 
        q.put('b')
39
 
        q.put(None)
40
 
        result = self.b.test('grep a', kw = {'inqueue': q })
41
 
        self.assert_(stringinlist('a', result))
42
 
 
43
 
    def test_grep5(self):
44
 
        q = Queue.Queue()
45
 
        q.put('A')
46
 
        q.put('B')
47
 
        q.put(None)
48
 
        result = self.b.test('grep -i a', kw = {'inqueue': q })
49
 
        self.assert_(stringinlist('A', result))
50
 
 
51
 
    def test_grep6(self):
52
 
        q = Queue.Queue()
53
 
        q.put('A')
54
 
        q.put('B')
55
 
        q.put(None)
56
 
        result = self.b.test('grep -v A', kw = {'inqueue': q })
57
 
        self.assert_(stringinlist('B', result))
58
 
 
59
 
    def test_grep7(self):
60
 
        q = Queue.Queue()
61
 
        q.put('A')
62
 
        q.put('B')
63
 
        q.put(None)
64
 
        result = self.b.test('grep -r .*', kw = {'inqueue': q })
65
 
        self.assert_(stringinlist('B', result))