diff --git a/examples/integration_test/it.py b/examples/integration_test/it.py
index 6f159e02d8209c11cd1d096555e032c183cb7630..778faef72b93af1d6d7ec784dd7f037415b7b85f 100644
--- a/examples/integration_test/it.py
+++ b/examples/integration_test/it.py
@@ -56,9 +56,9 @@ except ImportError:
print()
sys.exit(-1)
-##
-## Test Case helper functions for results storage and progress updates.
-##
+#
+# Test Case helper functions for results storage and progress updates.
+#
# helper class for storing test case details
@@ -108,10 +108,10 @@ class TestCaseError(Exception):
pass
-##
-## Sequential test cases, we cannot reuse the unit test framework because we must guarantee
-## execution order and state at each step and abort with appropriate cleanup.
-##
+#
+# Sequential test cases, we cannot reuse the unit test framework because we must guarantee
+# execution order and state at each step and abort with appropriate cleanup.
+#
# pylint: disable=too-many-branches, too-many-statements, too-many-locals, redefined-outer-name
# pylint: disable=broad-except, bare-except, no-member, protected-access
def run(oidc_username, storage_username):
@@ -126,9 +126,9 @@ def run(oidc_username, storage_username):
# the simulation we will launch, defined here so we have a cleanup reference at any point
sim = None
path = os.path.dirname(os.path.abspath(__file__))
- ##
- ## Server Information and Experiment List Interaction
- ##
+ #
+ # Server Information and Experiment List Interaction
+ #
# this test validates the config.json from user-scripts and checks to make sure the
# backend is running properly (roscore/OIDC if required)
@@ -162,9 +162,9 @@ def run(oidc_username, storage_username):
raise TestCaseError('Template Husky Experiment was not cloned to the storage.')
results.done(True)
- ##
- ## Clone a Cloned Experiment
- ##
+ #
+ # Clone a Cloned Experiment
+ #
results.start('Cloning a cloned experiment')
new_experiment_id = json.loads(vc.clone_cloned_experiment(experiment_id))['clonedExp']
@@ -172,9 +172,9 @@ def run(oidc_username, storage_username):
raise TestCaseError('Cloning the cloned Template Husky Experiment failed')
results.done(True)
- ##
- ## Delete a Cloned Experiment
- ##
+ #
+ # Delete a Cloned Experiment
+ #
results.start('Deleting a cloned experiment')
vc.delete_cloned_experiment(new_experiment_id)
@@ -182,9 +182,9 @@ def run(oidc_username, storage_username):
raise TestCaseError('Deleting a cloned Experiment failed')
results.done(True)
- ##
- ## Import an Experiment Folder
- ##
+ #
+ # Import an Experiment Folder
+ #
results.start('Importing an experiment folder')
response = vc.import_experiment(path + '/test_experiment_folder')
@@ -194,9 +194,9 @@ def run(oidc_username, storage_username):
vc.delete_cloned_experiment(new_experiment_id)
results.done(True)
- ##
- ## Import an Experiment Zipped Folder
- ##
+ #
+ # Import an Experiment Zipped Folder
+ #
results.start('Importing a zipped experiment folder')
response = vc.import_experiment(path + '/test_experiment_folder.zip')
@@ -206,9 +206,9 @@ def run(oidc_username, storage_username):
vc.delete_cloned_experiment(new_experiment_id)
results.done(True)
- ##
- ## Experiment Launch and Simulation State Interaction
- ##
+ #
+ # Experiment Launch and Simulation State Interaction
+ #
# launch an experiment
results.start('Launching Empty Template Husky Experiment')
@@ -266,9 +266,9 @@ def run(oidc_username, storage_username):
sim.start()
wait_condition(5, 'Waiting for simulation to resume.', lambda x: x['state'] == 'started')
results.done(True)
- ##
- ## Transfer Function Interaction
- ##
+ #
+ # Transfer Function Interaction
+ #
# retrieve transfer functions
results.start('Retrieving Transfer Functions')
@@ -354,9 +354,9 @@ def tf(t):
if tfs != sim._Simulation__get_simulation_scripts('transfer-function')['data']:
raise TestCaseError('Deleting a nonexistent TF deleted something else.')
results.done(True)
- ##
- ## State Machine Interaction
- ##
+ #
+ # State Machine Interaction
+ #
# add a new valid state machine
results.start('Adding a new valid State Machine')
@@ -367,7 +367,7 @@ def tf(t):
if len(sim._Simulation__get_simulation_scripts('state-machine')['data']) != len(sms) + 1:
raise TestCaseError('Failed to add a new valid state machine')
results.done(True)
- # valid state machine editing
+ # valid state machine editing
results.start('Valid State Machine Update')
sim.start()
valid_sm = 'import math\n' + sim.get_state_machine('statemachine_valid')
@@ -379,9 +379,9 @@ def tf(t):
raise TestCaseError('Valid State Machine update did not resume running simulation.')
results.done(True)
- ##
- ## Brain and Population Interaction
- ##
+ #
+ # Brain and Population Interaction
+ #
# modify brain script
results.start('Modifying Brain Script')
@@ -422,9 +422,9 @@ def tf(t):
results.done(True)
- ##
- ## Reset Different Simulation Parts
- ##
+ #
+ # Reset Different Simulation Parts
+ #
results.start('Resetting full simulation')
sim.reset('full')
wait_condition(5, 'Waiting for simulation to pause.', lambda x: x['state'] == 'paused')
@@ -442,9 +442,9 @@ def tf(t):
wait_condition(5, 'Waiting for simulation to pause.', lambda x: x['state'] == 'paused')
sim.start()
results.done(True)
- ##
- ## Shutdown, Cleanup and Delete the cloned experiment used in the tests
- ##
+ #
+ # Shutdown, Cleanup and Delete the cloned experiment used in the tests
+ #
# shutdown the experiment cleanly
results.start('Stopping Simulation')
@@ -476,7 +476,7 @@ def tf(t):
if sim:
try:
sim.stop()
- except:
+ except Exception:
pass
# make sure this file is properly updated for number of test cases, if not fail the dev
@@ -488,10 +488,10 @@ def tf(t):
return results
-##
-## Actual entry point, parse user options and print out results. Return a valid success (0) or
-## failure (-1) exit code upon exit for any automated checking.
-##
+#
+# Actual entry point, parse user options and print out results. Return a valid success (0) or
+# failure (-1) exit code upon exit for any automated checking.
+#
if __name__ == '__main__':
# allow the user to run IT using an OIDC enabled local backend (None if omitted)
diff --git a/hbp_nrp_virtual_coach/hbp_nrp_virtual_coach/tests/test_simulation.py b/hbp_nrp_virtual_coach/hbp_nrp_virtual_coach/tests/test_simulation.py
index e4747101fe511194939d29e1bb763af04f1c0aee..613a71eba766318b405b5b476a352322ae293785 100644
--- a/hbp_nrp_virtual_coach/hbp_nrp_virtual_coach/tests/test_simulation.py
+++ b/hbp_nrp_virtual_coach/hbp_nrp_virtual_coach/tests/test_simulation.py
@@ -404,7 +404,7 @@ class TestSimulation(unittest.TestCase):
def test_get_brain_and_populations(self):
self._sim._Simulation__get_simulation_scripts = Mock()
self._sim._Simulation__get_simulation_scripts.return_value = {'data': 'foo',
- 'brain_populations': 'bar'}
+ 'brain_populations': 'bar'}
self._sim.get_populations()
self._sim._Simulation__get_simulation_scripts.assert_called_once()
self._sim._Simulation__get_simulation_scripts.assert_called_with('brain')
@@ -419,9 +419,8 @@ class TestSimulation(unittest.TestCase):
# mock the http call, the get_all_transfer_function call, the start call, the pause call
# and the get_state call
- self._sim._Simulation__http_client.get = Mock(return_value=(http.client.OK,
- '{"data": {"foo": ""}}'))
- self._sim._Simulation__http_client.put = Mock(return_value=(http.client.OK,None))
+ self._sim._Simulation__http_client.get = Mock(return_value=(http.client.OK, '{"data": {"foo": ""}}'))
+ self._sim._Simulation__http_client.put = Mock(return_value=(http.client.OK, None))
self._sim._Simulation__get_all_transfer_functions = Mock()
self._sim._Simulation__get_all_transfer_functions.return_value = {'foo': ''}
diff --git a/hbp_nrp_virtual_coach/hbp_nrp_virtual_coach/virtual_coach.py b/hbp_nrp_virtual_coach/hbp_nrp_virtual_coach/virtual_coach.py
index 49521ea53dfb3057fd77bf9a2b80e0a1815a73df..9f57c9beea1262926595067be12ad6db031cf309 100644
--- a/hbp_nrp_virtual_coach/hbp_nrp_virtual_coach/virtual_coach.py
+++ b/hbp_nrp_virtual_coach/hbp_nrp_virtual_coach/virtual_coach.py
@@ -145,7 +145,7 @@ class VirtualCoach(object):
elif storage_username:
# this will interactively prompt the user for a password in terminal
logger.warning('No OIDC username supplied, simulation services will fail if OIDC is '
- 'enabled in this environment (%s).', environment)
+ 'enabled in this environment (%s).', environment)
logger.info('Logging into the Storage Server as: %s', storage_username)
if not storage_password:
storage_password = getpass.getpass()
@@ -413,13 +413,15 @@ class VirtualCoach(object):
assert isinstance(user_name, string_types)
assert isinstance(password, string_types)
- response = requests.post(self.__config['proxy-services']['storage-authentication'],
- json={'user': user_name, 'password': password})
- if response.status_code != 200:
+ resp = requests.post(self.__config['proxy-services']['storage-authentication'],
+ json={'user': user_name, 'password': password})
+
+ if resp.status_code != 200:
raise Exception('Storage Server authentication failed, Status Code: %d'
- % response.status_code)
+ % resp.status_code)
+
+ token = resp.content.decode("utf-8") if isinstance(resp.content, bytes) else resp.content
- token = response.content.decode("utf-8") if type(response.content) == bytes else response.content
return token
def __get_experiment_list(self, cloned=False):
diff --git a/verify.sh b/verify.sh
index d09f05fbf3a3dffbca2d1575d60a765cb56be088..1fe5177068e51bdb935e08c6534939ad11a17281 100755
--- a/verify.sh
+++ b/verify.sh
@@ -6,11 +6,11 @@ export IGNORE_LINT="platform_venv|config_files|examples/integration_test/test_ex
export VIRTUAL_ENV=$NRP_VIRTUAL_ENV
# This script only runs static code analysis, the tests can be run separately using run_tests.sh
-make run_pep8 run_pylint
+make run_pycodestyle run_pylint
RET=$?
if [ $RET == 0 ]; then
- echo -e "\033[32mVerify sucessfull.\e[0m Run ./run_tests.sh to run the tests."
+ echo -e "\033[32mVerify successful.\e[0m Run ./run_tests.sh to run the tests."
else
echo -e "\033[31mVerify failed.\e[0m"
fi