From c751b6785cb01d78140920585a162836d1da73bd Mon Sep 17 00:00:00 2001 From: "mchele.nan" Date: Thu, 4 Jul 2024 17:37:11 +0200 Subject: [PATCH 1/2] Fix operato parameter and added missing markets to enum --- src/Artesian/GMEPublicOffers/GMEPublicOfferQuery.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Artesian/GMEPublicOffers/GMEPublicOfferQuery.py b/src/Artesian/GMEPublicOffers/GMEPublicOfferQuery.py index 1687756..efd0021 100644 --- a/src/Artesian/GMEPublicOffers/GMEPublicOfferQuery.py +++ b/src/Artesian/GMEPublicOffers/GMEPublicOfferQuery.py @@ -262,7 +262,7 @@ def __buildRequest(self: GMEPublicOfferQuery) -> str: sep = "," operator = sep.join(map(str, qp.operator)) enc = parse.quote_plus(operator) - url = url + "&operator=" + enc + url = url + "&operators=" + enc if not (qp.zone is None): sep = "," zone = sep.join(map(lambda x: self.__getZone(x), qp.zone)) @@ -342,6 +342,8 @@ def __getMarket(self: GMEPublicOfferQuery, market: Market) -> str: Market.MIA1: "MIA1", Market.MIA2: "MIA2", Market.MIA3: "MIA3", + Market.MRR: "MRR", + Market.AFRR: "AFRR", } vr = switcher.get(market, "DefMarket") if vr == "DefMarket": From 29d0f5862ca44b6d4f023ad07591e33d05c41019 Mon Sep 17 00:00:00 2001 From: "mchele.nan" Date: Fri, 5 Jul 2024 09:20:50 +0200 Subject: [PATCH 2/2] Fixed operators variable name and added test --- .../GMEPublicOffers/GMEPublicOfferQuery.py | 14 +++++++------- .../GMEPublicOfferQueryParameters.py | 8 ++++---- tests/TestGMEPO.py | 14 ++++++++++++++ 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/Artesian/GMEPublicOffers/GMEPublicOfferQuery.py b/src/Artesian/GMEPublicOffers/GMEPublicOfferQuery.py index efd0021..874195c 100644 --- a/src/Artesian/GMEPublicOffers/GMEPublicOfferQuery.py +++ b/src/Artesian/GMEPublicOffers/GMEPublicOfferQuery.py @@ -115,19 +115,19 @@ def forUnit(self: GMEPublicOfferQuery, unit: List[str]) -> GMEPublicOfferQuery: self._queryParameters.unit = unit return self - def forOperator( - self: GMEPublicOfferQuery, operator: List[str] + def forOperators( + self: GMEPublicOfferQuery, operators: List[str] ) -> GMEPublicOfferQuery: """ Set the operators to be queried. Args: - operator: string for the GME Public Offer operator to be queried. + operators: string for the GME Public Offer operators to be queried. Returns: GMEPublicOfferQuery. """ - self._queryParameters.operator = operator + self._queryParameters.operators = operators return self def forZone(self: GMEPublicOfferQuery, zone: List[Zone]) -> GMEPublicOfferQuery: @@ -258,10 +258,10 @@ def __buildRequest(self: GMEPublicOfferQuery) -> str: ) enc = parse.quote_plus(generationType) url = url + "&generationType=" + enc - if not (qp.operator is None): + if not (qp.operators is None): sep = "," - operator = sep.join(map(str, qp.operator)) - enc = parse.quote_plus(operator) + operators = sep.join(map(str, qp.operators)) + enc = parse.quote_plus(operators) url = url + "&operators=" + enc if not (qp.zone is None): sep = "," diff --git a/src/Artesian/GMEPublicOffers/GMEPublicOfferQueryParameters.py b/src/Artesian/GMEPublicOffers/GMEPublicOfferQueryParameters.py index 6aa3f0a..39b345b 100644 --- a/src/Artesian/GMEPublicOffers/GMEPublicOfferQueryParameters.py +++ b/src/Artesian/GMEPublicOffers/GMEPublicOfferQueryParameters.py @@ -20,7 +20,7 @@ class _GMEPublicOfferQueryParameters: status: sets the Status to be queried. unitType: sets the unit types to be queried. generationType: that sets the generation type to be queried. - operator: sets the operators to be queried. + operators: sets the operators to be queried. unit: sets the units to be queried. zone: sets the zones to be queried. market: sets the Market to be queried. @@ -39,7 +39,7 @@ def __init__( status: Optional[Status] = None, unitType: Optional[List[UnitType]] = None, generationType: Optional[List[GenerationType]] = None, - operator: Optional[List[str]] = None, + operators: Optional[List[str]] = None, unit: Optional[List[str]] = None, zone: Optional[List[Zone]] = None, market: Optional[List[Market]] = None, @@ -57,7 +57,7 @@ def __init__( status:An enum that sets the Status to be queried. unitType: An enum that sets the unit types to be queried. generationType: An enum that sets the generation type to be queried. - operator: A string that sets the operators to be queried. + operators: A string that sets the operators to be queried. unit: A string that sets the units to be queried. zone: An enum that sets the zones to be queried. market: An enum that sets the Market to be queried. @@ -72,7 +72,7 @@ def __init__( self.status = status self.unitType = unitType self.generationType = generationType - self.operator = operator + self.operators = operators self.unit = unit self.zone = zone self.market = market diff --git a/tests/TestGMEPO.py b/tests/TestGMEPO.py index 2aaf763..a58c507 100644 --- a/tests/TestGMEPO.py +++ b/tests/TestGMEPO.py @@ -88,6 +88,20 @@ def test_Zones(self, requests): query = requests.getQs() self.assertEqual(query["zone"], "NORD,SUD") + @helpers.TrackGMEPORequests + def test_Operator(self, requests): + url = ( + qs.createQuery() + .forDate("2020-04-01") + .forOperators(["Test"]) + .forStatus(Status.ACC) + .forPurpose(Purpose.BID) + .execute() + ) + + query = requests.getQs() + self.assertEqual(query["operators"], "Test") + @helpers.TrackGMEPORequests def test_Pagination(self, requests): url = (