-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
92db5da
commit fbdd42c
Showing
4 changed files
with
100 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ description = "Python client for Toyota Connected Services." | |
authors = ["Simon Grud Hansen <[email protected]>"] | ||
license = "MIT" | ||
readme = "README.md" | ||
version = "0.7.2" | ||
version = "0.7.3" | ||
classifiers = [ | ||
"Development Status :: 4 - Beta", | ||
"License :: OSI Approved :: MIT License", | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
"""pytest tests for mytoyota.vehicle.Vehicle""" | ||
import json | ||
import os | ||
|
||
from mytoyota.vehicle import Vehicle | ||
|
||
# pylint: disable=no-self-use | ||
|
||
|
||
class TestVehicle: | ||
"""pytest functions for Vehicle object""" | ||
|
||
@staticmethod | ||
def _load_from_file(filename: str): | ||
"""Load a data structure from the specified JSON filename, and | ||
return it.""" | ||
with open(filename, encoding="UTF-8") as json_file: | ||
return json.load(json_file) | ||
|
||
def test_vehicle_no_data(self): | ||
"""Test vehicle with no initialization data""" | ||
vehicle = Vehicle({}) | ||
|
||
assert vehicle.id == 0 | ||
assert vehicle.vin is None | ||
assert vehicle.alias is None | ||
assert vehicle.details is None | ||
assert vehicle.is_connected is False | ||
assert vehicle.odometer is None | ||
assert vehicle.energy is None | ||
assert vehicle.hvac is None | ||
assert vehicle.parking is None | ||
|
||
def test_vehicle_init_no_status(self): | ||
"""Test vehicle initialization with no status""" | ||
|
||
data_files = os.path.join(os.path.curdir, "tests", "data") | ||
|
||
fixtures = self._load_from_file(os.path.join(data_files, "vehicles.json")) | ||
|
||
for veh in fixtures: | ||
vehicle = Vehicle(vehicle_info=veh) | ||
|
||
assert vehicle.vin == veh.get("vin") | ||
assert vehicle.is_connected is False | ||
assert vehicle.odometer is None | ||
assert vehicle.energy is None | ||
assert vehicle.hvac is None | ||
assert vehicle.parking is None | ||
|
||
def test_vehicle_init(self): | ||
"""Test vehicle initialization with connected services""" | ||
|
||
data_files = os.path.join(os.path.curdir, "tests", "data") | ||
|
||
fixtures = self._load_from_file(os.path.join(data_files, "vehicles.json")) | ||
|
||
for veh in fixtures: | ||
vehicle = Vehicle( | ||
vehicle_info=veh, | ||
connected_services={"connectedService": {"status": "ACTIVE"}}, | ||
) | ||
|
||
assert vehicle.vin == veh.get("vin") | ||
assert vehicle.is_connected is True | ||
print(vehicle.id) | ||
|
||
if vehicle.vin is None: | ||
assert vehicle.odometer is None | ||
assert vehicle.energy is None | ||
assert vehicle.hvac is None | ||
assert vehicle.parking is None | ||
else: | ||
assert vehicle.odometer is not None | ||
assert vehicle.energy is None | ||
assert vehicle.hvac is None | ||
assert vehicle.parking is not None |