-
-
Notifications
You must be signed in to change notification settings - Fork 253
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
Showing
9 changed files
with
254 additions
and
47 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from datetime import datetime | ||
|
||
from typing import List | ||
|
||
|
||
class BatterySoh: | ||
def __init__(self, vin, dates, levels): | ||
self.vin = vin | ||
self.dates: List[datetime] = dates | ||
self.levels: List[float] = levels |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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,27 @@ | ||
import unittest | ||
from sqlite3.dbapi2 import IntegrityError | ||
|
||
from psa_car_controller.psacc.model.battery_soh import BatterySoh | ||
from psa_car_controller.psacc.repository.db import Database | ||
from tests.utils import get_new_test_db, compare_dict, get_date, vehicule_list | ||
|
||
|
||
class TestUnit(unittest.TestCase): | ||
def test_record_soh(self): | ||
get_new_test_db() | ||
car = vehicule_list[0] | ||
soh_list = [99.0, 96.0, 90.2] | ||
for x in range(len(soh_list)): | ||
Database.record_battery_soh(car.vin, get_date(x), soh_list[x]) | ||
compare_dict(vars(BatterySoh(car.vin, | ||
[get_date(0), get_date(1), get_date(2)], | ||
soh_list)), | ||
vars(Database.get_soh_by_vin(car.vin)) | ||
) | ||
self.assertEqual(soh_list[-1], Database.get_last_soh_by_vin(car.vin)) | ||
|
||
def test_record_same_soh(self): | ||
get_new_test_db() | ||
car = vehicule_list[0] | ||
Database.record_battery_soh(car.vin, get_date(0), 99.0) | ||
self.assertRaises(IntegrityError, Database.record_battery_soh, car.vin, get_date(0), 99.0) |
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
Oops, something went wrong.