Skip to content

Commit

Permalink
Update tests to account for new colour arg for passing test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
sadielbartholomew committed Sep 30, 2024
1 parent 5eb5ac4 commit e648100
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion cats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ class CATSOutput:
carbonIntensityOptimal: CarbonIntensityAverageEstimate
location: str
countryISO3: str
colour: bool = False
emmissionEstimate: Optional[Estimates] = None
colour: bool = False

def __str__(self) -> str:
if self.colour:
Expand Down
22 changes: 10 additions & 12 deletions tests/test_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,19 @@
[
(
OUTPUT,
"""Best job start time 2024-03-16 02:00:00
"""
Best job start time = 2024-03-16 02:00:00
Carbon intensity if job started now = 50.00 gCO2eq/kWh
Carbon intensity at optimal time = 20.00 gCO2eq/kWh
Use --format=json to get this in machine readable format""",
Carbon intensity at optimal time = 20.00 gCO2eq/kWh""",
),
(
OUTPUT_WITH_EMISSION_ESTIMATE,
"""Best job start time 2024-03-16 02:00:00
"""
Best job start time = 2024-03-16 02:00:00
Carbon intensity if job started now = 50.00 gCO2eq/kWh
Carbon intensity at optimal time = 20.00 gCO2eq/kWh
Estimated emissions if job started now = 19
Estimated emissions at optimal time = 9 (- 10)
Use --format=json to get this in machine readable format""",
Estimated emissions at optimal time = 9 (- 10)""",
),
],
)
Expand All @@ -62,13 +60,13 @@ def test_string_repr(output, expected):
OUTPUT,
"""{"carbonIntensityNow": {"end": "2024-03-15T17:00:00", "start": "2024-03-15T16:00:00", "value": 50}, """
""""carbonIntensityOptimal": {"end": "2024-03-16T03:00:00", "start": "2024-03-16T02:00:00", "value": 20}, """
""""countryISO3": "GBR", "emmissionEstimate": null, "location": "OX1"}""",
""""colour": false, "countryISO3": "GBR", "emmissionEstimate": null, "location": "OX1"}""",
),
(
OUTPUT_WITH_EMISSION_ESTIMATE,
"""{"carbonIntensityNow": {"end": "2024-03-15T17:00:00", "start": "2024-03-15T16:00:00", "value": 50}, """
""""carbonIntensityOptimal": {"end": "2024-03-16T03:00:00", "start": "2024-03-16T02:00:00", "value": 20}, """
""""countryISO3": "GBR", "emmissionEstimate": [19, 9, 10], "location": "OX1"}""",
""""colour": false, "countryISO3": "GBR", "emmissionEstimate": [19, 9, 10], "location": "OX1"}""",
),
],
)
Expand All @@ -83,13 +81,13 @@ def test_output_json(output, expected):
OUTPUT,
"""{"carbonIntensityNow": {"end": "202403151700", "start": "202403151600", "value": 50}, """
""""carbonIntensityOptimal": {"end": "202403160300", "start": "202403160200", "value": 20}, """
""""countryISO3": "GBR", "emmissionEstimate": null, "location": "OX1"}""",
""""colour": false, "countryISO3": "GBR", "emmissionEstimate": null, "location": "OX1"}""",
),
(
OUTPUT_WITH_EMISSION_ESTIMATE,
"""{"carbonIntensityNow": {"end": "202403151700", "start": "202403151600", "value": 50}, """
""""carbonIntensityOptimal": {"end": "202403160300", "start": "202403160200", "value": 20}, """
""""countryISO3": "GBR", "emmissionEstimate": [19, 9, 10], "location": "OX1"}""",
""""colour": false, "countryISO3": "GBR", "emmissionEstimate": [19, 9, 10], "location": "OX1"}""",
),
],
)
Expand Down

0 comments on commit e648100

Please sign in to comment.