Skip to content
This repository was archived by the owner on Oct 26, 2022. It is now read-only.

Commit 17a19e4

Browse files
committed
add travis-ci
1 parent 261c943 commit 17a19e4

File tree

6 files changed

+80
-10
lines changed

6 files changed

+80
-10
lines changed

.coveragerc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[run]
2+
include = *mybatis_mapper2sql*

.travis.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
language: python
2+
3+
python:
4+
- "3.4"
5+
- "3.5"
6+
- "3.6"
7+
8+
matrix:
9+
include:
10+
- python: '3.7'
11+
dist: xenial # required for Python >= 3.7 (travis-ci/travis-ci#9069)
12+
13+
install:
14+
- pip install sqlparse
15+
- pip install coverage
16+
- pip install codecov
17+
18+
script:
19+
- coverage run -m unittest
20+
21+
after_success:
22+
- codecov

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
mybatis-mapper2sql
2-
==========================
2+
==================
3+
[![Build Status](https://travis-ci.org/hhyo/mybatis-mapper2sql.svg?branch=master)](https://travis-ci.org/hhyo/mybatis-mapper2sql)
4+
[![codecov](https://codecov.io/gh/hhyo/mybatis-mapper2sql/branch/master/graph/badge.svg)](https://codecov.io/gh/hhyo/mybatis-mapper2sql)
35
[![image](https://img.shields.io/pypi/v/mybatis-mapper2sql.svg)](https://pypi.org/project/mybatis-mapper2sql/)
46
[![image](https://img.shields.io/pypi/l/mybatis-mapper2sql.svg)](https://github.com/hhyo/mybatis-mapper2sql/blob/master/LICENSE)
57
[![image](https://img.shields.io/pypi/pyversions/mybatis-mapper2sql.svg)](https://pypi.org/project/mybatis-mapper2sql/)
68

7-
Generate SQL Statements from the MyBatis3 Mapper XML file in Python
9+
Generate SQL Statements from the MyBatis3 Mapper XML file
810
**Just for SQL Review https://github.com/hhyo/archery/issues/3**
911

1012
Installation
@@ -250,7 +252,7 @@ WHERE category = 'apple'
250252

251253
UPDATE fruits
252254
SET category = ?,
253-
price = ?,
255+
price = ?
254256
WHERE name = ?;
255257

256258

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def run_tests(self):
2525

2626
setup(
2727
name='mybatis-mapper2sql',
28-
version='0.1.2',
28+
version='0.1.3',
2929
author='hhyo',
3030
author_email='[email protected]',
3131
url='http://github.com/hhyo/mybatis-mapper2sql',

tests/test.py

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,82 @@
11
import os
22
import unittest
3-
from mybatis_mapper2sql import create_mapper, get_child_statement
3+
import mybatis_mapper2sql
4+
5+
base_dir = os.path.abspath(os.path.dirname(__file__))
6+
xml = os.path.join(base_dir, 'test.xml')
47

58

69
class Mapper2SqlTest(unittest.TestCase):
710

811
@classmethod
912
def setUpClass(cls):
10-
base_dir = os.path.abspath(os.path.dirname(__file__))
11-
xml = os.path.join(base_dir, 'test.xml')
12-
cls.mapper, cls.xml_raw_text = create_mapper(xml=xml)
13+
cls.mapper, cls.xml_raw_text = mybatis_mapper2sql.create_mapper(xml=xml)
1314
print("============XML_RAW_TEXT============")
1415
print(cls.xml_raw_text)
1516

16-
def tearDown(self):
17+
def test_all(self):
18+
statement = mybatis_mapper2sql.get_statement(self.mapper, result_type='raw', strip_comments=True)
19+
print(statement)
20+
21+
def test_base(self):
22+
self.child_id = 'testBasic'
1723
print("============{}============".format(self.child_id))
18-
self.statement = get_child_statement(self.mapper, child_id=self.child_id, reindent=True)
24+
self.statement = mybatis_mapper2sql.get_child_statement(self.mapper, child_id=self.child_id, reindent=True)
1925
print(self.statement)
2026

2127
def test_parameters(self):
2228
self.child_id = 'testParameters'
29+
print("============{}============".format(self.child_id))
30+
self.statement = mybatis_mapper2sql.get_child_statement(self.mapper, child_id=self.child_id, reindent=True)
31+
print(self.statement)
2332

2433
def test_include(self):
2534
self.child_id = 'testInclude'
35+
print("============{}============".format(self.child_id))
36+
self.statement = mybatis_mapper2sql.get_child_statement(self.mapper, child_id=self.child_id, reindent=True)
37+
print(self.statement)
2638

2739
def test_if(self):
2840
self.child_id = 'testIf'
41+
print("============{}============".format(self.child_id))
42+
self.statement = mybatis_mapper2sql.get_child_statement(self.mapper, child_id=self.child_id, reindent=True)
43+
print(self.statement)
2944

3045
def test_trim(self):
3146
self.child_id = 'testTrim'
47+
print("============{}============".format(self.child_id))
48+
self.statement = mybatis_mapper2sql.get_child_statement(self.mapper, child_id=self.child_id, reindent=True)
49+
print(self.statement)
3250

3351
def test_where(self):
3452
self.child_id = 'testWhere'
53+
print("============{}============".format(self.child_id))
54+
self.statement = mybatis_mapper2sql.get_child_statement(self.mapper, child_id=self.child_id, reindent=True)
55+
print(self.statement)
3556

3657
def test_set(self):
3758
self.child_id = 'testSet'
59+
print("============{}============".format(self.child_id))
60+
self.statement = mybatis_mapper2sql.get_child_statement(self.mapper, child_id=self.child_id, reindent=True)
61+
print(self.statement)
3862

3963
def test_choose(self):
4064
self.child_id = 'testChoose'
65+
print("============{}============".format(self.child_id))
66+
self.statement = mybatis_mapper2sql.get_child_statement(self.mapper, child_id=self.child_id, reindent=True)
67+
print(self.statement)
4168

4269
def test_foreach(self):
4370
self.child_id = 'testForeach'
71+
print("============{}============".format(self.child_id))
72+
self.statement = mybatis_mapper2sql.get_child_statement(self.mapper, child_id=self.child_id, reindent=True)
73+
print(self.statement)
4474

4575
def test_bind(self):
4676
self.child_id = 'testBind'
77+
print("============{}============".format(self.child_id))
78+
self.statement = mybatis_mapper2sql.get_child_statement(self.mapper, child_id=self.child_id, reindent=True)
79+
print(self.statement)
4780

4881

4982
if __name__ == '__main__':

tests/test.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@
1313
<include refid="${include_target}"/>
1414
<include refid="somewhere"/>
1515
</sql>
16+
<select id="testBasic">
17+
SELECT
18+
name,
19+
category,
20+
price
21+
FROM
22+
fruits
23+
WHERE
24+
category = 'apple' AND
25+
<![CDATA[ price < 500 ]]>
26+
</select>
1627
<select id="testParameters">
1728
SELECT
1829
name,

0 commit comments

Comments
 (0)