Skip to content

Commit

Permalink
Merge pull request #98 from ambitioninc/develop
Browse files Browse the repository at this point in the history
2.0.0
  • Loading branch information
somewes authored Jan 24, 2023
2 parents 111173e + dc92239 commit 56e36f1
Show file tree
Hide file tree
Showing 11 changed files with 142 additions and 106 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# copied from django-cte
name: data_schema tests
on:
push:
branches: [master]
pull_request:
branches: [master,develop]

jobs:
tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python: ['3.7', '3.8', '3.9']
# Time to switch to pytest or nose2??
# nosetests is broken on 3.10
# AttributeError: module 'collections' has no attribute 'Callable'
# https://github.com/nose-devs/nose/issues/1099
django:
- 'Django~=2.2.0'
- 'Django~=3.0.0'
- 'Django~=3.1.0'
- 'Django~=3.2.0'
- 'Django~=4.0.0'
- 'Django~=4.1.0'
experimental: [false]
# include:
# - python: '3.9'
# django: 'https://github.com/django/django/archive/refs/heads/main.zip#egg=Django'
# experimental: true
# # NOTE this job will appear to pass even when it fails because of
# # `continue-on-error: true`. Github Actions apparently does not
# # have this feature, similar to Travis' allow-failure, yet.
# # https://github.com/actions/toolkit/issues/399
exclude:
- python: '3.7'
django: 'Django~=4.0.0'
- python: '3.7'
django: 'Django~=4.1.0'
services:
postgres:
image: postgres:latest
env:
POSTGRES_DB: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Setup
run: |
python --version
pip install --upgrade pip wheel
pip install -r requirements/requirements.txt
pip install -r requirements/requirements-testing.txt
pip install "${{ matrix.django }}"
pip freeze
- name: Run tests
env:
DB_SETTINGS: >-
{
"ENGINE":"django.db.backends.postgresql_psycopg2",
"NAME":"data_schema",
"USER":"postgres",
"PASSWORD":"postgres",
"HOST":"localhost",
"PORT":"5432"
}
run: |
coverage run manage.py test data_schema
coverage report --fail-under=99
continue-on-error: ${{ matrix.experimental }}
- name: Check style
run: flake8 data_schema
40 changes: 0 additions & 40 deletions .travis.yml

This file was deleted.

1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
include README.md
include LICENSE
recursive-include requirements *
6 changes: 6 additions & 0 deletions data_schema/docs/release_notes.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
Release Notes

v2.0.0
------
* drop python 3.6
* python 3.8, 3.9
* django 3.0, 3.1, 3.2, 4.0, 4.1

v1.5.0
------
* Update display_name field on FieldSchema to no longer have a char limit.
Expand Down
20 changes: 10 additions & 10 deletions data_schema/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def test_set_value_dict(self):
data_schema.set_value(val, 'field_key', 'value')
self.assertEquals(val['field_key'], 'value')

@patch('data_schema.models.convert_value', set_spec=True)
@patch('data_schema.models.convert_value', spec_set=True)
def test_get_value_dict(self, convert_value_mock):
"""
Tests getting the value of a field when the object is a dictionary.
Expand All @@ -395,7 +395,7 @@ def test_get_value_dict_cached(self):
value = data_schema.get_value(obj, 'field_key')
self.assertEquals(value, 'none')

@patch('data_schema.models.convert_value', set_spec=True)
@patch('data_schema.models.convert_value', spec_set=True)
def test_get_value_obj(self, convert_value_mock):
"""
Tests the get_value function with an object as input.
Expand All @@ -410,7 +410,7 @@ class Input:
data_schema.get_value(Input(), 'field_key')
convert_value_mock.assert_called_once_with(FieldSchemaType.STRING, 'value', 'format', None, None)

@patch('data_schema.models.convert_value', set_spec=True)
@patch('data_schema.models.convert_value', spec_set=True)
def test_get_value_list(self, convert_value_mock):
"""
Tests the get_value function with a list as input.
Expand Down Expand Up @@ -456,7 +456,7 @@ def test_set_value_dict(self):
field_schema.set_value(val, 'value')
self.assertEquals(val['field_key'], 'value')

@patch('data_schema.models.convert_value', set_spec=True)
@patch('data_schema.models.convert_value', spec_set=True)
def test_get_value_dict(self, convert_value_mock):
"""
Tests getting the value of a field when the object is a dictionary.
Expand All @@ -465,7 +465,7 @@ def test_get_value_dict(self, convert_value_mock):
field_schema.get_value({'field_key': 'hello'})
convert_value_mock.assert_called_once_with(FieldSchemaType.STRING, 'hello', None, None, None)

@patch('data_schema.models.convert_value', set_spec=True)
@patch('data_schema.models.convert_value', spec_set=True)
def test_get_value_obj(self, convert_value_mock):
"""
Tests the get_value function with an object as input.
Expand All @@ -477,7 +477,7 @@ class Input:
field_schema.get_value(Input())
convert_value_mock.assert_called_once_with(FieldSchemaType.STRING, 'value', 'format', None, None)

@patch('data_schema.models.convert_value', set_spec=True)
@patch('data_schema.models.convert_value', spec_set=True)
def test_get_value_list(self, convert_value_mock):
"""
Tests the get_value function with a list as input.
Expand All @@ -486,7 +486,7 @@ def test_get_value_list(self, convert_value_mock):
field_schema.get_value(['hello', 'world'])
convert_value_mock.assert_called_once_with(FieldSchemaType.STRING, 'world', None, None, None)

