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

added additional import-lib package for python < 3.7 #35

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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 @@ -4,12 +4,13 @@ python:
- "3.5"
- "3.6"
- "3.7"
- "3.8"
# command to install dependencies
cache:
- pip
install:
- export BOTO_CONFIG=/dev/null
- "pip install setuptools --upgrade; pip install -r test_requirements.txt; python setup.py install"
- "pip install setuptools --upgrade; pip install --upgrade -r test_requirements.txt; python setup.py install"
# command to run tests
env:
- AWS_ACCESS_KEY_ID=foo AWS_SECRET_ACCESS_KEY=bar TESTCASE=tests/tests.py
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.5.2
* added more test cases for .all
* added python 3.8 support in tests
* specified additonal packages for python3.6

## 0.5.1
* Enhanced testing and increased coverage
* Fixed bug with .delete not removing an item from the cache
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
[![Slack](https://img.shields.io/badge/chat-slack-ff69b4.svg)](https://slack.zappa.io/)
[![Gun.io](https://img.shields.io/badge/made%20by-gun.io-blue.svg)](https://gun.io/)
[![Patreon](https://img.shields.io/badge/support-patreon-brightgreen.svg)](https://patreon.com/zappa)
<!-- ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/nodb) -->

_NoDB isn't a database.. but it sort of looks like one!_

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ appdirs>=1.4.3
funcsigs>=1.0.2
packaging>=16.8
pbr>=2.0.0
importlib-resources>=1.0.2 ; python_version < '3.7'
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@

setup(
name='nodb',
version='0.5.1',
version='0.5.2',
packages=['nodb'],
install_requires=required,
extras_require={':python_version<"3.7"': ['importlib-resources']},
tests_require=test_required,
test_suite='nose.collector',
include_package_data=True,
Expand All @@ -36,6 +37,9 @@
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
],
Expand Down
34 changes: 30 additions & 4 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def random_string(length):
return ''.join(random.choice(string.printable) for _ in range(length))


# noinspection DuplicatedCode
class TestNoDB(unittest.TestCase):
# def setUp(self):
# self.sleep_patch = mock.patch('time.sleep', return_value=None)
Expand Down Expand Up @@ -144,19 +145,44 @@ def test_nodb_cache(self):
bcp = nodb._get_base_cache_path()

@moto.mock_s3
def test_nodb_all(self):
def test_nodb_all_empty(self):
# create dummy bucket and store some objects
bucket_name = 'dummy_bucket_12345_qwerty'
bucket_name = 'dummy_bucket_all_empty'
self._create_mock_bucket(bucket_name)

nodb = NoDB(bucket_name)
nodb.index = "Name"

self.assertListEqual([], nodb.all())

@moto.mock_s3
def test_nodb_all_results(self):
# create dummy bucket and store some objects
bucket_name = 'dummy_bucket_all_results'
self._create_mock_bucket(bucket_name)

nodb = NoDB(bucket_name)
nodb.index = "Name"

nodb.save({"Name": "John", "age": 19})
nodb.save({"Name": "Jane", "age": 20})

self.assertListEqual([{"Name": "John", "age": 19}, {"Name": "Jane", "age": 20}], nodb.all())

@moto.mock_s3
def test_nodb_all_json_results(self):
# create dummy bucket and store some objects
bucket_name = 'dummy_bucket_all_json'
self._create_mock_bucket(bucket_name)

nodb = NoDB(bucket_name)
nodb.index = "Name"
nodb.serializer = "json"

nodb.save({"Name": "John", "age": 19})
nodb.save({"Name": "Jane", "age": 20})

all_objects = nodb.all()
self.assertListEqual([{"Name": "John", "age": 19}, {"Name": "Jane", "age": 20}], all_objects)
self.assertListEqual([{"Name": "John", "age": 19}, {"Name": "Jane", "age": 20}], nodb.all())

def _create_mock_bucket(self, bucket_name):
boto3.resource('s3').Bucket(bucket_name).create()
Expand Down