Skip to content

Commit 86e0bd5

Browse files
authored
Merge pull request #6 from Overseas-Student-Living/relax_package_versions
Relax package versions and make test DB URI more dynamic
2 parents ec03bee + 77afe69 commit 86e0bd5

File tree

7 files changed

+76
-24
lines changed

7 files changed

+76
-24
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
.cache
55
.tox
66
docs/build
7+
htmlcov

CHANGELOG

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Version 0.1.2
2+
-------------
3+
4+
Released 2016-10-19
5+
6+
* Relaxed package versions so that they are not pinned down unless it is necessary.
7+
* Stopped using static YAML files to set test parameters and started using pytest parser instead.
8+
* Makefile added.
9+
* CHANGELOG added.
10+
* README documentation updated.

Makefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.PHONY: test
2+
3+
HTMLCOV_DIR ?= htmlcov
4+
5+
test: flake8 test_lib
6+
7+
flake8:
8+
flake8 sqlalchemydiff test
9+
10+
test_lib:
11+
coverage run --source=sqlalchemydiff -m pytest test $(ARGS)
12+
13+
coverage-html: test
14+
coverage html -d $(HTMLCOV_DIR)
15+
16+
coverage-report: test
17+
coverage report -m
18+
19+
coverage: coverage-html coverage-report test

README.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,28 @@ SQLAlchemy Diff
77
inspection API.
88

99

10+
Running tests
11+
-------------
12+
13+
Makefile targets that can be used to run the tests.
14+
15+
Test databases will be created, used during the tests and destroyed afterwards.
16+
17+
Example of usage:
18+
19+
.. code-block:: shell
20+
21+
$ # using default settings
22+
$ pytest test
23+
$ make test
24+
$ make coverage
25+
26+
$ # or overridding the database URI
27+
$ pytest test --test-db-url=mysql+mysqlconnector://root:password@localhost:3306/sqlalchemydiff
28+
$ make test ARGS="--test-db-url=mysql+mysqlconnector://root:password@localhost:3306/sqlalchemydiff"
29+
$ make coverage ARGS="--lf -x -vv --test-db-url=mysql+mysqlconnector://root:password@localhost:3306/sqlalchemydiff"
30+
31+
1032
License
1133
-------
1234

config/config.yaml

Lines changed: 0 additions & 2 deletions
This file was deleted.

setup.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,24 @@
1313

1414
setup(
1515
name='sqlalchemy-diff',
16-
version='0.1.1',
16+
version='0.1.2',
1717
description='Compare two database schemas using sqlalchemy.',
1818
long_description=readme,
1919
author='student.com',
2020
author_email='[email protected]',
2121
url='https://github.com/Overseas-Student-Living/sqlalchemy-diff',
2222
packages=find_packages(exclude=['docs', 'test', 'test.*']),
2323
install_requires=[
24-
"six==1.10.0",
25-
"mock>=2.0.0",
26-
"sqlalchemy-utils==0.32.4",
27-
"pyyaml>=3.11",
24+
"six>=1.10.0",
25+
"sqlalchemy-utils>=0.32.4",
2826
],
2927
extras_require={
3028
'dev': [
29+
"mock==2.0.0",
3130
"mysql-connector-python==2.0.4",
32-
"pytest==2.9.1",
31+
"pytest==3.0.3",
32+
"flake8==3.0.4",
33+
"coverage==4.2",
3334
],
3435
'docs': [
3536
"sphinx==1.4.1",

test/conftest.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
import os
2-
31
import pytest
4-
import yaml
52

63

74
@pytest.fixture(scope="session")
8-
def project_root():
9-
return os.path.dirname(os.path.dirname(__file__))
10-
5+
def db_uri(request):
6+
return request.config.getoption('TEST_DB_URL')
117

12-
@pytest.fixture(scope="session")
13-
def test_config(project_root):
14-
config_file = os.path.join(project_root, "config", "config.yaml")
15-
with open(config_file) as stream:
16-
config = yaml.load(stream.read())
17-
return config
188

19-
20-
@pytest.fixture(scope="session")
21-
def db_uri(test_config):
22-
return test_config['DB_URIS']['test']
9+
def pytest_addoption(parser):
10+
parser.addoption(
11+
'--test-db-url',
12+
action='store',
13+
dest='TEST_DB_URL',
14+
default=(
15+
'mysql+mysqlconnector://root:password@localhost:3306/'
16+
'sqlalchemydiff'
17+
),
18+
help=(
19+
'DB url for testing (e.g. '
20+
'"mysql+mysqlconnector://root:password@localhost:3306/'
21+
'sqlalchemydiff''")'
22+
)
23+
)

0 commit comments

Comments
 (0)