@patch('data_schema.models.convert_value', set_spec=True)
@patch('data_schema.models.convert_value', spec_set=True)
def test_get_value_dict_non_extant(self, convert_value_mock):
"""
Tests getting the value of a field when the object is a dictionary and it doesn't exist in the dict.
Expand All @@ -495,7 +495,7 @@ def test_get_value_dict_non_extant(self, convert_value_mock):
field_schema.get_value({'field_key': 'hello'})
convert_value_mock.assert_called_once_with(FieldSchemaType.STRING, None, None, None, None)

@patch('data_schema.models.convert_value', set_spec=True)
@patch('data_schema.models.convert_value', spec_set=True)
def test_get_value_obj_non_extant(self, convert_value_mock):
"""
Tests the get_value function with an object as input and the field key is not in the object.
Expand All @@ -508,7 +508,7 @@ class Input:
field_schema.get_value(Input())
convert_value_mock.assert_called_once_with(FieldSchemaType.STRING, None, 'format', None, None)

@patch('data_schema.models.convert_value', set_spec=True)
@patch('data_schema.models.convert_value', spec_set=True)
def test_get_value_list_non_extant_negative(self, convert_value_mock):
"""
Tests the get_value function with a list as input and the input position is negative.
Expand All @@ -517,7 +517,7 @@ def test_get_value_list_non_extant_negative(self, convert_value_mock):
field_schema.get_value(['hello', 'world'])
convert_value_mock.assert_called_once_with(FieldSchemaType.STRING, None, None, None, None)

@patch('data_schema.models.convert_value', set_spec=True)
@patch('data_schema.models.convert_value', spec_set=True)
def test_get_value_list_non_extant_out_of_range(self, convert_value_mock):
"""
Tests the get_value function with a list as input and the input position is greater than the
Expand Down
2 changes: 1 addition & 1 deletion data_schema/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.5.0'
__version__ = '2.0.0'
13 changes: 7 additions & 6 deletions requirements/requirements-testing.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
coverage<=5.5
coveralls<=3.0.1
django-dynamic-fixture<=3.1.1
django-nose<=1.4.7
mock<=4.0.3
psycopg2<=2.8.6
coverage
#coveralls
django-dynamic-fixture
django-nose
mock
psycopg2
flake8
4 changes: 4 additions & 0 deletions requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Django>=2.2
django-manager-utils>=1.4.0
fleming>=0.5.0
python-dateutil>=2.2
22 changes: 12 additions & 10 deletions settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import json

from django.conf import settings

Expand All @@ -12,26 +13,27 @@ def configure_settings():
test_db = os.environ.get('DB', None)
if test_db is None:
db_config = {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'ambition_dev',
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'data_schema',
'USER': 'postgres',
'PASSWORD': '',
'HOST': 'db'
'HOST': 'db',
}
elif test_db == 'postgres':
db_config = {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'USER': 'postgres',
'NAME': 'data_schema',
}
elif test_db == 'sqlite':
db_config = {
'ENGINE': 'django.db.backends.sqlite3',
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'data_schema',
'USER': 'postgres',
'PASSWORD': '',
'HOST': 'db',
}
else:
raise RuntimeError('Unsupported test DB {0}'.format(test_db))

# Check env for db override (used for github actions)
if os.environ.get('DB_SETTINGS'):
db_config = json.loads(os.environ.get('DB_SETTINGS'))

settings.configure(
TEST_RUNNER='django_nose.NoseTestSuiteRunner',
NOSE_ARGS=['--nocapture', '--nologcapture', '--verbosity=1'],
Expand Down
31 changes: 17 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ def get_version():
raise RuntimeError('Unable to find version string in {0}.'.format(VERSION_FILE))


def get_lines(file_path):
return open(file_path, 'r').read().split('\n')


install_requires = get_lines('requirements/requirements.txt')
tests_require = get_lines('requirements/requirements-testing.txt')


setup(
name='django-data-schema',
version=get_version(),
Expand All @@ -30,28 +38,23 @@ def get_version():
packages=find_packages(),
classifiers=[
'Programming Language :: Python',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Framework :: Django',
'Framework :: Django :: 2.2',
'Framework :: Django :: 3.0',
'Framework :: Django :: 3.1',
'Framework :: Django :: 3.2',
'Framework :: Django :: 4.0',
'Framework :: Django :: 4.1',
],
license='MIT',
install_requires=[
'Django<4.0',
'django-manager-utils>=1.4.0',
'fleming>=0.5.0',
'python-dateutil>=2.2',
],
tests_require=[
'Django<4.0',
'django-dynamic-fixture',
'psycopg2',
'django-nose',
'mock',
],
install_requires=install_requires,
tests_require=tests_require,
test_suite='run_tests.run_tests',
include_package_data=True,
)
25 changes: 0 additions & 25 deletions tox.ini

This file was deleted.

0 comments on commit 56e36f1

Please sign in to comment.