Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Python 3 to test matrix #29

Merged
merged 11 commits into from
Apr 8, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["2.7", "3.10"]

include:
- tox-envs: "sqla06-py27,sqla07-py27,sqla08-py27,sqla09-py27,sqlalchemy-py27"
- tox-envs: "sqlalchemy-py3"
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt-get -y install graphviz
Expand All @@ -30,4 +27,4 @@ jobs:
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with tox
run: |
tox
tox -v -e ${{ matrix.tox-envs }} -- -v --color=yes
18 changes: 9 additions & 9 deletions tests/test_schema_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ def test_no_args():
def test_empty_db(metadata):
graph = sasd.create_schema_graph(metadata=metadata)
assert isinstance(graph, pydot.Graph)
assert graph.create_plain() == 'graph 1 0 0\nstop\n'
assert graph.create_plain() == b'graph 1 0 0\nstop\n'


def test_empty_table(metadata):
Table(
'foo', metadata,
Column('id', types.Integer, primary_key=True))
result = plain_result(metadata=metadata)
assert result.keys() == ['1']
assert result['1']['nodes'].keys() == ['foo']
assert list(result.keys()) == ['1']
assert list(result['1']['nodes'].keys()) == ['foo']
assert '- id : INTEGER' in result['1']['nodes']['foo']


Expand All @@ -51,8 +51,8 @@ def test_empty_table_with_key_suffix(metadata):
Column('id', types.Integer, primary_key=True))
result = plain_result(metadata=metadata, show_column_keys=True)
print(result)
assert result.keys() == ['1']
assert result['1']['nodes'].keys() == ['foo']
assert list(result.keys()) == ['1']
assert list(result['1']['nodes'].keys()) == ['foo']
assert '- id(PK) : INTEGER' in result['1']['nodes']['foo']


Expand All @@ -64,7 +64,7 @@ def test_foreign_key(metadata):
'bar', metadata,
Column('foo_id', types.Integer, ForeignKey(foo.c.id)))
result = plain_result(metadata=metadata)
assert result.keys() == ['1']
assert list(result.keys()) == ['1']
assert sorted(result['1']['nodes'].keys()) == ['bar', 'foo']
assert '- id : INTEGER' in result['1']['nodes']['foo']
assert '- foo_id : INTEGER' in result['1']['nodes']['bar']
Expand All @@ -80,7 +80,7 @@ def test_foreign_key_with_key_suffix(metadata):
'bar', metadata,
Column('foo_id', types.Integer, ForeignKey(foo.c.id)))
result = plain_result(metadata=metadata, show_column_keys=True)
assert result.keys() == ['1']
assert list(result.keys()) == ['1']
assert sorted(result['1']['nodes'].keys()) == ['bar', 'foo']
assert '- id(PK) : INTEGER' in result['1']['nodes']['foo']
assert '- foo_id(FK) : INTEGER' in result['1']['nodes']['bar']
Expand All @@ -96,8 +96,8 @@ def test_table_filtering(metadata):
'bar', metadata,
Column('foo_id', types.Integer, ForeignKey(foo.c.id)))
result = plain_result(tables=[bar])
assert result.keys() == ['1']
assert result['1']['nodes'].keys() == ['bar']
assert list(result.keys()) == ['1']
assert list(result['1']['nodes'].keys()) == ['bar']
assert '- foo_id : INTEGER' in result['1']['nodes']['bar']

def test_table_rendering_without_schema(metadata):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_uml_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class Foo(Base):
__tablename__ = 'foo'
id = Column(types.Integer, primary_key=True)
result = plain_result(mappers(Foo))
assert result.keys() == ['1']
assert result['1']['nodes'].keys() == ['Foo']
assert list(result.keys()) == ['1']
assert list(result['1']['nodes'].keys()) == ['Foo']
assert '+id : Integer' in result['1']['nodes']['Foo']
out, err = capsys.readouterr()
assert out == u''
Expand Down
3 changes: 2 additions & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

def parse_graph(graph):
result = {}
sio = StringIO(graph.create_plain())
graph_bytes = graph.create_plain()
sio = StringIO(graph_bytes.decode('utf-8'))
graph = None
for line in sio:
line = line.strip()
Expand Down
28 changes: 10 additions & 18 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,30 @@

[testenv]
commands = py.test --cov-report html --cov-report term --cov sqlalchemy_schemadisplay {posargs}

[basedeps]
deps =
pytest
pytest-cov

[testenv:sqla06-py27]
basepython = python2.7
deps =
{[basedeps]deps}
sqlalchemy>0.6dev,<0.7dev
{[testenv]deps}
sqlalchemy==0.6.*

[testenv:sqla07-py27]
basepython = python2.7
deps =
{[basedeps]deps}
sqlalchemy>0.7dev,<0.8dev
{[testenv]deps}
sqlalchemy==0.7.*

[testenv:sqla08-py27]
basepython = python2.7
deps =
{[basedeps]deps}
sqlalchemy>0.8dev,<0.9dev
{[testenv]deps}
sqlalchemy==0.8.*

[testenv:sqla09-py27]
basepython = python2.7
deps =
{[basedeps]deps}
sqlalchemy>0.9dev,<1.0dev
{[testenv]deps}
sqlalchemy==0.9.*

[testenv:sqlalchemy-py27]
basepython = python2.7
deps =
{[basedeps]deps}
sqlalchemy>0.9dev

[testenv:sqlalchemy-py3]