Skip to content

Commit

Permalink
#92 gh actions pyrpoj
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Van Campenhout committed Sep 19, 2024
1 parent b143079 commit 44d111b
Show file tree
Hide file tree
Showing 8 changed files with 252 additions and 105 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/skosprovider_heritagedata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: skosprovider_heritagedata backend tests
on:
push:
paths:
- skosprovider_heritagedata/**
- tests/**
- skosprovider_heritagedata.yaml
- pyproject.toml
- requirements*.txt
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.10", "3.11", "3.12" ]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# You can test your matrix by printing the current Python version
- name: Display Python version
run: python -c "import sys; print(sys.version)"

- name: Install python requirements
env:
HATCH_BUILD_NO_HOOKS: true
working-directory: ./
run: |
pip --version
pip install pip-tools
pip-sync requirements-dev.txt
pip install -e .
- name: Python tests
run: pytest tests --exitfirst --capture=no -vvv --full-trace
15 changes: 0 additions & 15 deletions .travis.yml

This file was deleted.

67 changes: 67 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
[build-system]
requires = ["hatchling", "hatch-fancy-pypi-readme"]
build-backend = "hatchling.build"

[project]
version = "1.2.1"
name = "skosprovider_heritagedata"
license="MIT"
dynamic = ["readme"]
authors = [
{ name = "Flanders Heritage Agency", email = "[email protected]" },
]
#license = "GPL-3.0-or-later"
description = "Skosprovider implementation of the heritagedata.org Vocabularies"
requires-python = ">=3.10,<3.13"
keywords = ["rdf", "skos", "skosprovider", "vocabularies", "thesauri"]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python",
"Framework :: Pyramid",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dependencies = [
"requests==2.32.3",
"skosprovider==1.2.0",
"rdflib==6.3.2",

]

[project.urls]
History = "https://github.com/OnroerendErfgoed/skosprovider_heritagedata/blob/master/CHANGES.rst"
Tracker = "https://github.com/OnroerendErfgoed/skosprovider_heritagedata/issues"
Source = "https://github.com/OnroerendErfgoed/skosprovider_heritagedata"
Documentation = "https://skosprovider_heritagedata.readthedocs.io/en/latest/"

[project.optional-dependencies]
dev = [
"uv==0.4.1",
"pytest==8.3.3",
"pytest-cov==5.0.0",
"coveralls==4.0.1",
"sphinx==8.0.2",
]

##
# Build tool specific
##
[tool.hatch.build.targets.wheel]
# In the wheel we want to have skosprovider_heritagedata in the root as python module.
only-include = [
"/skosprovider_heritagedata",
]

[tool.hatch.metadata]
# This allows us to use github links as dependencies
allow-direct-references = true

[tool.hatch.metadata.hooks.fancy-pypi-readme]
content-type = "text/x-rst"
fragments = [
{ path = "README.rst" },
{ path = "CHANGES.rst" },
]
105 changes: 95 additions & 10 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,95 @@
# Runtime requirements
--requirement requirements.txt

# Testing
pytest==6.2.5
pytest-cov==3.0.0
coveralls==3.3.1

# Documentation
Sphinx==4.3.0
alabaster==1.0.0
# via sphinx
babel==2.16.0
# via sphinx
cachetools==5.5.0
# via pyld
certifi==2024.8.30
# via requests
charset-normalizer==3.3.2
# via requests
coverage==7.6.1
# via
# coveralls
# pytest-cov
coveralls==4.0.1
# via skosprovider-heritagedata (pyproject.toml)
docopt==0.6.2
# via coveralls
docutils==0.21.2
# via sphinx
frozendict==2.4.4
# via pyld
html5lib==1.1
# via skosprovider
idna==3.10
# via requests
imagesize==1.4.1
# via sphinx
iniconfig==2.0.0
# via pytest
isodate==0.6.1
# via rdflib
jinja2==3.1.4
# via sphinx
language-tags==1.2.0
# via skosprovider
lxml==5.3.0
# via pyld
markupsafe==2.1.5
# via jinja2
packaging==24.1
# via
# pytest
# sphinx
pluggy==1.5.0
# via pytest
pygments==2.18.0
# via sphinx
pyld==2.0.4
# via skosprovider
pyparsing==3.1.4
# via rdflib
pytest==8.3.3
# via
# skosprovider-heritagedata (pyproject.toml)
# pytest-cov
pytest-cov==5.0.0
# via skosprovider-heritagedata (pyproject.toml)
rdflib==6.3.2
# via skosprovider-heritagedata (pyproject.toml)
requests==2.32.3
# via
# skosprovider-heritagedata (pyproject.toml)
# coveralls
# sphinx
rfc3987==1.3.8
# via skosprovider
six==1.16.0
# via
# html5lib
# isodate
skosprovider==1.2.0
# via skosprovider-heritagedata (pyproject.toml)
snowballstemmer==2.2.0
# via sphinx
sphinx==8.0.2
# via skosprovider-heritagedata (pyproject.toml)
sphinxcontrib-applehelp==2.0.0
# via sphinx
sphinxcontrib-devhelp==2.0.0
# via sphinx
sphinxcontrib-htmlhelp==2.1.0
# via sphinx
sphinxcontrib-jsmath==1.0.1
# via sphinx
sphinxcontrib-qthelp==2.0.0
# via sphinx
sphinxcontrib-serializinghtml==2.0.0
# via sphinx
urllib3==2.2.3
# via requests
uv==0.4.1
# via skosprovider-heritagedata (pyproject.toml)
webencodings==0.5.1
# via html5lib
39 changes: 37 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
requests==2.31.0
skosprovider==1.2.0
cachetools==5.5.0
# via pyld
certifi==2024.8.30
# via requests
charset-normalizer==3.3.2
# via requests
frozendict==2.4.4
# via pyld
html5lib==1.1
# via skosprovider
idna==3.10
# via requests
isodate==0.6.1
# via rdflib
language-tags==1.2.0
# via skosprovider
lxml==5.3.0
# via pyld
pyld==2.0.4
# via skosprovider
pyparsing==3.1.4
# via rdflib
rdflib==6.3.2
# via skosprovider-heritagedata (pyproject.toml)
requests==2.32.3
# via skosprovider-heritagedata (pyproject.toml)
rfc3987==1.3.8
# via skosprovider
six==1.16.0
# via
# html5lib
# isodate
skosprovider==1.2.0
# via skosprovider-heritagedata (pyproject.toml)
urllib3==2.2.3
# via requests
webencodings==0.5.1
# via html5lib
45 changes: 0 additions & 45 deletions setup.py

This file was deleted.

26 changes: 15 additions & 11 deletions tests/test_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def test_scheme_uri_not_available(self):

def test_get_top_concepts_provider(self):
provider = HeritagedataProvider({'id': 'Heritagedata'}, scheme_uri='http://purl.org/heritagedata/schemes/eh_period')
self.assertEqual(len(provider.get_top_concepts()), 8)
self.assertEqual(len(provider.get_top_concepts()), 2)

def test_default_language_scottish_gaelic(self):
provider_gd = HeritagedataProvider({'id': 'Heritagedata', 'default_language': 'gd'}, scheme_uri='http://purl.org/heritagedata/schemes/1')
Expand Down Expand Up @@ -93,7 +93,7 @@ def test_get_by_id_concept(self):
self.assertEqual(concept['type'], 'concept')
self.assertIsInstance(concept['labels'], list)

preflabels = [{'en': 'POST MEDIEVAL'}]
preflabels = [{'en': 'Post Medieval'}]
preflabels_conc = [{label.language: label.label} for label in concept['labels']
if label.type == 'prefLabel']
self.assertGreater(len(preflabels_conc), 0)
Expand All @@ -103,13 +103,17 @@ def test_get_by_id_concept(self):
self.assertGreater(len(concept['notes']), 0)
self.assertIsNotNone(concept['notes'][0])
self.assertEqual(concept['notes'][0].language, 'en')
self.assertEqual(concept['notes'][0].note, 'Begins with the dissolution of the monasteries and'
' ends with the death of Queen Victoria. '
'Use more specific period where known.')
self.assertEqual(
concept['notes'][0].note,
'Begins with the dissolution '
'of the monasteries (c.1540) and ends with the '
'death of Queen Victoria (1901). '
'Use more specific period where known.'
)
self.assertEqual(concept['notes'][0].type, 'scopeNote')

self.assertEqual(concept['id'], 'PM')
self.assertEqual(len(concept['broader']), 0)
self.assertEqual(len(concept['broader']), 1)
self.assertEqual(len(concept['related']), 0)
self.assertIn('STU', concept['narrower'])

Expand All @@ -135,7 +139,7 @@ def test_get_top_display(self):
keys_first_display = top_heritagedata_display[0].keys()
for key in ['id', 'type', 'label', 'uri']:
self.assertIn(key, keys_first_display)
self.assertIn('POST MEDIEVAL', [label['label'] for label in top_heritagedata_display])
self.assertIn('Centuries', [label['label'] for label in top_heritagedata_display])

def test_get_top_display_sort_sort(self):
prov = HeritagedataProvider(
Expand Down Expand Up @@ -163,10 +167,10 @@ def test_get_top_concepts_sort(self):
sorted_by_id = prov.get_top_concepts(sort='id')
assert [c['id'] for c in not_sorted] == [c['id'] for c in sorted_by_id]
sorted_by_uri = prov.get_top_concepts(sort='uri')
assert len(sorted_by_id) == 8
assert len(sorted_by_id) == 2
assert len(sorted_by_id) == len(sorted_by_uri)
assert [c['id'] for c in sorted_by_id] == [c['id'] for c in sorted_by_uri]
sorted_by_label = prov.get_top_concepts(sort='label')
sorted_by_label = prov.get_top_concepts(sort='label', sort_order='desc')
assert len(sorted_by_id) == len(sorted_by_label)
assert [c['id'] for c in sorted_by_id] == [c['id'] for c in sorted_by_label]

Expand All @@ -178,7 +182,7 @@ def test_get_childeren_display(self):
keys_first_display = childeren_Heritagedata_pm[0].keys()
for key in ['id', 'type', 'label', 'uri']:
self.assertIn(key, keys_first_display)
self.assertIn("TUDOR", [label['label'] for label in childeren_Heritagedata_pm])
self.assertIn("Tudor", [label['label'] for label in childeren_Heritagedata_pm])

def test_get_children_display_sort(self):
prov = HeritagedataProvider(
Expand Down Expand Up @@ -272,7 +276,7 @@ def test_get_items(self):
provider = HeritagedataProvider({'id': 'Heritagedata'},service_scheme_uri='http://heritagedata.org/live/services/')
res = provider._get_items("getConceptLabelMatch", {'contains': 'VICTORIAN', 'schemeURI': 'http://purl.org/heritagedata/schemes/eh_period'})
self.assertEqual(len(res), 1)
self.assertEqual(res[0]['label'], 'VICTORIAN')
self.assertEqual(res[0]['label'], 'Victorian')
self.assertEqual(res[0]['id'], 'VIC')
self.assertEqual(res[0]['lang'], 'en')
self.assertEqual(res[0]['type'], 'concept')
Expand Down
Loading

0 comments on commit 44d111b

Please sign in to comment.