Ejemplo n.º 1
0
 def test_then_json_pointer_is_any_float(self):
     path = util.rand_string()
     self.ctx.zato.response.data_impl[path] = util.rand_int()
     self.assertRaises(AssertionError, json.then_json_pointer_is_any_float,
                       self.ctx, '/' + path)
     self.ctx.zato.response.data_impl[path] = util.rand_float()
     self.assertTrue(
         json.then_json_pointer_is_any_float(self.ctx, '/' + path))
Ejemplo n.º 2
0
    def test_i_create_table_and_insert_data_from_csv_file_using_header(self, open_mock):
        colnames = (tuple((element) for element in util.rand_string(5)))
        values = (util.rand_string(), util.rand_string(), util.rand_int(), round(util.rand_float(), 4), util.rand_string())
        t = colnames + values
        fake_csv = '%s, %s, %s, %s, %s\ntext, varchar:30, integer, float, char\n%s, %s, %s, %s, %s' % t
        kwargs = {'filename': util.rand_string(),
                    'tablename': util.rand_string(),
                    'conn_name': self.conn}

        open_mock.return_value = StringIO(fake_csv)
        sql.insert_csv(use_header=1, use_types=0, **kwargs)

        q = self.conn.execute('SELECT * FROM {tn}'.format(tn = kwargs['tablename']))
        result = q.fetchone()
        self.assertEquals(result, values)
Ejemplo n.º 3
0
    def test_i_create_table_and_insert_data_from_csv_file_using_header(
            self, open_mock):
        colnames = (tuple((element) for element in util.rand_string(5)))
        values = (util.rand_string(), util.rand_string(), util.rand_int(),
                  round(util.rand_float(), 4), util.rand_string())
        t = colnames + values
        fake_csv = '%s, %s, %s, %s, %s\ntext, varchar:30, integer, float, char\n%s, %s, %s, %s, %s' % t
        kwargs = {
            'filename': util.rand_string(),
            'tablename': util.rand_string(),
            'conn_name': self.conn
        }

        open_mock.return_value = StringIO(fake_csv)
        sql.insert_csv(use_header=1, use_types=0, **kwargs)

        q = self.conn.execute(
            'SELECT * FROM {tn}'.format(tn=kwargs['tablename']))
        result = q.fetchone()
        self.assertEquals(result, values)
Ejemplo n.º 4
0
 def test_given_json_pointer_in_request_is_a_float(self):
     path = util.rand_string()
     value = util.rand_float()
     json.given_json_pointer_in_request_is_a_float(self.ctx, '/' + path, value)
     self.assertEquals(self.ctx.zato.request.data_impl[path], float(value))
Ejemplo n.º 5
0
 def test_then_json_pointer_is_any_float(self):
     path = util.rand_string()
     self.ctx.zato.response.data_impl[path] = util.rand_int()
     self.assertRaises(AssertionError, json.then_json_pointer_is_any_float, self.ctx, '/' + path)
     self.ctx.zato.response.data_impl[path] = util.rand_float()
     self.assertTrue(json.then_json_pointer_is_any_float(self.ctx, '/' + path))
Ejemplo n.º 6
0
 def test_given_json_pointer_in_request_is_a_float(self):
     path = util.rand_string()
     value = util.rand_float()
     json.given_json_pointer_in_request_is_a_float(self.ctx, '/' + path,
                                                   value)
     self.assertEquals(self.ctx.zato.request.data_impl[path], float(value))