diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..5444c2d --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,25 @@ +name: Test development infrastructure. + +on: + schedule: + - cron: '30 * * * *' + workflow_dispatch: + +jobs: + test_infrastructure_dev: + runs-on: ubuntu-latest + name: Test the infrastructure + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: dev + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: 3.10 + - name: Run tests. + run: | + python -m pip install --upgrade pip + pip install pytest requests + pytest -v diff --git a/tests/test_ndc.py b/tests/test_ndc.py new file mode 100644 index 0000000..c016b36 --- /dev/null +++ b/tests/test_ndc.py @@ -0,0 +1,46 @@ +# +# Run with: +# pip install pytest requests # install dependencies. +# pytest -v +# +import requests +import pytest + +TESTCASES = [ + { + "url": "https://lode-ndc-dev.apps.cloudpub.testedev.istat.it/extract?url=https://w3id.org/italia/onto/CPV", + "expected": "Annotation Properties", + "repo": "github.com/teamdigitale/dati-semantic-lode", + }, + { + "url": "https://ndc-dev.apps.cloudpub.testedev.istat.it", + "expected": "Content-Security-Policy", + "repo": "github.com/teamdigitale/dati-semantic-frontend", + }, + { + "url": "https://lod-ndc-dev.apps.cloudpub.testedev.istat.it/onto/CPV", + "expected": "Ontologia delle persone", + "repo": "github.com/teamdigitale/dati-semantic-lodview", + }, + { + "url": "https://ndc-dev.apps.cloudpub.testedev.istat.it/api/vocabularies/", + "expected": "totalCount", + "repo": "github.com/teamdigitale/dati-semantic-backend", + }, + { + "url": "https://virtuoso-dev-external-service-ndc-dev.apps.cloudpub.testedev.istat.it/sparql?default-graph-uri=&query=select+distinct+%3Fprop+%3Fvalue+where+%7B+%3Chttps%3A%2F%2Fw3id.org%2Fitalia%2Fonto%2FAtlasOfPaths%3E+%3Fprop+%3Fvalue%7D+LIMIT+2&format=text%2Fturtle&timeout=0&signal_void=on", + "expected": "owl:NamedIndividual", + "repo": "External Service Virtuoso" + } +] + + +@pytest.mark.parametrize("testcase", TESTCASES) +def test_ndc(testcase): + url = testcase["url"] + expected = testcase["expected"] + repo = testcase["repo"] + print("Testing %s" % url) + r = requests.get(url) + assert r.status_code == 200 + assert expected in r.text, 'Expected "%s" in response from %s' % (expected, repo) \ No newline at end of file