Created
July 23, 2021 19:28
-
-
Save LosantGists/3da0fb69664ab03e0b1967093fed8231 to your computer and use it in GitHub Desktop.
Automating Unit Tests Blog (11) 7.23.21
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import importlib | |
nb = importlib.import_module("ipynb.fs.defs.battery-stats") | |
is_row_before_charging = nb.is_row_before_charging | |
# it should return True if the change from the previous row is positive (isn't charging) | |
# and the change to the next row is negative (will be charging) | |
about_to_charge = pd.DataFrame({ | |
"battery_loss_this_row": [3], | |
"battery_loss_next_row": [-5] | |
}) | |
assert is_row_before_charging( about_to_charge.iloc[0] ) | |
# it should return False if the change from the previous row is negative (already charging) | |
charging = pd.DataFrame({ | |
"battery_loss_this_row": [-3], | |
"battery_loss_next_row": [-5] | |
}) | |
assert not is_row_before_charging( charging.iloc[0] ) | |
# it should return False if the change to the previous row is positive (will not be charging) | |
discharging = pd.DataFrame({ | |
"battery_loss_this_row": [3], | |
"battery_loss_next_row": [5] | |
}) | |
assert not is_row_before_charging( discharging.iloc[0] ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment