class OrloLiveServerTest(LiveServerTestCase):
    """
    Test the Orlo client against the Orlo server

    This is testing integration with the Orlo server, for tests that limit the scope to
    the client code see test_orloclient.py
    """

    def create_app(self):
        app = orlo.app
        app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://'
        app.config['TESTING'] = True
        app.config['TRAP_HTTP_EXCEPTIONS'] = True
        app.config['PRESERVE_CONTEXT_ON_EXCEPTION'] = False
        app.config['LIVESERVER_PORT'] = 7767
        # app.config['DEBUG'] = True

        orlo.orm.db.create_all()

        return orlo.app

    def setUp(self):
        self.orlo_client = OrloClient(
            uri='http://localhost:7767'
        )

    def tearDown(self):
        orlo.orm.db.session.remove()
        orlo.orm.db.drop_all()

    def _create_release(self):
        return self.orlo_client.create_release('testuser', ['testplatform'])

    def _create_package(self, release):
        return self.orlo_client.create_package(release, 'package_one', '1.2.3')

    def _package_start(self, package):
        return self.orlo_client.package_start(package)

    def _package_stop(self, package, success=True):
        return self.orlo_client.package_stop(package, success)

    def _release_stop(self, release):
        return self.orlo_client.release_stop(release)
class OrloLiveServerTest(LiveServerTestCase):
    """
    Test the Orlo client against the Orlo server

    This is testing integration with the Orlo server, for tests that limit the scope to
    the client code see test_orloclient.py
    """

    def create_app(self):
        app = orlo.app
        app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://'
        app.config['TESTING'] = True
        app.config['TRAP_HTTP_EXCEPTIONS'] = True
        app.config['PRESERVE_CONTEXT_ON_EXCEPTION'] = False
        app.config['LIVESERVER_PORT'] = 7767
        # app.config['DEBUG'] = True

        orlo.orm.db.create_all()

        return orlo.app

    def setUp(self):
        self.orlo_client = OrloClient(
            uri='http://localhost:7767'
        )

    def tearDown(self):
        orlo.orm.db.session.remove()
        orlo.orm.db.drop_all()

    def _create_release(self):
        return self.orlo_client.create_release('testuser', ['testplatform'])

    def _create_package(self, release):
        return self.orlo_client.create_package(release, 'package_one', '1.2.3')

    def _package_start(self, package):
        return self.orlo_client.package_start(package)

    def _package_stop(self, package, success=True):
        return self.orlo_client.package_stop(package, success)

    def _release_stop(self, release):
        return self.orlo_client.release_stop(release)
Esempio n. 3
0
        # Other deployers could use this to detect whether they are being invoked by Orlo
        raise DeployerError("Could not detect ORLO_URL from environment")

    if os.getenv('ORLO_RELEASE'):
        orlo_release = os.environ['ORLO_RELEASE']
    else:
        raise DeployerError("Could not detect ORLO_RELEASE in environment")

    packages, metadata = get_params()

    orlo_client = OrloClient(uri=orlo_url)
    # The release is created in Orlo before being handed to the deployer
    # So fetch it here
    release = orlo_client.get_release(orlo_release)

    # TODO - using package info from arguments makes no sense when we could fetch from Orlo
    orlo_packages = []
    for p, v in packages.items():
        info("Creating Package {}:{}".format(p, v))
        pkg = orlo_client.create_package(release, p, v)
        orlo_packages.append(pkg)

    info("Starting Release")
    for pkg in orlo_packages:
        info("Deploying {}".format(pkg.name))
        deploy(pkg, meta=metadata)
    info("Finishing Release")

    orlo_client.release_stop(release)
    info("Done.")