Skip to content

Commit adc3374

Browse files
committed
minor fixes before first release
1 parent 8df791e commit adc3374

5 files changed

Lines changed: 78 additions & 12 deletions

File tree

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,19 @@ before_install:
3232

3333
install:
3434
- pip install tox-travis
35+
- pip install coverage
36+
- pip install coveralls
3537
- virtualenv --version
3638
- easy_install --version
3739
- pip --version
3840
- tox --version
3941

42+
4043
script:
4144
- tox
45+
- pytest tests/ --cov=pyDataverse --cov-report=term-missing --cov-report=xml --cov-report=html
4246

4347
after_success:
44-
- pip install codecov
4548
- coveralls
4649

4750
notifications:

README.md

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,19 @@ A Python module to work with the Dataverse API. It allows to create, update and
2323

2424
## INSTALL
2525

26-
```bash
26+
**Requirements**
27+
28+
* curl
29+
30+
**Install**
31+
32+
```shell
2733
virtualenv --python=/usr/bin/python3 venv
2834
source venv/bin/activate
2935
pip install -r requirements.txt
3036
```
3137

32-
## USE
38+
## QUICKSTART
3339

3440
**Connect to API**
3541

@@ -49,24 +55,60 @@ print(resp.json())
4955
**Get dataset**
5056

5157
```python
52-
identifier = 'doi:10.5072/FK2/U6AEZM' # doi of the dataset
58+
identifier = 'doi:10.5072/FK2/U6AEZM' # doi of the dataset
5359
resp = api.get_dataset(identifier)
5460
```
5561

5662
**Get datafile**
5763

5864
```python
59-
file_id = '32' # file id of the datafile
60-
resp = api.get_datafile(file_id)
61-
resp.content
65+
datafile_id = '32' # file id of the datafile
66+
resp = api.get_datafile(datafile_id)
67+
print(resp.content)
6268
```
6369

6470
## DEVELOPMENT
6571

72+
### Install
73+
74+
```bash
75+
virtualenv --python=/usr/bin/python3 venv
76+
source venv/bin/activate
77+
pip install -r requirements.txt
78+
```
79+
6680
### Testing
6781

82+
[Tox](http://tox.readthedocs.io/) together with [pytest](https://docs.pytest.org/en/latest/) is used für testing.
83+
84+
First, you need to set the needed ENV variables. You can create a pytest.ini file with the ENV variables in it:
85+
86+
Example:
87+
```ini
88+
[pytest]
89+
env =
90+
API_TOKEN=<SECRET>
91+
DATAVERSE_VERSION=4.8.4
92+
BASE_URL=https://data.aussda.at
93+
```
94+
95+
or define it in the shell.
96+
97+
Example:
98+
```shell
99+
export API_TOKEN=<SECRET>
100+
export DATAVERSE_VERSION=4.8.4
101+
export BASE_URL=https://data.aussda.at
102+
```
103+
104+
To run through all tests (e. g. different python versions, packaging, docs, flake8, etc.), simply call tox from the root directory:
105+
```shell
106+
tox
68107
```
69-
pytest
108+
109+
When you only want to run the py36 test:
110+
```shell
111+
tox -e py36
70112
```
71113

72114
### Documentation

setup.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
import codecs
55
import os
66
import re
7+
from setuptools.command.test import test as TestCommand
78
from setuptools import find_packages
89
from setuptools import setup
10+
import sys
911

1012
ROOT_DIR = os.path.abspath(os.path.dirname(__file__))
1113
os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))
@@ -28,7 +30,24 @@ def find_version(*file_paths):
2830
if version_match:
2931
return version_match.group(1)
3032

31-
raise RuntimeError("Unable to find version string.")
33+
raise RuntimeError('Unable to find version string.')
34+
35+
36+
class Tox(TestCommand):
37+
"""Tox class."""
38+
39+
def finalize_options(self):
40+
"""Finalize options."""
41+
TestCommand.finalize_options(self)
42+
self.test_args = []
43+
self.test_suite = True
44+
45+
def run_tests(self):
46+
"""Run tests."""
47+
# import here, cause outside the eggs aren't loaded
48+
import tox
49+
errcode = tox.cmdline(self.test_args)
50+
sys.exit(errcode)
3251

3352

3453
INSTALL_REQUIREMENTS = [
@@ -37,6 +56,7 @@ def find_version(*file_paths):
3756
]
3857

3958
TESTS_REQUIREMENTS = [
59+
'tox'
4060
]
4161

4262
CLASSIFIERS = [
@@ -62,7 +82,7 @@ def find_version(*file_paths):
6282
author='Stefan Kasberger',
6383
author_email='stefan.kasberger@univie.ac.at',
6484
name='pyDataverse',
65-
version=find_version("src", "pyDataverse", "__init__.py"),
85+
version=find_version('src', 'pyDataverse', '__init__.py'),
6686
description='A Dataverse API wrapper',
6787
long_description=read_file('README.md'),
6888
long_description_content_type="text/markdown",
@@ -76,6 +96,7 @@ def find_version(*file_paths):
7696
package_dir={'': 'src'},
7797
setup_requires=['pytest-runner'],
7898
tests_require=TESTS_REQUIREMENTS,
99+
cmdclass={'test': Tox},
79100
include_package_data=True,
80101
keywords=['pydataverse', 'dataverse', 'api'],
81102
zip_safe=False,

tests/test_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
if 'BASE_URL' in os.environ:
2424
BASE_URL = os.environ['BASE_URL']
2525
else:
26-
print('ERROR: Environment variable BASE_URL for test missing.')
26+
print('ERROR: Environment variable BASE_URL for test missing.')
2727

2828

2929
class TestApiConnect(object):

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = flake8,coverage,packaging,docs,py36
2+
envlist = py36,coverage,packaging,docs,flake8
33
skip_missing_interpreters = True
44
ignore_basepython_conflict = True
55

0 commit comments

Comments
 (0)