Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
force-bdss
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Adham Hashibon
force-bdss
Commits
ed69faa5
Commit
ed69faa5
authored
7 years ago
by
Stefano Borini
Browse files
Options
Downloads
Patches
Plain Diff
Flake8
parent
dbf85720
No related branches found
No related tags found
1 merge request
!29
Extract io layer to writer/reader class
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
force_bdss/cli/tests/test_execution.py
+5
-3
5 additions, 3 deletions
force_bdss/cli/tests/test_execution.py
force_bdss/io/workflow_reader.py
+5
-4
5 additions, 4 deletions
force_bdss/io/workflow_reader.py
force_bdss/tests/fixtures/__init__.py
+5
-1
5 additions, 1 deletion
force_bdss/tests/fixtures/__init__.py
with
15 additions
and
8 deletions
force_bdss/cli/tests/test_execution.py
+
5
−
3
View file @
ed69faa5
...
@@ -3,6 +3,8 @@ import subprocess
...
@@ -3,6 +3,8 @@ import subprocess
import
os
import
os
from
contextlib
import
contextmanager
from
contextlib
import
contextmanager
from
force_bdss.tests
import
fixtures
@contextmanager
@contextmanager
def
cd
(
dir
):
def
cd
(
dir
):
...
@@ -22,17 +24,17 @@ def fixture_dir():
...
@@ -22,17 +24,17 @@ def fixture_dir():
class
TestExecution
(
unittest
.
TestCase
):
class
TestExecution
(
unittest
.
TestCase
):
def
test_plain_invocation_mco
(
self
):
def
test_plain_invocation_mco
(
self
):
with
cd
(
fixture
_
dir
()):
with
cd
(
fixture
s
.
dir
path
()):
out
=
subprocess
.
check_call
([
"
force_bdss
"
,
"
test_csv.json
"
])
out
=
subprocess
.
check_call
([
"
force_bdss
"
,
"
test_csv.json
"
])
self
.
assertEqual
(
out
,
0
)
self
.
assertEqual
(
out
,
0
)
def
test_unsupported_file_input
(
self
):
def
test_unsupported_file_input
(
self
):
with
cd
(
fixture
_
dir
()):
with
cd
(
fixture
s
.
dir
path
()):
with
self
.
assertRaises
(
subprocess
.
CalledProcessError
):
with
self
.
assertRaises
(
subprocess
.
CalledProcessError
):
subprocess
.
check_call
([
"
force_bdss
"
,
"
test_csv_v2.json
"
])
subprocess
.
check_call
([
"
force_bdss
"
,
"
test_csv_v2.json
"
])
def
test_corrupted_file_input
(
self
):
def
test_corrupted_file_input
(
self
):
with
cd
(
fixture
_
dir
()):
with
cd
(
fixture
s
.
dir
path
()):
with
self
.
assertRaises
(
subprocess
.
CalledProcessError
):
with
self
.
assertRaises
(
subprocess
.
CalledProcessError
):
subprocess
.
check_call
([
"
force_bdss
"
,
subprocess
.
check_call
([
"
force_bdss
"
,
"
test_csv_corrupted.json
"
])
"
test_csv_corrupted.json
"
])
...
...
This diff is collapsed.
Click to expand it.
force_bdss/io/workflow_reader.py
+
5
−
4
View file @
ed69faa5
...
@@ -47,14 +47,15 @@ class WorkflowReader(HasStrictTraits):
...
@@ -47,14 +47,15 @@ class WorkflowReader(HasStrictTraits):
wf
=
Workflow
()
wf
=
Workflow
()
try
:
try
:
w
orkflow
_data
=
json_data
[
"
workflow
"
]
w
f
_data
=
json_data
[
"
workflow
"
]
wf
.
multi_criteria_optimizer
=
self
.
_extract_mco
(
w
orkflow
_data
)
wf
.
multi_criteria_optimizer
=
self
.
_extract_mco
(
w
f
_data
)
wf
.
data_sources
[:]
=
self
.
_extract_data_sources
(
w
orkflow
_data
)
wf
.
data_sources
[:]
=
self
.
_extract_data_sources
(
w
f
_data
)
wf
.
kpi_calculators
[:]
=
self
.
_extract_kpi_calculators
(
w
orkflow
_data
)
wf
.
kpi_calculators
[:]
=
self
.
_extract_kpi_calculators
(
w
f
_data
)
except
KeyError
as
e
:
except
KeyError
as
e
:
logging
.
exception
(
"
Could not read file
"
)
logging
.
exception
(
"
Could not read file
"
)
raise
InvalidFileException
(
"
Could not read file.
"
raise
InvalidFileException
(
"
Could not read file.
"
"
Unable to find key {}
"
.
format
(
e
))
"
Unable to find key {}
"
.
format
(
e
))
return
wf
def
_extract_mco
(
self
,
json_data
):
def
_extract_mco
(
self
,
json_data
):
registry
=
self
.
bundle_registry
registry
=
self
.
bundle_registry
...
...
This diff is collapsed.
Click to expand it.
force_bdss/tests/fixtures/__init__.py
+
5
−
1
View file @
ed69faa5
...
@@ -2,4 +2,8 @@ from os.path import join, dirname, abspath
...
@@ -2,4 +2,8 @@ from os.path import join, dirname, abspath
def
get
(
filename
):
def
get
(
filename
):
return
join
(
dirname
(
abspath
(
__file__
)),
filename
)
return
join
(
dirpath
(),
filename
)
def
dirpath
():
return
dirname
(
abspath
(
__file__
))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment