Skip to content

Commit

Permalink
Merge pull request #27 from ARKlab/feature/gmePO-extraction-fix
Browse files Browse the repository at this point in the history
Fix operators parameter and added missing markets to enum
  • Loading branch information
AndreaCuneo authored Jul 5, 2024
2 parents 4e43ac6 + 7980b55 commit 2739e28
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
18 changes: 10 additions & 8 deletions src/Artesian/GMEPublicOffers/GMEPublicOfferQuery.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -258,11 +258,11 @@ 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)
url = url + "&operator=" + enc
operators = sep.join(map(str, qp.operators))
enc = parse.quote_plus(operators)
url = url + "&operators=" + enc
if not (qp.zone is None):
sep = ","
zone = sep.join(map(lambda x: self.__getZone(x), qp.zone))
Expand Down Expand Up @@ -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":
Expand Down
8 changes: 4 additions & 4 deletions src/Artesian/GMEPublicOffers/GMEPublicOfferQueryParameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
Expand All @@ -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.
Expand All @@ -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
Expand Down
14 changes: 14 additions & 0 deletions tests/TestGMEPO.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down

0 comments on commit 2739e28

Please sign in to comment.