Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
teleyinex committed Feb 21, 2018
1 parent 77fe217 commit b7c7f46
Showing 1 changed file with 44 additions and 12 deletions.
56 changes: 44 additions & 12 deletions test/test_pbs_add_helping_materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ class TestPbsAddHelpingMaterial(TestDefault):
"""Test class for pbs add helping materials commands."""

@patch('helpers.find_project_by_short_name')
def test_add_helping_materials_json_with_info(self, find_mock):
@patch('helpers.enable_auto_throttling')
def test_add_helping_materials_json_with_info(self, auto_mock, find_mock):
"""Test add_helpingmaterials json with info field works."""
auto_mock.return_value = (0, None)
project = MagicMock()
project.name = 'name'
project.short_name = 'short_name'
Expand All @@ -32,8 +34,10 @@ def test_add_helping_materials_json_with_info(self, find_mock):
assert res == '1 helping materials added to project: short_name', res

@patch('helpers.find_project_by_short_name')
def test_add_helping_materials_json_from_filextension(self, find_mock):
@patch('helpers.enable_auto_throttling')
def test_add_helping_materials_json_from_filextension(self, auto_mock, find_mock):
"""Test add_helpingmaterials json without specifying file extension works."""
auto_mock.return_value = (0, None)
project = MagicMock()
project.name = 'name'
project.short_name = 'short_name'
Expand All @@ -53,8 +57,10 @@ def test_add_helping_materials_json_from_filextension(self, find_mock):
assert res == '1 helping materials added to project: short_name', res

@patch('helpers.find_project_by_short_name')
def test_add_helping_materials_csv_with_info(self, find_mock):
@patch('helpers.enable_auto_throttling')
def test_add_helping_materials_csv_with_info(self, auto_mock, find_mock):
"""Test add_helpingmaterials csv with info field works."""
auto_mock.return_value = (0, None)
project = MagicMock()
project.name = 'name'
project.short_name = 'short_name'
Expand All @@ -74,8 +80,10 @@ def test_add_helping_materials_csv_with_info(self, find_mock):

@patch('helpers.openpyxl.load_workbook')
@patch('helpers.find_project_by_short_name')
def test_add_helping_materials_excel_with_info(self, find_mock, workbook_mock):
@patch('helpers.enable_auto_throttling')
def test_add_helping_materials_excel_with_info(self, auto_mock, find_mock, workbook_mock):
"""Test add_helpingmaterials excel with info field works."""
auto_mock.return_value = (0, None)
project = MagicMock()
project.name = 'name'
project.short_name = 'short_name'
Expand Down Expand Up @@ -135,8 +143,11 @@ def test_add_helping_materials_csv_from_filextension(self, auto_mock,
assert res == '1 helping materials added to project: short_name', res

@patch('helpers.find_project_by_short_name')
def test_add_helping_materials_json_without_info(self, find_mock):
@patch('helpers.enable_auto_throttling')
def test_add_helping_materials_json_without_info(self, auto_mock, find_mock):
"""Test add_heping_materials json without info field works."""
auto_mock.return_value = (0, None)

project = MagicMock()
project.name = 'name'
project.short_name = 'short_name'
Expand All @@ -155,8 +166,11 @@ def test_add_helping_materials_json_without_info(self, find_mock):
assert res == '1 helping materials added to project: short_name', res

@patch('helpers.find_project_by_short_name')
def test_add_helping_materials_csv_without_info(self, find_mock):
@patch('helpers.enable_auto_throttling')
def test_add_helping_materials_csv_without_info(self, auto_mock, find_mock):
"""Test add_helpingmaterials csv without info field works."""
auto_mock.return_value = (0, None)

project = MagicMock()
project.name = 'name'
project.short_name = 'short_name'
Expand All @@ -175,8 +189,12 @@ def test_add_helping_materials_csv_without_info(self, find_mock):
assert res == '1 helping materials added to project: short_name', res

@patch('helpers.find_project_by_short_name')
def test_add_helping_materials_unknow_type_from_filextension(self, find_mock):
@patch('helpers.enable_auto_throttling')
def test_add_helping_materials_unknow_type_from_filextension(self,
auto_mock,
find_mock):
"""Test add_helpingmaterials with unknown type from file extension works."""
auto_mock.return_value = (0, None)
project = MagicMock()
project.name = 'name'
project.short_name = 'short_name'
Expand All @@ -197,8 +215,11 @@ def test_add_helping_materials_unknow_type_from_filextension(self, find_mock):
"properties."), res

@patch('helpers.find_project_by_short_name')
def test_add_helping_materials_unknow_type(self, find_mock):
@patch('helpers.enable_auto_throttling')
def test_add_helping_materials_unknow_type(self, auto_mock, find_mock):
"""Test add_helpingmaterials with unknown type works."""
auto_mock.return_value = (0, None)

project = MagicMock()
project.name = 'name'
project.short_name = 'short_name'
Expand All @@ -218,8 +239,11 @@ def test_add_helping_materials_unknow_type(self, find_mock):
"properties."), res

@patch('helpers.find_project_by_short_name')
def test_add_helping_materials_csv_connection_error(self, find_mock):
@patch('helpers.enable_auto_throttling')
def test_add_helping_materials_csv_connection_error(self, auto_mock, find_mock):
"""Test add_helpingmaterials csv connection error works."""
auto_mock.return_value = (0, None)

project = MagicMock()
project.name = 'name'
project.short_name = 'short_name'
Expand All @@ -238,8 +262,11 @@ def test_add_helping_materials_csv_connection_error(self, find_mock):
assert res == "Connection Error! The server http://server is not responding", res

@patch('helpers.find_project_by_short_name')
def test_add_helping_material_json_connection_error(self, find_mock):
@patch('helpers.enable_auto_throttling')
def test_add_helping_material_json_connection_error(self, auto_mock, find_mock):
"""Test add_helpingmaterials json connection error works."""
auto_mock.return_value = (0, None)

project = MagicMock()
project.name = 'name'
project.short_name = 'short_name'
Expand All @@ -258,8 +285,10 @@ def test_add_helping_material_json_connection_error(self, find_mock):
assert res == "Connection Error! The server http://server is not responding", res

@patch('helpers.find_project_by_short_name')
def test_add_helpingmaterial_another_error(self, find_mock):
@patch('helpers.enable_auto_throttling')
def test_add_helpingmaterial_another_error(self, auto_mock, find_mock):
"""Test add_tasks another error works."""
auto_mock.return_value = (0, None)
project = MagicMock()
project.name = 'name'
project.short_name = 'short_name'
Expand Down Expand Up @@ -296,8 +325,11 @@ def test_create_helping_material_info(self):

@patch('helpers.openpyxl.load_workbook')
@patch('helpers.find_project_by_short_name')
def test_add_helping_materials_excel_with_file(self, find_mock, workbook_mock):
@patch('helpers.enable_auto_throttling')
def test_add_helping_materials_excel_with_file(self, auto_mock, find_mock, workbook_mock):
"""Test add_helpingmaterials excel with file_path field works."""
auto_mock.return_value = (0, None)

project = MagicMock()
project.name = 'name'
project.short_name = 'short_name'
Expand Down

0 comments on commit b7c7f46

Please sign in to comment.