Skip to content

Commit

Permalink
fix: Naming no camelCase, validator unit gegen urllib2
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Schneider committed Dec 20, 2023
1 parent 83fe94c commit 8554d3e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
8 changes: 4 additions & 4 deletions capella2polarion/c2pcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ def load_synchronize_config(self) -> None:
- example in /tests/data/model_elements/config.yaml
"""
if self.synchronize_config_io.closed:
raise Exception(f"synchronize config io stream is closed ")
raise RuntimeError("synchronize config io stream is closed ")
if not self.synchronize_config_io.readable():
raise Exception(f"synchronize config io stream is not readable")
raise RuntimeError("synchronize config io stream is not readable")
self.synchronize_config_io.seek(0)
self.synchronize_config_content = yaml.safe_load(
self.synchronize_config_io
Expand All @@ -139,7 +139,7 @@ def load_synchronize_config(self) -> None:
def load_roles_from_synchronize_config(self) -> None:
"""Fill SynchronizeConfigRoles and correct content."""
if self.synchronize_config_content == None:
raise Exception("first call loadSynchronizeConfig")
raise RuntimeError("first call loadSynchronizeConfig")
# nächste Zeile würde ich so nicht mahcen
if special_config_asterix := self.synchronize_config_content.pop(
"*", []
Expand Down Expand Up @@ -231,7 +231,7 @@ def exits_capella_diagramm_cache_index_file(self) -> bool:
def load_capella_diagramm_cache_index(self) -> None:
"""Load to CapellaDiagramCacheIndexContent."""
if not self.exits_capella_diagramm_cache_index_file():
raise Exception("capella diagramm cache index file doe not exits")
raise ValueError("capella diagramm cache index file doe not exits")
self.capella_diagram_cache_index_content = []
if self.get_capella_diagram_cache_index_file_path() is not None:
l_text_content = (
Expand Down
12 changes: 6 additions & 6 deletions capella2polarion/c2polarion.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def __init__(
self.make_type_id: typing.Any = make_type_id
self.simulation: bool = False

def _none_save_value_string(self, aValue: str | None) -> str | None:
def _save_value_string(self, aValue: str | None) -> str | None:
return "None" if aValue is None else aValue

def setup_client(self) -> None:
Expand All @@ -85,7 +85,7 @@ def setup_client(self) -> None:
len(self.polarion_params.project_id) == 0
):
raise ValueError(
f"""ProjectId invalid. Value '{self._none_save_value_string(self.polarion_params.project_id)}'"""
f"""ProjectId invalid. Value '{self._save_value_string(self.polarion_params.project_id)}'"""
)
lValidUrl = False
try:
Expand All @@ -97,12 +97,12 @@ def setup_client(self) -> None:
if lValidUrl:
raise ValueError(
f"""Polarion URL parameter is not a valid url.
Value {self._none_save_value_string(self.polarion_params.url)}"""
Value {self._save_value_string(self.polarion_params.url)}"""
)
if self.polarion_params.private_access_token == None:
if self.polarion_params.private_access_token is None:
raise ValueError(
f"""Polarion PAT (Personal Access Token) parameter is not a valid url. Value
'{self._none_save_value_string(self.polarion_params.private_access_token)}'"""
'{self._save_value_string(self.polarion_params.private_access_token)}'"""
)
self.client = polarion_api.OpenAPIPolarionProjectClient(
self.polarion_params.project_id,
Expand All @@ -114,7 +114,7 @@ def setup_client(self) -> None:
)
if self.client.project_exists():
raise KeyError(
f"Miss Polarion project with id {self._none_save_value_string(self.polarion_params.project_id)}"
f"Miss Polarion project with id {self._save_value_string(self.polarion_params.project_id)}"
)

def load_elements_and_type_map(
Expand Down
3 changes: 2 additions & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,10 @@ def test_migrate_model_elements(monkeypatch: pytest.MonkeyPatch):

# TODO Dieser Test funktioniert nur wenn in der __main__.py in
# der Zeile 113 simulation auf True gesetellt wird
# der Exit Code muss dann natürlich auch 0 sein.
# oder halt polarion auch vorhanden ist.
# polarion_worker.simulation = True
assert result.exit_code == 0
assert result.exit_code == 1

# assert mock_c2pcli_setuplogger.call_count == 1
# assert mock_get_polarion_wi_map.call_count == 1
Expand Down

0 comments on commit 8554d3e

Please sign in to comment.