Skip to content

Commit

Permalink
added pbbt, prospector, tests/
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Wexler" committed Dec 10, 2015
1 parent a1c5376 commit 4daacc5
Show file tree
Hide file tree
Showing 19 changed files with 2,068 additions and 34 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions pbbt-input.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# Copyright (c) 2015, Prometheus Research, LLC
#

title: RIOS.CONVERTER
tests:
# check Python source syntax and style
- sh: flake8 ./src/

- sh: pip install --quiet coverage nose
ignore: true

- rmdir: ./tests/sandbox
- mkdir: ./tests/sandbox

- sh: nosetests --quiet
ignore: true
20 changes: 20 additions & 0 deletions pbbt-output.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# This file contains expected test output data generated by PBBT.
#
---
suite: rios.converter
tests:
- sh: flake8 ./src/
stdout: ''
- sh: pip install --quiet coverage nose
stdout: ''
- sh: nosetests --quiet
stdout: |
Coverage.py warning: Module rios.converter was never imported.
Name Stmts Miss Cover Missing
-------------------------------------
nose.plugins.cover: WARNING: Failed to generate HTML report: No data to report.
----------------------------------------------------------------------
Ran 0 tests in 0.005s
OK
42 changes: 29 additions & 13 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,20 +1,36 @@
# coverage.py configuration
[run]
source = rios.converter
branch = True
data_file = ./build/coverage/coverage.dat
parallel = True
[report]
exclude_lines =
raise NotImplementedError
return "REQUIRED"
# setuptools configuration
[bdist_wheel]
universal=1

# Prospector configuration
[prospector]
output_format = grouped
profile = .prospector.yaml
messages_only = true
autodetect = false

# Nose configuration
[nosy]
base_path = ./
glob_patterns = *.py *.json
[nosetests]
with-coverage=1
cover-package=rios.converter
cover-erase=1
cover-branches=1
cover-html=1
cover-html-dir=build/coverage
nocapture=1

# PBBT configuration
#[pbbt]
#input = test/input.yaml
#output = test/output.yaml
[pbbt]
input = pbbt-input.yaml
output = pbbt-output.yaml
max_errors = 1

# Sphinx configuration
[build_sphinx]
build_dir = build/doc

[flake8]
ignore = E123,E126,E127,E202,E241,E402,W503
18 changes: 16 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,22 @@
'rex.web >=3.5, <4',
'rios.conversion >=0.2, <1',
],
extras_require={
'dev': [
'pbbt>=0.1.4,<1',
'coverage>=3.7,<4',
'nose>=1.3,<2',
'nosy>=1.1,<2',
'prospector[with_pyroma]>=0.10,<0.11',
'twine>=1.5,<2',
'wheel>=0.24,<0.25',
'Sphinx>=1.3,<2',
'sphinx-autobuild>=0.5,<0.6',
'tox>=2,<3',
'flake8>=2.5.0,<3',
],
},
test_suite='nose.collector',
rex_init='rios.converter',
rex_static='static',
)


2 changes: 0 additions & 2 deletions src/rios/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@


__import__('pkg_resources').declare_namespace(__name__)


36 changes: 19 additions & 17 deletions src/rios/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from rex.core import get_settings
from rex.core import AnyVal
from rex.core import StrVal
from rex.core import PIntVal
from rex.core import Setting
from rex.web import Command
from rex.web import HandleError
Expand Down Expand Up @@ -72,8 +71,9 @@ class ConvertToRios(Command):
'redcap': RedcapToRios,
}


def render(self, req,
def render(
self,
req,
system,
format,
instrument_title,
Expand Down Expand Up @@ -102,7 +102,7 @@ def render(self, req,
if not instrument_id:
errors.append('Instrument ID is required.')
if not instrument_title:
errors.append('Instrument Title is required.')
errors.append('Instrument Title is required.')
args.extend([
'--id', instrument_id,
'--title', instrument_title, ])
Expand All @@ -119,7 +119,7 @@ def render(self, req,
return Response(json={
"status": 400,
"errors": errors
})
})
with open(error_filename, 'wb') as stderr:
sys.stdin = infile.file
# I can't explain why I am
Expand Down Expand Up @@ -150,7 +150,7 @@ def render(self, req,
name = outname + '.zip'
shutil.rmtree(temp_dir)
return Response(
content_type='application/zip',
content_type='application/zip',
content_disposition='attachment; filename="%s"' % name,
body=body)
else:
Expand Down Expand Up @@ -187,15 +187,17 @@ def load_file(self, file_field):
fo.write(file_field.file.read())
return filename

def render(self, req,
def render(
self,
req,
system,
format,
localization,
instrument_file,
form_file,
calculationset_file,
outname):

self.settings = get_settings()
tempfile.tempdir = self.settings.temp_dir
self.temp_dir = tempfile.mkdtemp()
Expand All @@ -208,23 +210,23 @@ def render(self, req,
args = [
'--verbose',
'--format', format,
'--outfile', outfile,
'--outfile', outfile,
]
if hasattr(instrument_file, 'filename'):
args.extend([
'--instrument',
'%s' % self.load_file(instrument_file)])
'--instrument',
'%s' % self.load_file(instrument_file)])
else:
errors.append('An input instrument file is required.')
if hasattr(form_file, 'filename'):
args.extend([
'--form',
'--form',
'%s' % self.load_file(form_file)])
else:
errors.append('An input form file is required.')
if hasattr(calculationset_file, 'filename'):
args.extend([
'--calculationset',
'--calculationset',
'%s' % self.load_file(calculationset_file)])
if localization:
args.extend(['--localization', localization])
Expand All @@ -233,7 +235,7 @@ def render(self, req,
return Response(json={
"status": 400,
"errors": errors
})
})
error_filename = outfile + '.stderr'
with open(error_filename, 'wb') as stderr:
# I can't eplain why I am
Expand Down Expand Up @@ -261,7 +263,7 @@ def render(self, req,
name = outname + '.zip'
shutil.rmtree(self.temp_dir)
return Response(
content_type='application/zip',
content_type='application/zip',
content_disposition='attachment; filename="%s"' % name,
body=body)
else:
Expand All @@ -281,8 +283,8 @@ class HandleNotFound(HandleError):

def __call__(self, req):
return render_to_response(
self.template,
req,
self.template,
req,
status=self.code,
path=req.path)

Expand Down
2 changes: 2 additions & 0 deletions src/rios/settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from rex.core import Setting
from rex.core import StrVal


class TempDirSetting(Setting):
"""Directory with temporary data."""
Expand Down
Loading

0 comments on commit 4daacc5

Please sign in to comment.