示例#1
0
    def test_new_context_from_environment_dir(self):

        # Same comment as in test_new_context_from_old_ctx.
        for x in range(2):
            environment_dir = rand_string()
            ctx = new_context(None, environment_dir, {})
            self._test_new_context(ctx, environment_dir)
示例#2
0
    def setUp(self):
        self.ctx = Bunch()
        self.ctx.zato = util.new_context(None, util.rand_string(), {})

        # setup initial Cassandra keyspace
        self.current_session_name = util.rand_string()
        self.columns = ['userid', 'fname', 'sname']
        self.values = util.rand_string(3)
        self.keyspace = util.rand_string()
        self.table = util.rand_string()
        data = (self.keyspace, self.table) + tuple(s for s in self.columns)
        keyspace_statement = (
            "CREATE KEYSPACE %s WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 }") % self.keyspace
        table_statement = ("CREATE TABLE %s.%s (%s text PRIMARY KEY, %s text, %s text)") % data

        self.embedded_cassandra = pysandraunit.PysandraUnit(native_transport_port=9042)
        self.embedded_cassandra.start()
        self.cluster = Cluster(protocol_version=1)
        self.session = self.cluster.connect()
        self.session.execute(keyspace_statement)
        self.session.execute(table_statement)
        self.cluster.shutdown()

        # setup Cassandra ctx
        cassandra_.given_cassandra_contact_points(self.ctx, 'localhost')
        cassandra_.given_cassandra_protocol_version(self.ctx, 1)
        cassandra_.given_cassandra_port(self.ctx, '9042')
        cassandra_.given_i_connect_to_keyspace_as_session(self.ctx, self.keyspace, self.current_session_name)
示例#3
0
    def setUp(self):
        # TODO: Cassandra tests are failing due to """PysandraUnitServerError:
        # Failed to execute command start: /127.0.0.1:7010 is in use by another process.
        # Change listen_address:storage_port in cassandra.yaml to values that do not conflict with other services"""
        return
        self.ctx = Bunch()
        self.ctx.zato = util.new_context(None, util.rand_string(), {})

        import time
        time.sleep(2)

        # setup initial Cassandra keyspace
        self.current_session_name = util.rand_string()
        self.columns = ['userid', 'fname', 'sname']
        self.values = util.rand_string(3)
        self.keyspace = util.rand_string()
        self.table = util.rand_string()
        data = (self.keyspace, self.table) + tuple(s for s in self.columns)
        keyspace_statement = (
            "CREATE KEYSPACE %s WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 }") % self.keyspace
        table_statement = ("CREATE TABLE %s.%s (%s text PRIMARY KEY, %s text, %s text)") % data

        self.embedded_cassandra = pysandraunit.PysandraUnit(native_transport_port=9042)
        self.embedded_cassandra.start()
        self.cluster = Cluster(protocol_version=1)
        self.session = self.cluster.connect()
        self.session.execute(keyspace_statement)
        self.session.execute(table_statement)
        self.cluster.shutdown()

        # setup Cassandra ctx
        cassandra_.given_cassandra_contact_points(self.ctx, 'localhost')
        cassandra_.given_cassandra_protocol_version(self.ctx, 1)
        cassandra_.given_cassandra_port(self.ctx, '9042')
        cassandra_.given_i_connect_to_keyspace_as_session(self.ctx, self.keyspace, self.current_session_name)
示例#4
0
    def test_new_context_from_environment_dir(self):

        # Same comment as in test_new_context_from_old_ctx.
        for x in range(2):
            environment_dir = rand_string()
            ctx = new_context(None, environment_dir, {})
            self._test_new_context(ctx, environment_dir)
