Skip to content

Commit

Permalink
Revert "update formatting"
Browse files Browse the repository at this point in the history
This reverts commit 5b4ec91.
  • Loading branch information
brg468 committed Dec 15, 2023
1 parent 5b4ec91 commit d4c7f4a
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 18 deletions.
22 changes: 16 additions & 6 deletions tests/test_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ def test_list_programs(self, mock):
args, kwargs = mock.call_args

# Check that the mock function is called with the rights args.
self.assertEqual(args[1], f"{VALVE_API_URL}/program/listPrograms/{valveid}")
self.assertEqual(
args[1], f"{VALVE_API_URL}/program/listPrograms/{valveid}"
)
self.assertEqual(args[0], "GET")
self.assertEqual(kwargs["data"], None)

Expand All @@ -47,7 +49,9 @@ def test_get_program(self, mock):
args, kwargs = mock.call_args

# Check that the mock function is called with the rights args.
self.assertEqual(args[1], f"{VALVE_API_URL}/program/getProgram/{programid}")
self.assertEqual(
args[1], f"{VALVE_API_URL}/program/getProgram/{programid}"
)
self.assertEqual(args[0], "GET")
self.assertEqual(kwargs["data"], None)

Expand All @@ -64,10 +68,13 @@ def test_create_skip_overrides(self, mock):
args, kwargs = mock.call_args

# Check that the mock function is called with the rights args.
self.assertEqual(args[1], f"{VALVE_API_URL}/program/createSkipOverrides")
self.assertEqual(
args[1], f"{VALVE_API_URL}/program/createSkipOverrides"
)
self.assertEqual(args[0], "POST")
self.assertEqual(
kwargs["data"], json.dumps({"programId": programid, "timestamp": timestamp})
kwargs["data"],
json.dumps({"programId": programid, "timestamp": timestamp})
)

@patch("requests.Session.request")
Expand All @@ -83,8 +90,11 @@ def test_delete_skip_overrides(self, mock):
args, kwargs = mock.call_args

# Check that the mock function is called with the rights args.
self.assertEqual(args[1], f"{VALVE_API_URL}/program/deleteSkipOverrides")
self.assertEqual(
args[1], f"{VALVE_API_URL}/program/deleteSkipOverrides"
)
self.assertEqual(args[0], "POST")
self.assertEqual(
kwargs["data"], json.dumps({"programId": programid, "timestamp": timestamp})
kwargs["data"],
json.dumps({"programId": programid, "timestamp": timestamp})
)
10 changes: 7 additions & 3 deletions tests/test_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ def test_get_valve_day_views(self, mock):
self.assertEqual(
kwargs["data"],
json.dumps(
{"resourceId": {"baseStationId": deviceid}, "start": start, "end": end}
),
)
{
"resourceId": {"baseStationId": deviceid},
"start": start,
"end": end
}
)
)
34 changes: 25 additions & 9 deletions tests/test_valve.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ def test_get_base_station(self, mock):
args, kwargs = mock.call_args

# Check that the mock function is called with the rights args.
self.assertEqual(args[1], f"{VALVE_API_URL}/valve/getBaseStation/{baseid}")
self.assertEqual(
args[1],
f"{VALVE_API_URL}/valve/getBaseStation/{baseid}"
)
self.assertEqual(args[0], "GET")
self.assertEqual(kwargs["data"], None)

Expand All @@ -64,7 +67,10 @@ def test_list_base_stations(self, mock):
args, kwargs = mock.call_args

# Check that the mock function is called with the rights args.
self.assertEqual(args[1], f"{VALVE_API_URL}/valve/listBaseStations/{userid}")
self.assertEqual(
args[1],
f"{VALVE_API_URL}/valve/listBaseStations/{userid}"
)
self.assertEqual(args[0], "GET")
self.assertEqual(kwargs["data"], None)

Expand Down Expand Up @@ -101,12 +107,16 @@ def test_set_default_runtime(self, mock):
self.assertEqual(args[0], "PUT")
self.assertEqual(
kwargs["data"],
json.dumps({"valveId": valveid, "defaultRuntimeSeconds": duration}),
json.dumps({"valveId": valveid, "defaultRuntimeSeconds": duration})
)

# Check that values should be within range.
self.assertRaises(AssertionError, self.valve.start_watering, valveid, -1)
self.assertRaises(AssertionError, self.valve.start_watering, valveid, 86401)
self.assertRaises(
AssertionError, self.valve.start_watering, valveid, -1
)
self.assertRaises(
AssertionError, self.valve.start_watering, valveid, 86401
)

@patch("requests.Session.request")
def test_start_watering(self, mock):
Expand All @@ -125,12 +135,16 @@ def test_start_watering(self, mock):
self.assertEqual(args[0], "PUT")
self.assertEqual(
kwargs["data"],
json.dumps({"valveId": valveid, "durationSeconds": duration}),
json.dumps({"valveId": valveid, "durationSeconds": duration})
)

# Check that values should be within range.
self.assertRaises(AssertionError, self.valve.start_watering, valveid, -1)
self.assertRaises(AssertionError, self.valve.start_watering, valveid, 86401)
self.assertRaises(
AssertionError, self.valve.start_watering, valveid, -1
)
self.assertRaises(
AssertionError, self.valve.start_watering, valveid, 86401
)

@patch("requests.Session.request")
def test_stop_watering(self, mock):
Expand All @@ -146,4 +160,6 @@ def test_stop_watering(self, mock):
# Check that the mock function is called with the rights args.
self.assertEqual(args[1], f"{VALVE_API_URL}/valve/stopWatering")
self.assertEqual(args[0], "PUT")
self.assertEqual(kwargs["data"], json.dumps({"valveId": valveid}))
self.assertEqual(
kwargs["data"], json.dumps({"valveId": valveid})
)

0 comments on commit d4c7f4a

Please sign in to comment.