Beispiel #1
0
class OrloClientTest(TestCase):
    """
    Parent method for Orlo client tests

    Constants in this class are test parameters for Orlo methods
    """
    NOTE = 'test note'
    PLATFORMS = ['test_platform']
    REFERENCES = ['test_reference']
    TEAM = 'test_team'
    URI = 'http://localhost:1337'
    USER = '******'

    CLIENT = MockOrloClient('http://dummy.example.com')
    RELEASE = Release(CLIENT, str(uuid.uuid4()))
    PACKAGE = RELEASE.packages[0]

    def setUp(self):
        self.orlo = OrloClient(self.URI)
Beispiel #2
0
from __future__ import print_function
from tests import OrloClientTest
from orloclient.mock_orlo import MockOrloClient
from orloclient import Package, Release
from orloclient.exceptions import ClientError
import arrow
import uuid

__author__ = 'alforbes'

client = MockOrloClient('http://dummy.example.com')


class TestPackage(OrloClientTest):
    def setUp(self):
        self.rid = client.example_release_dict['id']
        self.pid = client.example_package_dict['id']
        self.release = Release(client, self.rid)
        self.package = self.release.packages[0]

    def test_package_id(self):
        """
        Test that the package id returned matches the one from the mock and is a UUID
        """
        self.assertIsInstance(self.package.id, uuid.UUID)
        self.assertEqual(self.package.id, uuid.UUID(self.pid))

    def test_package_stime(self):
        """
        Test that stime is cast to an arrow object
        """
Beispiel #3
0
 def setUp(self):
     self.mock_client = MockOrloClient(uri='http://dummy')
Beispiel #4
0
class TestMockOrlo(TestCase):
    """
    Ensure that the mock is updated whenever the client changes...

    If you encounter a test failure here, you probably need to add your
    function to the mock. See orloclient/mock_orlo.py :)
    """

    functions = get_callables(OrloClient)

    def setUp(self):
        self.mock_client = MockOrloClient(uri='http://dummy')

    def test_attributes(self):
        """
        Compare the attributes of OrloClient and MockOrlo
        """
        for f in self.functions:
            self.assertIn(f, dir(self.mock_client))

    def test_create_package(self):
        result = self.mock_client.create_package()
        self.assertIsInstance(result, Package)

    def test_create_release(self):
        result = self.mock_client.create_release()
        self.assertIsInstance(result, Release)

    def test_get_info(self):
        result = self.mock_client.get_info('foo')
        self.assertIsInstance(result, dict)

    def test_get_releases(self):
        result = self.mock_client.get_releases()
        self.assertIsInstance(result, str)
        d = json.loads(result)
        self.assertIn('releases', d)

    def test_get_stats(self):
        result = self.mock_client.get_stats()
        self.assertIsInstance(result, str)

    def test_package_start(self):
        self.assertEqual(self.mock_client.package_start(), True)

    def test_package_stop(self):
        self.assertEqual(self.mock_client.package_stop(), True)

    def test_ping(self):
        self.assertEqual(self.mock_client.ping(), True)

    def test_release_stop(self):
        self.assertEqual(self.mock_client.release_stop('foo'), True)

    def test_get_release(self):
        result = self.mock_client.get_release(str(uuid.uuid4()))
        self.assertIsInstance(result, Release)

    def test_deploy_release(self):
        result = self.mock_client.deploy_release(str(uuid.uuid4()))
        self.assertIs(result, True)

    def test_get_versions(self):
        result = self.mock_client.get_versions()
        self.assertIsInstance(result, dict)