Skip to content
This repository has been archived by the owner on Sep 17, 2021. It is now read-only.

Commit

Permalink
Updating tests for new token requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
particledecay committed Jul 13, 2016
1 parent f408c30 commit 4db3340
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 30 deletions.
17 changes: 14 additions & 3 deletions tests/test_circlecli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"""

import binascii
import json
import os
import unittest

from httmock import with_httmock
Expand All @@ -14,21 +16,30 @@
import mocks.circlecli


# 40-character hexadecimal string
FAKE_TOKEN = binascii.b2a_hex(os.urandom(20))


class TestCircleCLISetup(unittest.TestCase):

""" CircleAPI.init() should check the token is a 40-digit hex string
and return an error if it is not
"""
def test_valid_token(self):
circlecli = CircleAPI('moo')
circlecli = CircleAPI(FAKE_TOKEN)

def test_invalid_token(self):
circlecli = CircleAPI('foo')
# not long enough
self.assertRaises(ValueError, CircleAPI, 'fff')

# not hex
self.assertRaises(ValueError, CircleAPI, 'ququququququququququququququququququququ')


class TestCircleCLI(unittest.TestCase):

def setUp(self):
self.circlecli = CircleAPI('bar')
self.circlecli = CircleAPI(FAKE_TOKEN)

""" CircleAPI.me()
test results as a dict
Expand Down
8 changes: 7 additions & 1 deletion tests/test_circlecli_builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"""

import binascii
import json
import os
import unittest

from httmock import with_httmock
Expand All @@ -14,10 +16,14 @@
import mocks.circlecli


# 40-character hexadecimal string
FAKE_TOKEN = binascii.b2a_hex(os.urandom(20))


class TestCircleCLIBuilds(unittest.TestCase):

def setUp(self):
self.circlecli = CircleAPI('bar')
self.circlecli = CircleAPI(FAKE_TOKEN)

""" CircleAPI.builds()
test results as dict
Expand Down
58 changes: 32 additions & 26 deletions tests/test_circlecli_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"""

import binascii
import json
import os
import unittest

from httmock import with_httmock
Expand All @@ -14,24 +16,28 @@
import mocks.circlecli


# 40-character hexadecimal string
FAKE_TOKEN = binascii.b2a_hex(os.urandom(20))


class TestCircleCLIKeys(unittest.TestCase):

def setUp(self):
self.circlecli = CircleAPI('bar')
self.circlecli = CircleAPI(FAKE_TOKEN)

""" CircleAPI.ssh_users()
"""
@with_httmock(mocks.circlecli.resource_get)
@unittest.skip("test not written yet")
def test_ssh_users_as_dict(self):
results = self.circlecli.ssh_users(verbose=False)
print results

self.assertEqual(results['Username'], 'therealbarack')

""" CircleAPI.ssh_users()
"""
@with_httmock(mocks.circlecli.resource_get)
@unittest.skip("test not written yet")
Expand All @@ -45,18 +51,18 @@ def test_ssh_users_as_json(self):
self.assertEqual(data['login'], 'therealbarack')

""" CircleAPI.create_ssh()
"""
@with_httmock(mocks.circlecli.resource_get)
@unittest.skip("test not written yet")
def test_create_ssh_as_dict(self):
results = self.circlecli.create_ssh(verbose=False)
print results

self.assertEqual(results['Username'], 'therealbarack')

""" CircleAPI.create_ssh()
"""
@with_httmock(mocks.circlecli.resource_get)
@unittest.skip("test not written yet")
Expand All @@ -70,18 +76,18 @@ def test_create_ssh_as_json(self):
self.assertEqual(data['login'], 'therealbarack')

""" CircleAPI.list_checkout_keys()
"""
@with_httmock(mocks.circlecli.resource_get)
@unittest.skip("test not written yet")
def test_list_checkout_keys_as_dict(self):
results = self.circlecli.list_checkout_keys(verbose=False)
print results

self.assertEqual(results['Username'], 'therealbarack')

""" CircleAPI.list_checkout_keys()
"""
@with_httmock(mocks.circlecli.resource_get)
@unittest.skip("test not written yet")
Expand All @@ -95,18 +101,18 @@ def test_list_checkout_keys_as_json(self):
self.assertEqual(data['login'], 'therealbarack')

""" CircleAPI.create_checkout_key()
"""
@with_httmock(mocks.circlecli.resource_get)
@unittest.skip("test not written yet")
def test_create_checkout_key_as_dict(self):
results = self.circlecli.create_checkout_key(verbose=False)
print results

self.assertEqual(results['Username'], 'therealbarack')

""" CircleAPI.create_checkout_key()
"""
@with_httmock(mocks.circlecli.resource_get)
@unittest.skip("test not written yet")
Expand All @@ -120,18 +126,18 @@ def test_create_checkout_key_as_json(self):
self.assertEqual(data['login'], 'therealbarack')

""" CircleAPI.checkout_key()
"""
@with_httmock(mocks.circlecli.resource_get)
@unittest.skip("test not written yet")
def test_checkout_key_as_dict(self):
results = self.circlecli.checkout_key(verbose=False)
print results

self.assertEqual(results['Username'], 'therealbarack')

""" CircleAPI.checkout_key()
"""
@with_httmock(mocks.circlecli.resource_get)
@unittest.skip("test not written yet")
Expand All @@ -145,18 +151,18 @@ def test_checkout_key_as_json(self):
self.assertEqual(data['login'], 'therealbarack')

""" CircleAPI.delete_checkout_key()
"""
@with_httmock(mocks.circlecli.resource_get)
@unittest.skip("test not written yet")
def test_delete_checkout_key_as_dict(self):
results = self.circlecli.delete_checkout_key(verbose=False)
print results

self.assertEqual(results['Username'], 'therealbarack')

""" CircleAPI.delete_checkout_key()
"""
@with_httmock(mocks.circlecli.resource_get)
@unittest.skip("test not written yet")
Expand All @@ -170,18 +176,18 @@ def test_delete_checkout_key_as_json(self):
self.assertEqual(data['login'], 'therealbarack')

""" CircleAPI.add_circle_key()
"""
@with_httmock(mocks.circlecli.resource_get)
@unittest.skip("test not written yet")
def test_add_circle_key_as_dict(self):
results = self.circlecli.add_circle_key(verbose=False)
print results

self.assertEqual(results['Username'], 'therealbarack')

""" CircleAPI.add_circle_key()
"""
@with_httmock(mocks.circlecli.resource_get)
@unittest.skip("test not written yet")
Expand All @@ -195,18 +201,18 @@ def test_add_circle_key_as_json(self):
self.assertEqual(data['login'], 'therealbarack')

""" CircleAPI.add_heroku_key()
"""
@with_httmock(mocks.circlecli.resource_get)
@unittest.skip("test not written yet")
def test_add_heroku_key_as_dict(self):
results = self.circlecli.add_heroku_key(verbose=False)
print results

self.assertEqual(results['Username'], 'therealbarack')

""" CircleAPI.add_heroku_key()
"""
@with_httmock(mocks.circlecli.resource_get)
@unittest.skip("test not written yet")
Expand Down

0 comments on commit 4db3340

Please sign in to comment.