diff --git a/test/test_card.py b/test/test_card.py index 1096bc06..575e48f5 100644 --- a/test/test_card.py +++ b/test/test_card.py @@ -6,7 +6,7 @@ from trello import TrelloClient, ResourceUnavailable -class TrelloBoardTestCase(unittest.TestCase): +class TrelloCardTestCase(unittest.TestCase): """ Tests for TrelloClient API. Note these test are in order to preserve dependencies, as an API integration cannot be tested @@ -137,5 +137,6 @@ def suite(): # return unittest.TestSuite(map(TrelloBoardTestCase, tests)) return unittest.TestLoader().loadTestsFromTestCase(TrelloBoardTestCase) + if __name__ == "__main__": unittest.main() diff --git a/test/test_trello_client.py b/test/test_trello_client.py index de5423a0..5aef374a 100644 --- a/test/test_trello_client.py +++ b/test/test_trello_client.py @@ -112,10 +112,33 @@ def test54_resource_unavailable(self): self._trello.get_card, '0') +class TrelloClientTestCaseWithoutOAuth(unittest.TestCase): + """ + + Tests for TrelloClient API when OAuth not activated. + + """ + + def setUp(self): + self._trello = TrelloClient(os.environ['TRELLO_API_KEY'], + api_secret=os.environ['TRELLO_TOKEN']) + + def test01_oauth_not_activated(self): + self.assertIsNone(self._trello.oauth) + + def suite(): - # tests = ['test01_list_boards', 'test10_board_attrs', 'test20_add_card'] - # return unittest.TestSuite(map(TrelloClientTestCase, tests)) - return unittest.TestLoader().loadTestsFromTestCase(TrelloClientTestCase) + test_classes_to_run = [TrelloClientTestCase, + TrelloClientTestCaseWithoutOAuth] + + loader = unittest.TestLoader() + + suites_list = [] + for test_class in test_classes_to_run: + suite = loader.loadTestsFromTestCase(test_class) + suites_list.append(suite) + + return unittest.TestSuite(suites_list) if __name__ == "__main__": diff --git a/trello/trelloclient.py b/trello/trelloclient.py index e07ef6dd..78d18016 100644 --- a/trello/trelloclient.py +++ b/trello/trelloclient.py @@ -38,7 +38,7 @@ def __init__(self, api_key, api_secret=None, token=None, token_secret=None): """ # client key and secret for oauth1 session - if api_key or token: + if token or token_secret: self.oauth = OAuth1(client_key=api_key, client_secret=api_secret, resource_owner_key=token, resource_owner_secret=token_secret) else: