Exemplo n.º 1
0
class TestHostedCircleCLI(unittest.TestCase):
    """A self-hosted CircleCI installation should work."""

    def setUp(self):
        self.circlecli = CircleAPI(token=FAKE_TOKEN, baseurl="https://myownhost.com")

    """ CircleAPI.me()
        test results as a dict
    """
    @with_httmock(mocks.circlecli.resource_get)
    def test_me_as_dict(self):
        results = self.circlecli.me(verbose=False)

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

    """ CircleAPI.me()
        test results as json
    """
    @with_httmock(mocks.circlecli.resource_get)
    def test_me_as_json(self):

        results = self.circlecli.me(verbose=True)

        data = json.loads(results)

        self.assertEqual(data['login'], 'therealbarack')
Exemplo n.º 2
0
 def setUp(self):
     self.circlecli = CircleAPI(FAKE_TOKEN)
Exemplo n.º 3
0
class TestCircleCLI(unittest.TestCase):

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

    """ CircleAPI.me()
        test results as a dict
    """
    @with_httmock(mocks.circlecli.resource_get)
    def test_me_as_dict(self):
        results = self.circlecli.me(verbose=False)

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

    """ CircleAPI.me()
        test results as json
    """
    @with_httmock(mocks.circlecli.resource_get)
    def test_me_as_json(self):

        results = self.circlecli.me(verbose=True)

        data = json.loads(results)

        self.assertEqual(data['login'], 'therealbarack')

    """ CircleAPI.projects()
        test results as a dict
    """
    @with_httmock(mocks.circlecli.resource_get)
    def test_projects_as_dict(self):
        results = self.circlecli.projects(verbose=False)

        self.assertEqual(results, ['therealbarack/circlecli'])

    """ CircleAPI.projects()
        test results as json
    """
    @with_httmock(mocks.circlecli.resource_get)
    def test_projects_as_json(self):

        results = self.circlecli.projects(verbose=True)

        data = json.loads(results)

        self.assertEqual(data[0]['branches']['master']['last_success']['status'], 'fixed')

    """ CircleAPI.clear_cache()

    """
    @with_httmock(mocks.circlecli.resource_delete)
    def test_clear_cache_as_dict(self):
        results = self.circlecli.clear_cache('therealbarack', 'circlecli', verbose=False)
        print results

        self.assertEqual(results['status'], 'build caches deleted')

    """ CircleAPI.clear_cache()

    """
    @with_httmock(mocks.circlecli.resource_delete)
    def test_clear_cache_as_json(self):

        results = self.circlecli.clear_cache('therealbarack', 'circlecli', verbose=True)
        print results

        data = json.loads(results)

        self.assertEqual(data['status'], 'build caches deleted')

    """ CircleAPI.envar()

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

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

    """ CircleAPI.envar()

    """
    @with_httmock(mocks.circlecli.resource_get)
    @unittest.skip("test not written yet")
    def test_envar_as_json(self):

        results = self.circlecli.envvar(verbose=True)
        print results

        data = json.loads(results)

        self.assertEqual(data['login'], 'therealbarack')
Exemplo n.º 4
0
 def setUp(self):
     self.circlecli = CircleAPI(token=FAKE_TOKEN, baseurl="https://myownhost.com")
class TestCircleCLIKeys(unittest.TestCase):

    def setUp(self):
        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")
    def test_ssh_users_as_json(self):

        results = self.circlecli.ssh_users(verbose=True)
        print results

        data = json.loads(results)

        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")
    def test_create_ssh_as_json(self):

        results = self.circlecli.create_ssh(verbose=True)
        print results

        data = json.loads(results)

        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")
    def test_list_checkout_keys_as_json(self):

        results = self.circlecli.list_checkout_keys(verbose=True)
        print results

        data = json.loads(results)

        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")
    def test_create_checkout_key_as_json(self):

        results = self.circlecli.create_checkout_key(verbose=True)
        print results

        data = json.loads(results)

        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")
    def test_checkout_key_as_json(self):

        results = self.circlecli.checkout_key(verbose=True)
        print results

        data = json.loads(results)

        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")
    def test_delete_checkout_key_as_json(self):

        results = self.circlecli.delete_checkout_key(verbose=True)
        print results

        data = json.loads(results)

        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")
    def test_add_circle_key_as_json(self):

        results = self.circlecli.add_circle_key(verbose=True)
        print results

        data = json.loads(results)

        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")
    def test_add_heroku_key_as_json(self):

        results = self.circlecli.add_heroku_key(verbose=True)
        print results

        data = json.loads(results)

        self.assertEqual(data['login'], 'therealbarack')
Exemplo n.º 6
0
 def setUp(self):
     self.circlecli = CircleAPI(FAKE_TOKEN)
Exemplo n.º 7
0
class TestCircleCLIKeys(unittest.TestCase):
    def setUp(self):
        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")
    def test_ssh_users_as_json(self):

        results = self.circlecli.ssh_users(verbose=True)
        print results

        data = json.loads(results)

        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")
    def test_create_ssh_as_json(self):

        results = self.circlecli.create_ssh(verbose=True)
        print results

        data = json.loads(results)

        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")
    def test_list_checkout_keys_as_json(self):

        results = self.circlecli.list_checkout_keys(verbose=True)
        print results

        data = json.loads(results)

        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")
    def test_create_checkout_key_as_json(self):

        results = self.circlecli.create_checkout_key(verbose=True)
        print results

        data = json.loads(results)

        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")
    def test_checkout_key_as_json(self):

        results = self.circlecli.checkout_key(verbose=True)
        print results

        data = json.loads(results)

        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")
    def test_delete_checkout_key_as_json(self):

        results = self.circlecli.delete_checkout_key(verbose=True)
        print results

        data = json.loads(results)

        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")
    def test_add_circle_key_as_json(self):

        results = self.circlecli.add_circle_key(verbose=True)
        print results

        data = json.loads(results)

        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")
    def test_add_heroku_key_as_json(self):

        results = self.circlecli.add_heroku_key(verbose=True)
        print results

        data = json.loads(results)

        self.assertEqual(data['login'], 'therealbarack')
Exemplo n.º 8
0
class TestCircleCLIBuilds(unittest.TestCase):
    def setUp(self):
        self.circlecli = CircleAPI(FAKE_TOKEN)

    """ CircleAPI.builds()
        test results as dict
    """

    @with_httmock(mocks.circlecli.resource_get)
    def test_builds_as_dict(self):
        results = self.circlecli.builds(verbose=False)
        print results

        self.assertEqual(len(results), 2)
        contributors = [r['Author '] for r in results]
        self.assertTrue('Barack Obama <*****@*****.**>'
                        in contributors)
        self.assertTrue('Joe Biden <*****@*****.**>' in contributors)

    """ CircleAPI.builds()
        test results as json
    """

    @with_httmock(mocks.circlecli.resource_get)
    def test_builds_as_json(self):

        results = self.circlecli.builds(verbose=True)
        print results

        data = json.loads(results)

        self.assertEqual(len(data), 2)
        subjects = [d['subject'] for d in data]
        self.assertTrue('corrected name of builds with project' in subjects)

    """ CircleAPI.builds()
        test results as dict with project
    """

    @with_httmock(mocks.circlecli.resource_get)
    def test_builds_with_project_as_dict(self):
        results = self.circlecli.builds('therealbarack',
                                        'circlecli',
                                        1,
                                        verbose=False)
        print results

        self.assertEqual(results[0]['Result '], 'no_tests')

    """ CircleAPI.builds()
        test results as json with project
    """

    @with_httmock(mocks.circlecli.resource_get)
    def test_builds_with_project_as_json(self):

        results = self.circlecli.builds('therealbarack',
                                        'circlecli',
                                        1,
                                        verbose=True)
        print results

        data = json.loads(results)

        self.assertEqual(data['outcome'], 'no_tests')

    """ CircleAPI.artifacts()

    """

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

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

    """ CircleAPI.artifacts()

    """

    @with_httmock(mocks.circlecli.resource_get)
    @unittest.skip("test not written yet")
    def test_artifacts_as_json(self):

        results = self.circlecli.artifacts(verbose=True)
        print results

        data = json.loads(results)

        self.assertEqual(data['login'], 'therealbarack')

    """ CircleAPI.retry_build()

    """

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

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

    """ CircleAPI.retry_build()

    """

    @with_httmock(mocks.circlecli.resource_get)
    @unittest.skip("test not written yet")
    def test_retry_build_as_json(self):

        results = self.circlecli.retry_build(verbose=True)
        print results

        data = json.loads(results)

        self.assertEqual(data['login'], 'therealbarack')

    """ CircleAPI.cancel_build()

    """

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

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

    """ CircleAPI.cancel_build()

    """

    @with_httmock(mocks.circlecli.resource_get)
    @unittest.skip("test not written yet")
    def test_cancel_build_as_json(self):

        results = self.circlecli.cancel_build(verbose=True)
        print results

        data = json.loads(results)

        self.assertEqual(data['login'], 'therealbarack')

    """ CircleAPI.new_build()

    """

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

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

    """ CircleAPI.new_build()

    """

    @with_httmock(mocks.circlecli.resource_get)
    @unittest.skip("test not written yet")
    def test_new_build_as_json(self):

        results = self.circlecli.new_build(verbose=True)
        print results

        data = json.loads(results)

        self.assertEqual(data['login'], 'therealbarack')

    @with_httmock(mocks.circlecli.resource_get)
    def test_filter_with_match(self):
        """Should match one of two values in mock data."""
        results = self.circlecli.builds(
            'therealbarack',
            verbose=False,
            filters={'user.login': '******'})

        self.assertEqual(len(results), 1)  # should only be one of two
        self.assertEqual(
            results[0]['Author '],
            'Barack Obama <*****@*****.**>')

    @with_httmock(mocks.circlecli.resource_get)
    def test_filter_without_match(self):
        """Should return no results (no match)."""
        results = self.circlecli.builds(
            'therealbarack',
            verbose=False,
            filters={'user.login': '******'})

        self.assertEqual(len(results), 0)
Exemplo n.º 9
0
class TestCircleCLI(unittest.TestCase):

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

    """ CircleAPI.me()
        test results as a dict
    """
    @with_httmock(mocks.circlecli.resource_get)
    def test_me_as_dict(self):
        results = self.circlecli.me(verbose=False)

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

    """ CircleAPI.me()
        test results as json
    """
    @with_httmock(mocks.circlecli.resource_get)
    def test_me_as_json(self):

        results = self.circlecli.me(verbose=True)

        data = json.loads(results)

        self.assertEqual(data['login'], 'therealbarack')

    """ CircleAPI.projects()
        test results as a dict
    """
    @with_httmock(mocks.circlecli.resource_get)
    def test_projects_as_dict(self):
        results = self.circlecli.projects(verbose=False)

        self.assertEqual(results, ['therealbarack/circlecli'])

    """ CircleAPI.projects()
        test results as json
    """
    @with_httmock(mocks.circlecli.resource_get)
    def test_projects_as_json(self):

        results = self.circlecli.projects(verbose=True)

        data = json.loads(results)

        self.assertEqual(data[0]['branches']['master']['last_success']['status'], 'fixed')

    """ CircleAPI.clear_cache()

    """
    @with_httmock(mocks.circlecli.resource_delete)
    def test_clear_cache_as_dict(self):
        results = self.circlecli.clear_cache('therealbarack', 'circlecli', verbose=False)
        print results

        self.assertEqual(results['status'], 'build caches deleted')

    """ CircleAPI.clear_cache()

    """
    @with_httmock(mocks.circlecli.resource_delete)
    def test_clear_cache_as_json(self):

        results = self.circlecli.clear_cache('therealbarack', 'circlecli', verbose=True)
        print results

        data = json.loads(results)

        self.assertEqual(data['status'], 'build caches deleted')

    """ CircleAPI.envar()

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

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

    """ CircleAPI.envar()

    """
    @with_httmock(mocks.circlecli.resource_get)
    @unittest.skip("test not written yet")
    def test_envar_as_json(self):

        results = self.circlecli.envvar(verbose=True)
        print results

        data = json.loads(results)

        self.assertEqual(data['login'], 'therealbarack')
Exemplo n.º 10
0
 def test_valid_token(self):
     circlecli = CircleAPI(FAKE_TOKEN)