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

Omnibus PR for our consideration 2019.10.04 #746

Merged
merged 46 commits into from
Oct 18, 2019
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
ab842c7
Changes need to update to Django 2.2.x and Python 3.7
rdhyee Jun 11, 2019
7f7ee7e
add new requirements to python_apt_package_deps for Python 3.7
rdhyee Jun 11, 2019
72cd357
updated tests -- made to run on top of django2 updates
rdhyee Jun 11, 2019
cbc2fe8
add pandas requirement
rdhyee Jun 27, 2019
f29bb12
first pass at allowing for customization of parameters in the Vagrant…
rdhyee Jun 29, 2019
56fedca
getting pip to install correctly...but other problems in build left
rdhyee Jun 29, 2019
899801e
experiment with extra.yml to allow for overriding values of variables…
rdhyee Jul 17, 2019
5e9c908
loosen the versions in Pipfile
rdhyee Jul 19, 2019
776da7a
don't let pandas update pass 0.24.x at this point since 0.25.0 is cau…
rdhyee Jul 19, 2019
782c932
update Python to 3.7.4 and add liblzma-dev package because ModuleNotF…
rdhyee Jul 19, 2019
5f08c5e
pandas = ">=0.24.0" since pandas 0.25 works because liblzma-dev is no…
rdhyee Jul 19, 2019
0fcb003
working configuration for opencontext_predb Vagrant machine to spin u…
rdhyee Jul 30, 2019
8b48bd5
start tagging opencontext_predb instance
rdhyee Jul 31, 2019
30f5318
some prerequisites for letsencrypt
rdhyee Sep 17, 2019
cbe3f35
fixes to test_basic.py -- I'm not sure why these tests broke in the f…
rdhyee Sep 17, 2019
2094d89
added server_name to nginx_conf.j2
rdhyee Sep 17, 2019
ede8656
for debugging ansible module gcp_dns_resource_record_set
rdhyee Sep 19, 2019
fe5d454
latest attempt to run gcp_dns_resource_record_set
rdhyee Sep 22, 2019
69b68d2
stepping stone to adding more sensitive stuff to nginx_conf.j2
rdhyee Sep 22, 2019
f64cfc4
adding more options to nginx_conf.j2
rdhyee Sep 23, 2019
065213e
adding configuration for SSL part of nginx configuration and add a se…
rdhyee Sep 23, 2019
70da5bd
fixed syntax problems in build.yml
rdhyee Sep 23, 2019
dc87af3
adding *.opencontext.org ssl cert (Expiry Date: 2019-12-23 14:22:14+0…
rdhyee Sep 24, 2019
793fded
add network and subnetwork to Vagrantfile
rdhyee Sep 30, 2019
0f35377
typo in Vagrantfile for subnetwork
rdhyee Sep 30, 2019
db9b170
pass 1 at incorporating rest of variables in secrets.json
rdhyee Oct 2, 2019
9634fbe
change oc_install_dir to /var/oc-venv
rdhyee Oct 2, 2019
afe5a85
consolidate static_dir
rdhyee Oct 2, 2019
2b14c1d
adding utility scripts
rdhyee Oct 2, 2019
85e241c
change file ownership to www-data
rdhyee Oct 3, 2019
4daa837
fix typos en route to more use of www-data -- but not complete transi…
rdhyee Oct 3, 2019
bcd62f3
ansible_ssh_user -> ansible_user
rdhyee Oct 3, 2019
3e1867c
move to using www-data looks pretty good now
rdhyee Oct 4, 2019
5ccbf39
forgot to turn off restart-here
rdhyee Oct 4, 2019
3735b9f
new *.opencontext.org cert expiration 2020.01.02
rdhyee Oct 4, 2019
d035927
try to setgid on {{oc_install_dir}}
rdhyee Oct 5, 2019
fed8503
set chmod g=y for {{oc_install_dir}} at the end
rdhyee Oct 5, 2019
8db5bb2
debugging: permissions
rdhyee Oct 7, 2019
21b4e7e
create static cache explicitly
rdhyee Oct 8, 2019
969c8f2
move to next stages of fixing tests
rdhyee Oct 9, 2019
1dd9435
refinements that I think are now working for opencontext_predb and op…
rdhyee Oct 11, 2019
858c917
Merge branch 'staging_prod_ssl' of github.com:rdhyee/open-context-py …
rdhyee Oct 11, 2019
cc1f14b
new certs should cover both *.opencontext.org and opencontext.org
rdhyee Oct 11, 2019
1fa5444
changing secret_key to match the curren production key
rdhyee Oct 11, 2019
e586c26
added cronjob to restart uwsgi on reboot
rdhyee Oct 15, 2019
12a9564
fill out some parameters that I had left empty in opencontext with th…
rdhyee Oct 17, 2019
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
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain

sysadmin/files/referral-spam.conf diff=ansible-vault merge=binary
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense to encrypt open-context-py/referral-spam.conf at ry20191004 · rdhyee/open-context-py -- hence this line to help understand diffs in that file

sysadmin/templates/nginx_conf.j2 diff=ansible-vault merge=binary
sysadmin/files/ssl-certs/opencontext_predb/* diff=ansible-vault merge=binary
58 changes: 58 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
[[source]]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General approach for setting up Pipfile is to set minimum versions but not fix any versions unless necessary.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK!

name = "pypi"
verify_ssl = true
url = "https://pypi.org/simple"

[packages]
anyjson = ">=0.3.3"
coverage = ">=4.0.3"
coveralls = ">=1.1"
Django = ">=2.0.7"
django-debug-toolbar = ">=1.9"
django-redis-cache = ">=1.7.0"
django-reversion = ">=2.0.6"
django-user_agents = ">=0.3.0"
docopt = ">=0.6.2"
feedparser = ">=5.2.1"
geojson = ">=1.3"
isodate = ">=0.5.4"
jsonfield = ">=1.0.3"
lxml = ">=3.8"
mysolr = ">=0.8.3"
numpy = ">=1.11.0"
pandas = ">=0.24.0"
"psycopg2" = ">=2.7.5"
pyparsing = ">=2.1.1"
python-dateutil = ">=2.5.3"
pytz = ">=2016.4"
rdflib = ">=4.2.1"
rdflib-jsonld = ">=0.4.0"
redis = ">=2.10.5"
requests = ">=2.20.0"
roman = ">=2.0.0"
scipy = ">=0.17.0"
six = ">=1.10.0"
sqlparse = ">=0.2.4"
titlecase = ">=0.9.0"
ua-parser = ">=0.7.1"
user-agents = ">=1.0.1"
python-memcached = ">=1.59"
pyproj = ">=1.9.5"
atomicwrites = ">=1.2.1"
attrs = ">=18.2.0"
more-itertools = ">=4.3.0"
"pathlib2" = ">=2.3.2"
pluggy = ">=0.8.0"
py = ">=1.7.0"
pytest = ">=3.9.3"
pytest-django = ">=3.4.3"
Pillow = ">=5.2.0"
PyYAML = ">=3.11"
Shapely = ">=1.5.15"
Unidecode = ">=0.4.19"
uWSGI = ">=2.0.17.1"

[dev-packages]

[requires]
python_version = "3.7"
616 changes: 616 additions & 0 deletions Pipfile.lock

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import pytest
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file enables the use of production database for tests. One thing that needs to confirmed: is this the right place for this file?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I can look into this also. We should mainly just configure database access for tests that go in the tests/regression path. The "unit" tests should be completely database free, and the "integration" tests can use a short term database that gets temporarily set up and then torn down after the tests complete.

import json
from opencontext_py import settings

@pytest.fixture(autouse=True)
def enable_db_access_for_all_tests(db):
pass

@pytest.fixture(scope='session')
def django_db_setup():

with open('secrets.json', 'r') as secrets_file:
secrets = json.loads(secrets_file.read())

settings.DATABASES['default'] = {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': secrets.get('DATABASES_NAME'),
'USER': secrets.get('DATABASES_USER'),
'PASSWORD': secrets.get('DATABASES_PASSWORD'),
'HOST': secrets.get('DATABASES_HOST'),
'CONN_MAX_AGE': 600,
}
4 changes: 2 additions & 2 deletions opencontext_py/apps/about/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ class TestPredicateValues(TestCase):

def setUp(self):
self.oc_item = OCitem(
).get_item('9E474B89-E36B-4B9D-2D38-7C7CCBDBB030')
).get_item('FA6BFBFD-39EB-4474-A2D9-860B2D1B81A6')
self.json_ld = self.oc_item.json_ld
self.oc_label = self.json_ld['label']

def test_get_oc_item_label(self):
#oc_label = self.json_ld['label']
self.assertEqual(self.oc_label, 'Bone 4502')
self.assertEqual(self.oc_label, 'CAT # 20')
10 changes: 8 additions & 2 deletions opencontext_py/apps/archive/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from django.db import transaction
from django.conf import settings
from django.test import TestCase
from django.test.client import Client
from rdflib.plugin import register, Parser
from rdflib import Graph, URIRef, Literal
from rdflib.graph import ConjunctiveGraph
Expand All @@ -28,10 +29,15 @@ def setUp(self):
'rdflib_jsonld.parser',
'JsonLDParser')
# self.graph = Graph()
self.proj_context_uri = 'http://127.0.0.1:8000/contexts/projects/3.json'
# self.proj_context_uri = 'http://127.0.0.1:8000/contexts/projects/3FAAA477-5572-4B05-8DC1-CA264FE1FC10.json'
self.proj_context_uri = '/contexts/projects/3FAAA477-5572-4B05-8DC1-CA264FE1FC10.json'
self.context_file = settings.STATIC_IMPORTS_ROOT + '3-context.json'
self.data_file = settings.STATIC_IMPORTS_ROOT + 'dt-bone.json'
self.context_str = self.request_json_str(self.proj_context_uri)
#self.context_str = self.request_json_str(self.proj_context_uri)
client = Client()
response = client.get(self.proj_context_uri, follow=True)
assert response.status_code in [200,301]
self.context_str = response.content
self.data_str = self.load_json_file_str(self.data_file)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at this point, the setup still fails because self.data_str is still None.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to check in dt-bone.json into the STATIC_IMPORTS_ROOT dir? Is there a complication to this?

g_context = ConjunctiveGraph(identifier=self.proj_context_uri)
g_context.parse(data=self.context_str, format='json-ld')
Expand Down
3 changes: 2 additions & 1 deletion opencontext_py/apps/contexts/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ def setUp(self):
'rdflib_jsonld.parser',
'JsonLDParser')
# self.graph = Graph()
self.proj_context_uri = 'http://127.0.0.1:8000/contexts/projects/3.json'
#self.proj_context_uri = 'http://127.0.0.1:8000/contexts/projects/3.json'
self.proj_context_uri = '/127.0.0.1:8000/contexts/projects/3.json'
self.context_file = settings.STATIC_IMPORTS_ROOT + '3-context.json'
self.data_file = settings.STATIC_IMPORTS_ROOT + 'dt-bone.json'
self.context_str = self.request_json_str(self.proj_context_uri)
Expand Down
4 changes: 2 additions & 2 deletions opencontext_py/apps/edit/inputs/fieldgroups/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ class TestPredicateValues(TestCase):

def setUp(self):
self.oc_item = OCitem(
).get_item('9E474B89-E36B-4B9D-2D38-7C7CCBDBB030')
).get_item('FA6BFBFD-39EB-4474-A2D9-860B2D1B81A6')
self.json_ld = self.oc_item.json_ld
self.oc_label = self.json_ld['label']

def test_get_oc_item_label(self):
#oc_label = self.json_ld['label']
self.assertEqual(self.oc_label, 'Bone 4502')
self.assertEqual(self.oc_label, 'CAT # 20')
4 changes: 2 additions & 2 deletions opencontext_py/apps/edit/inputs/inputfields/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ class TestPredicateValues(TestCase):

def setUp(self):
self.oc_item = OCitem(
).get_item('9E474B89-E36B-4B9D-2D38-7C7CCBDBB030')
).get_item('FA6BFBFD-39EB-4474-A2D9-860B2D1B81A6')
self.json_ld = self.oc_item.json_ld
self.oc_label = self.json_ld['label']

def test_get_oc_item_label(self):
#oc_label = self.json_ld['label']
self.assertEqual(self.oc_label, 'Bone 4502')
self.assertEqual(self.oc_label, 'CAT # 20')
4 changes: 2 additions & 2 deletions opencontext_py/apps/edit/inputs/inputrelations/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ class TestPredicateValues(TestCase):

def setUp(self):
self.oc_item = OCitem(
).get_item('9E474B89-E36B-4B9D-2D38-7C7CCBDBB030')
).get_item('FA6BFBFD-39EB-4474-A2D9-860B2D1B81A6')
self.json_ld = self.oc_item.json_ld
self.oc_label = self.json_ld['label']

def test_get_oc_item_label(self):
#oc_label = self.json_ld['label']
self.assertEqual(self.oc_label, 'Bone 4502')
self.assertEqual(self.oc_label, 'CAT # 20')
4 changes: 2 additions & 2 deletions opencontext_py/apps/edit/inputs/profiles/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ class TestPredicateValues(TestCase):

def setUp(self):
self.oc_item = OCitem(
).get_item('9E474B89-E36B-4B9D-2D38-7C7CCBDBB030')
).get_item('FA6BFBFD-39EB-4474-A2D9-860B2D1B81A6')
self.json_ld = self.oc_item.json_ld
self.oc_label = self.json_ld['label']

def test_get_oc_item_label(self):
#oc_label = self.json_ld['label']
self.assertEqual(self.oc_label, 'Bone 4502')
self.assertEqual(self.oc_label, 'CAT # 20')
4 changes: 2 additions & 2 deletions opencontext_py/apps/edit/inputs/rules/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ class TestPredicateValues(TestCase):

def setUp(self):
self.oc_item = OCitem(
).get_item('9E474B89-E36B-4B9D-2D38-7C7CCBDBB030')
).get_item('FA6BFBFD-39EB-4474-A2D9-860B2D1B81A6')
self.json_ld = self.oc_item.json_ld
self.oc_label = self.json_ld['label']

def test_get_oc_item_label(self):
#oc_label = self.json_ld['label']
self.assertEqual(self.oc_label, 'Bone 4502')
self.assertEqual(self.oc_label, 'CAT # 20')
4 changes: 2 additions & 2 deletions opencontext_py/apps/index/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ class TestPredicateValues(TestCase):

def setUp(self):
self.oc_item = OCitem(
).get_item('9E474B89-E36B-4B9D-2D38-7C7CCBDBB030')
).get_item('FA6BFBFD-39EB-4474-A2D9-860B2D1B81A6')
self.json_ld = self.oc_item.json_ld
self.oc_label = self.json_ld['label']

def test_get_oc_item_label(self):
#oc_label = self.json_ld['label']
self.assertEqual(self.oc_label, 'Bone 4502')
self.assertEqual(self.oc_label, 'CAT # 20')
4 changes: 2 additions & 2 deletions opencontext_py/apps/indexer/crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(self):
index_single_document method. Just provide the document's UUID.
For example:

crawler.index_single_document('9E474B89-E36B-4B9D-2D38-7C7CCBDBB030')
crawler.index_single_document('FA6BFBFD-39EB-4474-A2D9-860B2D1B81A6')
'''
# The list of Open Context items to crawl
self.uuidlist = UUIDList().uuids
Expand Down Expand Up @@ -203,7 +203,7 @@ def index_single_document(self, uuid):
UUID as an argument. For example:

crawler = Crawler()
crawler.index_single_document('9E474B89-E36B-4B9D-2D38-7C7CCBDBB030')
crawler.index_single_document('FA6BFBFD-39EB-4474-A2D9-860B2D1B81A6')
'''
print('\nAttempting to index document ' + uuid + '...\n')
start_time = time.time()
Expand Down
4 changes: 2 additions & 2 deletions opencontext_py/apps/indexer/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ class TestPredicateValues(TestCase):

def setUp(self):
self.oc_item = OCitem(
).get_item('9E474B89-E36B-4B9D-2D38-7C7CCBDBB030')
).get_item('FA6BFBFD-39EB-4474-A2D9-860B2D1B81A6')
self.json_ld = self.oc_item.json_ld
self.oc_label = self.json_ld['label']

def test_get_oc_item_label(self):
#oc_label = self.json_ld['label']
self.assertEqual(self.oc_label, 'Bone 4502')
self.assertEqual(self.oc_label, 'CAT # 20')
4 changes: 2 additions & 2 deletions opencontext_py/apps/oai/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ class TestPredicateValues(TestCase):

def setUp(self):
self.oc_item = OCitem(
).get_item('9E474B89-E36B-4B9D-2D38-7C7CCBDBB030')
).get_item('FA6BFBFD-39EB-4474-A2D9-860B2D1B81A6')
self.json_ld = self.oc_item.json_ld
self.oc_label = self.json_ld['label']

def test_get_oc_item_label(self):
#oc_label = self.json_ld['label']
self.assertEqual(self.oc_label, 'Bone 4502')
self.assertEqual(self.oc_label, 'CAT # 20')
2 changes: 1 addition & 1 deletion opencontext_py/apps/ocitems/projects/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def view_allowed(self, request):
def edit_allowed(self, request):
""" Checks to see if a user is allowed to edit a project """
output = False
if request.user.is_authenticated():
if request.user.is_authenticated:
if request.user.is_superuser:
# super users are super!
output = True
Expand Down
4 changes: 2 additions & 2 deletions opencontext_py/apps/utilities/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ class TestPredicateValues(TestCase):

def setUp(self):
self.oc_item = OCitem(
).get_item('9E474B89-E36B-4B9D-2D38-7C7CCBDBB030')
).get_item('FA6BFBFD-39EB-4474-A2D9-860B2D1B81A6')
self.json_ld = self.oc_item.json_ld
self.oc_label = self.json_ld['label']

def test_get_oc_item_label(self):
#oc_label = self.json_ld['label']
self.assertEqual(self.oc_label, 'Bone 4502')
self.assertEqual(self.oc_label, 'CAT # 20')
2 changes: 1 addition & 1 deletion opencontext_py/libs/requestnegotiation.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def anonymize_request(self, request):
""" anonymizes a request by flushing session cookies for users
that are not logged in
"""
if not request.user.is_authenticated():
if not request.user.is_authenticated:
# the user is not authenticated, therefore
# we will default to expire the session cookie for a user after the default
pass
Expand Down
2 changes: 1 addition & 1 deletion opencontext_py/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def get_secret(setting, secrets=secrets):
'django_user_agents',
)

MIDDLEWARE_CLASSES = (
MIDDLEWARE = (
'debug_toolbar.middleware.DebugToolbarMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
Expand Down
7 changes: 7 additions & 0 deletions opencontext_py/tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# About Tests

The tests directory should be subdivided into 3 directories with different kinds of tests. This will be:

1. `/unit`: These will test functions and not require use of the database.
2. `/integration`: These are tests need a (temporary) database, but can work with fake data.
3. `/regression`: These tests will either require or will be easiest to conduct with real data in the Open Context database.
Loading