diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..4edd7b1 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,2 @@ +[run] +relative_files = True diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml new file mode 100644 index 0000000..13e2b02 --- /dev/null +++ b/.github/workflows/django.yml @@ -0,0 +1,51 @@ +name: Django CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + max-parallel: 4 + matrix: + python-version: [3.7, 3.8, 3.9] + + services: + dynamodb: + image: amazon/dynamodb-local + ports: + - 8000:8000 + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + pip install -r tests/requirements.txt + pip install -e . + - name: Run Tests + run: | + flake8 --config .config/flake8 pydjamodb + coverage run tests/manage.py test tests + - name: Coveralls + uses: AndreMiras/coveralls-python-action@develop + with: + parallel: true + flag-name: Unit Test + + coveralls_finish: + needs: test + runs-on: ubuntu-latest + steps: + - name: Coveralls Finished + uses: AndreMiras/coveralls-python-action@develop + with: + parallel-finished: true diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e4d33a2..0000000 --- a/.travis.yml +++ /dev/null @@ -1,36 +0,0 @@ -sudo: false -language: python -dist: xenial -python: - - 3.9 - - 3.8 - - 3.7 - - 3.6 -cache: pip -env: - global: - - PYTHONWARNINGS=default,ignore::PendingDeprecationWarning,ignore::ResourceWarning - - DJANGO_DATABASE_USER_POSTGRES=postgres - - DJANGO_DATABASE_USER_MYSQL=travis - matrix: - - DJANGO='>=3.1,<3.2' - - DJANGO='>=3.0,<3.1' - - DJANGO='>=2.2,<3.0' -matrix: - fast_finish: true -services: - - docker -install: - - pip install --pre django$DJANGO - - pip install -r tests/requirements.txt - - pip install -e . -before_script: - - docker pull amazon/dynamodb-local - - docker run -d -p 8000:8000 amazon/dynamodb-local:1.13.4 -script: - - flake8 --config .config/flake8 pydjamodb - - coverage run tests/manage.py test tests -after_success: - - coverage report -notifications: - email: false diff --git a/README.md b/README.md index 7f181c0..980ae5b 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ Prolog `pydjamodb` library is Django connector to the AWS DynamoDB. As a base is used `PynamoDB` library which models is transformed into `Django` model structure with the querysets and managers. +[![Coverage Status](https://coveralls.io/repos/github/druids/pydjamodb/badge.svg?branch=master)](https://coveralls.io/github/druids/pydjamodb?branch=master) + Installation ------------ diff --git a/pydjamodb/queryset.py b/pydjamodb/queryset.py index 86e652c..7f6de8d 100644 --- a/pydjamodb/queryset.py +++ b/pydjamodb/queryset.py @@ -205,6 +205,8 @@ def filter(self, **kwargs): obj._pre_filter(field, field_name, operator, value) obj._filter = obj._get_filter(field, operator, value) + if operator == 'between' and value[0] > value[1]: + return self.none() return obj def get(self, **kwargs): diff --git a/tests/requirements.txt b/tests/requirements.txt index 32587da..78bd1fe 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,4 +1,4 @@ https://github.com/druids/pynamodb/tarball/AddTagsSupport#egg=pynamodb django-germanium==2.2.3 flake8 -coverage +coveralls diff --git a/tests/test_app/tests/__init__.py b/tests/test_app/tests/__init__.py index 4d4ea01..aaf7302 100644 --- a/tests/test_app/tests/__init__.py +++ b/tests/test_app/tests/__init__.py @@ -99,6 +99,7 @@ def test_queryset_filter_should_return_filtered_items(self): qs = TestDynamoModel.objects_string_number.set_hash_key('test') assert_equal(list(qs.filter(number=5)), [instances[5]]) assert_equal(list(qs.filter(number__between=(2, 4))), instances[2:5]) + assert_equal(list(qs.filter(number__between=(4, 2))), []) assert_equal(list(qs.filter(number__gt=4)), instances[5:]) assert_equal(list(qs.filter(number__lte=4)), instances[:5])