示例#5
0
    def setUp(self):
        self.ctx = Bunch()
        self.ctx.zato = util.new_context(None, util.rand_string(), {})

        # setup initial Cassandra keyspace
        self.current_session_name = util.rand_string()
        self.columns = ['userid', 'fname', 'sname']
        self.values = util.rand_string(3)
        self.keyspace = util.rand_string()
        self.table = util.rand_string()
        data = (self.keyspace, self.table) + tuple(s for s in self.columns)
        keyspace_statement = (
            "CREATE KEYSPACE %s WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 }") % self.keyspace
        table_statement = ("CREATE TABLE %s.%s (%s text PRIMARY KEY, %s text, %s text)") % data

        self.embedded_cassandra = pysandraunit.PysandraUnit(native_transport_port=9042)
        self.embedded_cassandra.start()
        self.cluster = Cluster(protocol_version=1)
        self.session = self.cluster.connect()
        self.session.execute(keyspace_statement)
        self.session.execute(table_statement)
        self.cluster.shutdown()

        # setup Cassamdra ctx
        cassandra_.given_cassandra_contact_points(self.ctx, 'localhost')
        cassandra_.given_cassandra_protocol_version(self.ctx, 1)
        cassandra_.given_cassandra_port(self.ctx, '9042')
        cassandra_.given_i_connect_to_keyspace_as_session(self.ctx, self.keyspace, self.current_session_name)
示例#6
0
    def test_new_context_from_old_ctx(self):

        # Done twice to ensure that util's context actually is wiped out.
        for x in range(2):
            environment_dir = rand_string()
            old_ctx = Bunch()
            old_ctx.zato = Bunch(environment_dir=environment_dir)
            ctx = new_context(old_ctx, None, {})
            self._test_new_context(ctx, environment_dir)
示例#7
0
    def test_new_context_from_old_ctx(self):

        # Done twice to ensure that util's context actually is wiped out.
        for x in range(2):
            environment_dir = rand_string()
            old_ctx = Bunch()
            old_ctx.zato = Bunch(environment_dir=environment_dir)
            ctx = new_context(old_ctx, None, {})
            self._test_new_context(ctx, environment_dir)
示例#8
0
    def setUp(self):
        self.ctx = Bunch()
        self.ctx.zato = util.new_context(None, util.rand_string(), {})

        self.fake_service_code = util.rand_string()

        conn_name = util.rand_string()
        cluster_id = util.rand_int()
        url_path = util.rand_string()
        username = util.rand_string()
        password = util.rand_string()
        zato_.given_i_store_zato_info_under_conn_name(self.ctx, cluster_id, url_path, username, password, conn_name)
        self.stored = self.ctx.zato.user_ctx[conn_name]
示例#9
0
    def setUp(self):
        self.ctx = Bunch()
        self.ctx.zato = util.new_context(None, util.rand_string(), {})

        self.fake_service_code = util.rand_string()

        conn_name = util.rand_string()
        cluster_id = util.rand_int()
        url_path = util.rand_string()
        username = util.rand_string()
        password = util.rand_string()
        zato_.given_i_store_zato_info_under_conn_name(self.ctx, cluster_id,
                                                      url_path, username,
                                                      password, conn_name)
        self.stored = self.ctx.zato.user_ctx[conn_name]
示例#10
0
    def setUp(self):
        self.ctx = Bunch()
        self.ctx.zato = util.new_context(None, util.rand_string(), {})

        self.id = util.rand_int()
        self.name = util.rand_string()
        self.value = util.rand_string()
        self.temp_db = NamedTemporaryFile().name

        self.conn = sqlite3.connect(self.temp_db)
        self.cursor = self.conn.cursor()
        self.cursor.execute("CREATE TABLE TestDB (id integer, name text, value text)")
        self.cursor.execute("INSERT INTO TestDB (id, name, value) VALUES (?,?,?)", (self.id, self.name, self.value))
        self.conn.commit()

        self.sqlalchemy_url = 'sqlite:///' + self.temp_db
        general_conn_name = 'general_connn_name'
        sql.given_i_connect_to_sqlalchemy_url_as_conn_name(self.ctx, self.sqlalchemy_url, general_conn_name)
        self.general_conn = self.ctx.zato.user_ctx[general_conn_name]
