def test__get_ocp_credentials_missing_cluster_id(self): """Test to get ocp cluster-id with missing cluster-id raises exception.""" client = SourcesHTTPClient(auth_header=Config.SOURCES_FAKE_HEADER, source_id=self.source_id) with requests_mock.mock() as m: m.get( f"{MOCK_URL}/api/v1.0/{ENDPOINT_SOURCES}/{self.source_id}", status_code=200, json={"source_ref": None} ) with self.assertRaises(SourcesHTTPClientError): client._get_ocp_credentials()
def test__get_ocp_credentials(self): """Test to get ocp cluster-id.""" uuid = str(uuid4()) client = SourcesHTTPClient(auth_header=Config.SOURCES_FAKE_HEADER, source_id=self.source_id) with requests_mock.mock() as m: m.get( f"{MOCK_URL}/api/v1.0/{ENDPOINT_SOURCES}/{self.source_id}", status_code=200, json={"source_ref": uuid} ) creds = client._get_ocp_credentials() self.assertEqual(creds.get("cluster_id"), uuid)