Skip to content

Commit

Permalink
minor fixes before first release
Browse files Browse the repository at this point in the history
  • Loading branch information
skasberger committed May 15, 2019
1 parent 8df791e commit adc3374
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 12 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,19 @@ before_install:

install:
- pip install tox-travis
- pip install coverage
- pip install coveralls
- virtualenv --version
- easy_install --version
- pip --version
- tox --version


script:
- tox
- pytest tests/ --cov=pyDataverse --cov-report=term-missing --cov-report=xml --cov-report=html

after_success:
- pip install codecov
- coveralls

notifications:
Expand Down
56 changes: 49 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,19 @@ A Python module to work with the Dataverse API. It allows to create, update and

## INSTALL

```bash
**Requirements**

* curl

**Install**

```shell
virtualenv --python=/usr/bin/python3 venv
source venv/bin/activate
pip install -r requirements.txt
```

## USE
## QUICKSTART

**Connect to API**

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

```python
identifier = 'doi:10.5072/FK2/U6AEZM' # doi of the dataset
identifier = 'doi:10.5072/FK2/U6AEZM' # doi of the dataset
resp = api.get_dataset(identifier)
```

**Get datafile**

```python
file_id = '32' # file id of the datafile
resp = api.get_datafile(file_id)
resp.content
datafile_id = '32' # file id of the datafile
resp = api.get_datafile(datafile_id)
print(resp.content)
```

## DEVELOPMENT

### Install

```bash
virtualenv --python=/usr/bin/python3 venv
source venv/bin/activate
pip install -r requirements.txt
```

### Testing

[Tox](http://tox.readthedocs.io/) together with [pytest](https://docs.pytest.org/en/latest/) is used für testing.

First, you need to set the needed ENV variables. You can create a pytest.ini file with the ENV variables in it:

Example:
```ini
[pytest]
env =
API_TOKEN=<SECRET>
DATAVERSE_VERSION=4.8.4
BASE_URL=https://data.aussda.at
```

or define it in the shell.

Example:
```shell
export API_TOKEN=<SECRET>
export DATAVERSE_VERSION=4.8.4
export BASE_URL=https://data.aussda.at
```

To run through all tests (e. g. different python versions, packaging, docs, flake8, etc.), simply call tox from the root directory:
```shell
tox
```
pytest

When you only want to run the py36 test:
```shell
tox -e py36
```

### Documentation
Expand Down
25 changes: 23 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import codecs
import os
import re
from setuptools.command.test import test as TestCommand
from setuptools import find_packages
from setuptools import setup
import sys

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

raise RuntimeError("Unable to find version string.")
raise RuntimeError('Unable to find version string.')


class Tox(TestCommand):
"""Tox class."""

def finalize_options(self):
"""Finalize options."""
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True

def run_tests(self):
"""Run tests."""
# import here, cause outside the eggs aren't loaded
import tox
errcode = tox.cmdline(self.test_args)
sys.exit(errcode)


INSTALL_REQUIREMENTS = [
Expand All @@ -37,6 +56,7 @@ def find_version(*file_paths):
]

TESTS_REQUIREMENTS = [
'tox'
]

CLASSIFIERS = [
Expand All @@ -62,7 +82,7 @@ def find_version(*file_paths):
author='Stefan Kasberger',
author_email='[email protected]',
name='pyDataverse',
version=find_version("src", "pyDataverse", "__init__.py"),
version=find_version('src', 'pyDataverse', '__init__.py'),
description='A Dataverse API wrapper',
long_description=read_file('README.md'),
long_description_content_type="text/markdown",
Expand All @@ -76,6 +96,7 @@ def find_version(*file_paths):
package_dir={'': 'src'},
setup_requires=['pytest-runner'],
tests_require=TESTS_REQUIREMENTS,
cmdclass={'test': Tox},
include_package_data=True,
keywords=['pydataverse', 'dataverse', 'api'],
zip_safe=False,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
if 'BASE_URL' in os.environ:
BASE_URL = os.environ['BASE_URL']
else:
print('ERROR: Environment variable BASE_URL for test missing.')
print('ERROR: Environment variable BASE_URL for test missing.')


class TestApiConnect(object):
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = flake8,coverage,packaging,docs,py36
envlist = py36,coverage,packaging,docs,flake8
skip_missing_interpreters = True
ignore_basepython_conflict = True

Expand Down

0 comments on commit adc3374

Please sign in to comment.