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)