Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ python:
- 2.7
- 3.5
- 3.6
- 3.8
sudo: false
install:
- travis_retry python setup.py develop
- travis_retry pip install pytest-cov coverage coveralls
- travis_retry pip install markupsafe==1.1.1 pytest-cov coverage coveralls
script:
- coverage run --source=sandman2 setup.py test
after_success:
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ wcwidth==0.1.7
Werkzeug==0.15.4
WTForms==2.2.1
zipp==0.5.1
markupsafe==1.1.1
4 changes: 2 additions & 2 deletions sandman2/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ def main():
'-e',
'--enable-cors',
help='Enable Cross Origin Resource Sharing (CORS)',
action='store_true',
default=False)


args = parser.parse_args()
app = get_app(args.URI, read_only=args.read_only, schema=args.schema)
if args.enable_cors:
from flask_cors import CORS
CORS(app)
if args.debug:
if args.debug:
app.config['DEBUG'] = True
if args.local_only:
host = '127.0.0.1'
Expand Down
2 changes: 1 addition & 1 deletion sandman2/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def _all_resources(self):
order = []
for key, value in args.items():
if value.startswith('%'):
filters.append(getattr(self.__model__, key).like(str(value), escape='/'))
filters.append(getattr(self.__model__, key).like(str(value[1:]), escape='/'))
elif key == 'sort':
direction = desc if value.startswith('-') else asc
order.append(direction(getattr(self.__model__, value.lstrip('-'))))
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ def run_tests(self):
url='http://github.com/jeffknupp/sandman2/',
license='Apache Software License',
author='Jeff Knupp',
tests_require=['pytest', 'pytest-cov', 'pytest-flask==0.14.0'],
tests_require=['pytest', 'pytest-cov', 'pytest-flask==0.15.1'],
install_requires=[
'Flask>=1.0.3',
'Flask-SQLAlchemy==2.4.0',
'SQLAlchemy==1.3.3',
'Flask-SQLAlchemy>=2.4.0',
'SQLAlchemy>=1.3.3',
'Flask-Admin>=1.5.3',
'Flask-HTTPAuth>=3.2.4',
],
Expand Down
7 changes: 4 additions & 3 deletions start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

# Start sandman2

if [ $DB_TYPE == "sqlite"" ] then
sandman2ctl -p $PORT $DB_TYPE+$DB_DRIVER:///$DATABASE
if [ "$DB_TYPE" = "sqlite" ]
then
sandman2ctl -p "$PORT" "$DB_TYPE+$DB_DRIVER:///$DATABASE"
else
sandman2ctl -p $PORT $DB_TYPE+$DB_DRIVER://$USERNAME:$PASSWORD@$DB_NAME:$DB_PORT/$DATABASE
sandman2ctl -p "$PORT" "$DB_TYPE+$DB_DRIVER://$USERNAME:$PASSWORD@$DB_NAME:$DB_PORT/$DATABASE"
fi
12 changes: 10 additions & 2 deletions tests/test_extended_functionality.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,22 @@ def test_filtering_unkown_field(client):
assert response.status_code == 400


def test_wildcard_filtering(client):
def test_wildcard_filtering1(client):
"""Do we return filtered results when a wildcarded URL parameter is provided?"""
response = client.get('/artist/?Name=%25%25DC')
response = client.get('/artist/?Name=%25%25%25DC')
assert response.status_code == 200
assert len(response.json['resources']) == 1
assert response.json['resources'][0]['ArtistId'] == 1


def test_wildcard_filtering2(client):
"""Do we return filtered results when a wildcarded URL parameter is provided?"""
response = client.get('/artist/?Name=%25AC%25%25')
assert response.status_code == 200
assert len(response.json['resources']) == 7
assert response.json['resources'][0]['ArtistId'] == 1


def test_sorting(client):
"""Do we return sorted results when a 'sort' URL parameter is provided?"""
response = client.get('/artist/?sort=Name')
Expand Down