diff options
author | kongr45gpen <electrovesta@gmail.com> | 2014-04-28 19:07:21 +0300 |
---|---|---|
committer | kongr45gpen <electrovesta@gmail.com> | 2014-04-28 19:07:21 +0300 |
commit | 4665d27418eb4a426f6ff52352285d6430ba0841 (patch) | |
tree | 30901457e418f1f2e4c866f32f13782a31a14273 /test.py | |
parent | ac155dc4e25a6c91d36d9c7b5f8bed9aacbb426c (diff) | |
download | supybot_github-4665d27418eb4a426f6ff52352285d6430ba0841.tar.gz supybot_github-4665d27418eb4a426f6ff52352285d6430ba0841.tar.bz2 supybot_github-4665d27418eb4a426f6ff52352285d6430ba0841.zip |
Make tests look Rubyish
Diffstat (limited to 'test.py')
-rw-r--r-- | test.py | 51 |
1 files changed, 11 insertions, 40 deletions
@@ -1,12 +1,10 @@ ### - from supybot.log import info from supybot.test import * -import re -import urllib +from local.testing.ExpectationPluginTestCase import * -class GithubTestCase(ChannelPluginTestCase): +class GithubTestCase(ExpectationPluginTestCase): plugins = ('Github',) port = 27230 files = {} @@ -14,54 +12,27 @@ class GithubTestCase(ChannelPluginTestCase): 'plugins.github.hidePush': False } - def assertContains(self, query, expectedNeedle, flags=re.I, **kwargs): - regex = re.compile("((\x02)|(\x03))(?:\d{1,2}(?:,\d{1,2})?)?", re.UNICODE) - - m = self._feedMsg(query, **kwargs) - messageString = regex.sub('', m.args[1]) - if m is None: - raise TimeoutError, query - self.failUnless(re.search(expectedNeedle, messageString, flags), - '%r does not match %r' % (messageString, expectedNeedle)) - return m - def setUp(self): # Set a different port from the default one to make testing while a # supybot-github instance is running possible - we don't use the config # variable because supybot's test framework sets the value after the # plugin has been loaded conf.supybot.plugins.get("Github").get('port').setValue(self.port) - ChannelPluginTestCase.setUp(self) - - def sendRequest(self, file): - if file in self.files: - content = self.files[file] - else: - with open('samples/' + file + '.json', 'r') as content_file: - content = content_file.read() - self.files[file] = content - - res = urllib.urlopen('http://localhost:' + str(self.port), 'payload=' + content) - + PluginTestCase.setUp(self) def testMerge(self): self.sendRequest('push-merge') + self.describe('first message', + it().should.contain('merged 4 commits'), + it().should.contain('from newTestBranch'), + it().should.contain('pushed 1 commit'), + it().should.contain('to master'), + it().should.contain('https://github.com/username/test/compare/cb12c8e51c8e...f386345fa3c5') + ) + # By default, merged commits should not be shown self.assertError('get 5th message') - self.assertContains('get first message', 'merged 4 commits') - self.assertContains('get first message', 'from newTestBranch') - self.assertContains('get first message', 'pushed 1 commit') - self.assertContains('get first message', 'to master') - - self.assertContains('get first message', 'https://github.com/username/test/compare/cb12c8e51c8e...f386345fa3c5') - - def testHeaders(self): - # self.assertError('headers ftp://ftp.cdrom.com/pub/linux') - # self.assertNotError('headers http://www.slashdot.org/') - return - - # vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: |