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

Unit tests #4

Merged
merged 13 commits into from
Apr 28, 2021
17 changes: 17 additions & 0 deletions .github/styles/vocab.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
gitlab
github
redmine
bugfix
hotfix
bugfixes
mattermost
calver
astro
codecov
Volodymyr
Savchenko
Tramacere
Versoix
Chemin
cdci
antares
26 changes: 26 additions & 0 deletions .github/workflows/prose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Prose Linting
on: [push]

jobs:
prose:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master

- name: Vale
uses: errata-ai/vale-action@v1.2.0
with:
# Optional
styles: |
https://github.com/errata-ai/Microsoft/releases/latest/download/Microsoft.zip
https://github.com/errata-ai/write-good/releases/latest/download/write-good.zip

# Optional
config: https://raw.githubusercontent.com/errata-ai/vale/master/.vale.ini

# Optional
files: '["README.md"]'
env:
# Required
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
55 changes: 55 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python application

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]



jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest mypy pylint coverage
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi

- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics || echo "failed lint"
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics || echo "failed second lint"

- name: PyLint - more lint
run: |
pylint -E dispatcher_plugin_antares || echo 'this is fine!'

- name: MyPy
run: |
mypy dispatcher_plugin_antares --ignore-missing-imports || echo 'this is fine too!'

- name: Test with pytest
run: |
python -m coverage run --source=dispatcher_plugin_antares -m pytest tests -sv --full-trace --log-cli-level=DEBUG

# I wonder how this interacts with the Github App. But this is not only for PR. Also this does not always work
- name: Codecov
uses: codecov/codecov-action@v1.3.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ ANTARES cdci plugin is distributed under the terms of The MIT License.

Who's responsible?
-------------------
Andrea Tramacere
Denys Savchenko, Andrea Tramacere

Copy link
Member

Choose a reason for hiding this comment

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

@andriineronov should I put here Paris? APC or IPGP or something?

ISDC Data Centre for Astrophysics, Astronomy Department of the University of Geneva, Chemin d'Ecogia 16, CH-1290 Versoix, Switzerland

Copy link
Member

Choose a reason for hiding this comment

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

@andriineronov I am about this line

Choose a reason for hiding this comment

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

Remove "ISDC Data Centre for Astrophysics," it does not exist

Copy link
Member Author

Choose a reason for hiding this comment

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

we could really also do these changes in a separate PR, it's not very clear if we are ok with the changes suggested here.

Configuration for deployment
----------------------------
- copy the conf_file from 'cdci_antares_plugin/config_dir/data_server_conf.yml' and place in given directory
- set the env var `CDCI_ANTARES_PLUGIN_CONF_FILE` to the path of the file conf_file
- edit the in conf_file the two keys:
- copy the `conf_file` from `cdci_antares_plugin/config_dir/data_server_conf.yml' and place in given directory

Choose a reason for hiding this comment

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

Minor: perhaps also 'config' will have to be inserted in the vocab list

- set the environment variable `CDCI_ANTARES_PLUGIN_CONF_FILE` to the path of the file conf_file
- edit the in `conf_file` the two keys:

Choose a reason for hiding this comment

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

I might got confused, what are the two keys to edit?

- `data_server_url:`

these two keys must correspond to those in the antares-backend conf_file ie:
these two keys must correspond to those in the antares-backend conf_file i.e.:

- `data_server_url:` -> `url:`

Expand Down
1 change: 1 addition & 0 deletions dispatcher_plugin_antares/config_dir/data_server_conf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ instruments:
antares:
data_server_url: http://localhost:5002
data_server_port: 5002
dummy_cache: dangerously-not-set-to-anything-useful


6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cdci_data_analysis
#pandas
# move to master or pypi later
-e git+https://github.com/oda-hub/dispatcher-app@reusable-fixture#egg=cdci_data_analysis
astropy
simple_logger
numpy
numpy
7 changes: 7 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# we could make a plugin, but it's more effort

from cdci_data_analysis.pytest_fixtures import (
dispatcher_live_fixture,
dispatcher_test_conf,
app
)
43 changes: 43 additions & 0 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import requests
import time
import json
import logging

import pytest


logger = logging.getLogger(__name__)

default_params = dict(
query_status="new",
query_type="Real",
instrument="antares",
product_type="antares_spectrum",
T1="2008-03-19T06:11:11.0",
T2="2008-03-19T06:12:11.0",
async_dispatcher=False,
)

def test_discover_plugin():
import cdci_data_analysis.plugins.importer as importer

assert 'dispatcher_plugin_antares' in importer.cdci_plugins_dict.keys()


@pytest.mark.xfail
def test_default(dispatcher_live_fixture):
server = dispatcher_live_fixture

logger.info("constructed server: %s", server)
c = requests.get(server + "/run_analysis",
params = default_params)

logger.info("content: %s", c.text)
jdata = c.json()
logger.info(json.dumps(jdata, indent=4, sort_keys=True))
logger.info(jdata)
assert c.status_code == 200

assert jdata['job_status'] == 'done'