示例#11
0
    def setUp(self):
        # TODO: Cassandra tests are failing due to """PysandraUnitServerError:
        # Failed to execute command start: /127.0.0.1:7010 is in use by another process.
        # Change listen_address:storage_port in cassandra.yaml to values that do not conflict with other services"""
        return
        self.ctx = Bunch()
        self.ctx.zato = util.new_context(None, util.rand_string(), {})

        import time
        time.sleep(2)

        # setup initial Cassandra keyspace
        self.current_session_name = util.rand_string()
        self.columns = ['userid', 'fname', 'sname']
        self.values = util.rand_string(3)
        self.keyspace = util.rand_string()
        self.table = util.rand_string()
        data = (self.keyspace, self.table) + tuple(s for s in self.columns)
        keyspace_statement = (
            "CREATE KEYSPACE %s WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 }"
        ) % self.keyspace
        table_statement = (
            "CREATE TABLE %s.%s (%s text PRIMARY KEY, %s text, %s text)"
        ) % data

        self.embedded_cassandra = pysandraunit.PysandraUnit(
            native_transport_port=9042)
        self.embedded_cassandra.start()
        self.cluster = Cluster(protocol_version=1)
        self.session = self.cluster.connect()
        self.session.execute(keyspace_statement)
        self.session.execute(table_statement)
        self.cluster.shutdown()

        # setup Cassandra ctx
        cassandra_.given_cassandra_contact_points(self.ctx, 'localhost')
        cassandra_.given_cassandra_protocol_version(self.ctx, 1)
        cassandra_.given_cassandra_port(self.ctx, '9042')
        cassandra_.given_i_connect_to_keyspace_as_session(
            self.ctx, self.keyspace, self.current_session_name)
示例#12
0
    def setUp(self):
        self.ctx = Bunch()
        self.ctx.zato = util.new_context(None, util.rand_string(), {})

        self.id = util.rand_int()
        self.name = util.rand_string()
        self.value = util.rand_string()
        self.temp_db = NamedTemporaryFile().name

        self.conn = sqlite3.connect(self.temp_db)
        self.cursor = self.conn.cursor()
        self.cursor.execute(
            "CREATE TABLE TestDB (id integer, name text, value text)")
        self.cursor.execute(
            "INSERT INTO TestDB (id, name, value) VALUES (?,?,?)",
            (self.id, self.name, self.value))
        self.conn.commit()

        self.sqlalchemy_url = 'sqlite:///' + self.temp_db
        general_conn_name = 'general_connn_name'
        sql.given_i_connect_to_sqlalchemy_url_as_conn_name(
            self.ctx, self.sqlalchemy_url, general_conn_name)
        self.general_conn = self.ctx.zato.user_ctx[general_conn_name]
示例#13
0
 def setUp(self):
     self.ctx = Bunch()
     self.ctx.zato = util.new_context(None, util.rand_string(), {})
     self.format = common.given_format(self.ctx,'JSON')
     self.request = common.given_request_is(self.ctx, '{}')
示例#14
0
 def setUp(self):
     self.ctx = Bunch()
     self.ctx.zato = util.new_context(None, util.rand_string(), {})
     self.ctx.zato.response = Bunch()
     self.ctx.zato.response.data = Bunch()
     self.ctx.zato.response.data_impl = Bunch()
示例#15
0
 def setUp(self):
     self.ctx = Bunch()
     self.ctx.zato = util.new_context(None, util.rand_string(), {})
     self.format = common.given_format(self.ctx, 'JSON')
     self.request = common.given_request_is(self.ctx, '{}')
示例#16
0
 def setUp(self):
     self.ctx = Bunch()
     self.ctx.zato = util.new_context(None, util.rand_string(), {})
     self.ctx.zato.response = Bunch()
     self.ctx.zato.response.data = Bunch()
     self.ctx.zato.response.data_impl = Bunch()
示例#17
0
def before_feature(context, feature):
    environment_dir = os.path.dirname(os.path.realpath(__file__))
    context.zato = new_context(None, environment_dir)
示例#18
0
 def setUp(self):
     self.ctx = Bunch()
     self.ctx.zato = util.new_context(None, util.rand_string(), {})
示例#19
0
 def setUp(self):
     self.ctx = Bunch()
     self.ctx.zato = util.new_context(None, util.rand_string(), {})
示例#20
0
def before_feature(context, feature):
    environment_dir = os.path.dirname(os.path.realpath(__file__))
    context.zato = new_context(None, environment_dir)