Permalink
Browse files

Add some tests for pulls.

  • Loading branch information...
1 parent f28b272 commit 1a2d5af53f155e591a9529a625bc6388b9c1e5e9 @sigmavirus24 committed Oct 15, 2012
Showing with 38 additions and 12 deletions.
  1. +13 −0 tests/base.py
  2. +2 −12 tests/test_issues.py
  3. +23 −0 tests/test_pulls.py
View
@@ -0,0 +1,13 @@
+from unittest import TestCase
+import sys
+import os
+
+
+class BaseTest(TestCase):
+ def setUp(self):
+ self.stdout = sys.stdout
+ sys.stdout = open(os.devnull, 'r+')
+
+ def tearDown(self):
+ sys.stdout.close()
+ sys.stdout = self.stdout
View
@@ -1,13 +1,11 @@
-from unittest import TestCase
from github3 import issue
from gh.util import tc
from gh.base import main_parser
from gh.commands.issues import IssuesCommand
-import sys
-import os
+from base import BaseTest
-class TestIssuesCommand(TestCase):
+class TestIssuesCommand(BaseTest):
def __init__(self, methodName='runTest'):
super(TestIssuesCommand, self).__init__(methodName)
self.issue = issue('sigmavirus24', 'github3.py', 30)
@@ -16,14 +14,6 @@ def __init__(self, methodName='runTest'):
self.opts, _ = self.command.parser.parse_args([])
self.command.get_repo(self.opts)
- def setUp(self):
- self.stdout = sys.stdout
- sys.stdout = open(os.devnull, 'r+')
-
- def tearDown(self):
- sys.stdout.close()
- sys.stdout = self.stdout
-
def test_format_short_issue(self):
out = self.command.format_short_issue(self.issue)
assert tc['default'] in out
View
@@ -0,0 +1,23 @@
+from gh.commands.pulls import PullsCommand, tc
+from github3 import pull_request
+from base import BaseTest
+
+
+class TestPullsCommand(BaseTest):
+ def __init__(self, methodName='runTest'):
+ super(TestPullsCommand, self).__init__(methodName)
+ self.number = 13
+ self.pull = pull_request('sigmavirus24', 'github3.py', self.number)
+ self.command = PullsCommand()
+ self.command.repository = ('sigmavirus24', 'github3.py')
+ opts = self.command.parser.parse_args([])
+ self.command.get_repo(opts)
+
+ def test_format_short_pull(self):
+ short = self.command.format_short_pull(self.pull)
+ assert tc['bold'] in short
+ assert 'sigmavirus24' in short
+
+ def test_get_pull(self):
+ pull = self.command.get_pull(self.number)
+ assert pull.id == pull.id

0 comments on commit 1a2d5af

Please sign in to comment.