Commit 7db667be authored by Ritika Kaushal's avatar Ritika Kaushal
Browse files

changes for flake8

parent a2c7d8f6
Pipeline #108245 failed with stages
in 2 minutes and 20 seconds
......@@ -18,15 +18,13 @@ class TestOsduClient:
_expected_ids_str = [{"id": "321"}, {"id": "432"}, {"id": "543"}]
_access_token = "token"
_data_partition_id = "AnId"
_serviceName= "wellbore"
_serviceName = "wellbore"
mockConfig = Mock(spec=Configuration)
mockConfig.data_partition_id= "AnId"
mockConfig.wellbore_service_path_prefix=None
mockConfig.search_service_path_prefix=None
mockConfig.data_partition_id = "AnId"
mockConfig.wellbore_service_path_prefix = None
mockConfig.search_service_path_prefix = None
mockConfig.base_url = "http://test.bp.com"
def match_and_mock_post(self, request: any):
if request.method != "POST":
return httpx.Response(500, text="Not a post request")
......@@ -81,10 +79,8 @@ class TestOsduClient:
base_url = "http://test.bp.com"
record = Record({"kind": "kind", "acl": {}, "legal": "legal", "data": {}})
respx_mock.post(f"{base_url}/api/os-wellbore-ddms/ddms/v3/wellbores").mock(side_effect=self.match_and_mock_post)
client = OsduClient(self.mockConfig, self._access_token)
# Act
......
......@@ -40,8 +40,8 @@ class OsduClient:
self._data_partition_id = config.data_partition_id
self._wellbore_service_path_prefix = config.wellbore_service_path_prefix
self._search_service_path_prefix = config.search_service_path_prefix
self._wellbore_service="wellbore"
self._search_service="search"
self._wellbore_service = "wellbore"
self._search_service = "search"
def _create_headers(self) -> Dict[str, str]:
"""
......@@ -63,7 +63,8 @@ class OsduClient:
:return: the id of the new well bore
:rtype: str
"""
return self._post_data_with_id_response(f'{self.get_base_url(self._wellbore_service)}/api/os-wellbore-ddms/ddms/v3/wellbores', record)
url = f'{self.get_base_url(self._wellbore_service)}/api/os-wellbore-ddms/ddms/v3/wellbores'
return self._post_data_with_id_response(url, record)
def post_welllog(self, record: Union[Record, WellLogRecord]) -> List[any]:
"""
......@@ -75,7 +76,8 @@ class OsduClient:
:return: The ID of the created/updated well log
:rtype: List[any]
"""
return self._post_data_with_id_response(f'{self.get_base_url(self._wellbore_service)}/api/os-wellbore-ddms/ddms/v3/welllogs', record)
url = f'{self.get_base_url(self._wellbore_service)}/api/os-wellbore-ddms/ddms/v3/welllogs'
return self._post_data_with_id_response(url, record)
def get_wellbore_record(self, wellbore_id: str) -> Record:
"""
......@@ -130,8 +132,9 @@ class OsduClient:
if curves is not None and len(curves) > 0:
curves_query = f"&curves={','.join(curves)}"
url = self.get_base_url(self._wellbore_service)
get_welllog_data_url = f'{self.get_base_url(self._wellbore_service)}/api/os-wellbore-ddms/ddms/v3/welllogs/{welllog_id}/data?describe=false{curves_query}'
get_welllog_data_url = f'{url}/api/os-wellbore-ddms/ddms/v3/welllogs/{welllog_id}/data?describe=false{curves_query}'
try:
res = self._send_request("GET", get_welllog_data_url, None, None)
......@@ -203,9 +206,12 @@ class OsduClient:
return res
def get_base_url( self,service_name: str) -> str:
if service_name == self._wellbore_service and self._wellbore_service_path_prefix is not None and len(self._wellbore_service_path_prefix) > 0:
return f"{self._base_url}/{self._wellbore_service_path_prefix}"
elif service_name == self._search_service and self._search_service_path_prefix is not None and len(self._search_service_path_prefix) > 0:
return f"{self._base_url}/{self._search_service_path_prefix}"
wellbore_path_prefix = self._wellbore_service_path_prefix
search_path_prefix = self._search_service_path_prefix
if service_name == self._wellbore_service and wellbore_path_prefix is not None and len(wellbore_path_prefix) > 0:
return f"{self._base_url}/{wellbore_path_prefix}"
elif service_name == self._search_service and search_path_prefix is not None and len(search_path_prefix) > 0:
return f"{self._base_url}/{search_path_prefix}"
else:
return self._base_url
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment