-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add more sample inputs and unit tests
- Loading branch information
Showing
4 changed files
with
63 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"weather": { | ||
"temperature": 25, | ||
"humidity": 60.5, | ||
"wind_speed": 10.2 | ||
}, | ||
"traffic_flow": { | ||
"average_speed": 45.5, | ||
"traffic_density": [0.3, 0.5, 0.7], | ||
"incident_reports": 2 | ||
}, | ||
"road_condition": { | ||
"road_quality": 8, | ||
"lighting_conditions": 9, | ||
"accident_history": 1 | ||
} | ||
} |
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,17 @@ | ||
{ | ||
"weather": { | ||
"temperature": -5, | ||
"humidity": 90.5, | ||
"wind_speed": 25.0 | ||
}, | ||
"traffic_flow": { | ||
"average_speed": 10.5, | ||
"traffic_density": [0.95, 0.98, 0.99], | ||
"incident_reports": 10 | ||
}, | ||
"road_condition": { | ||
"road_quality": 2, | ||
"lighting_conditions": 3, | ||
"accident_history": 7 | ||
} | ||
} |
Empty file.
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,29 @@ | ||
from src.calculators import ( | ||
calculate_comfort_index, | ||
calculate_traffic_flow_efficiency, | ||
calculate_safety_score, | ||
calculate_overall_commute_quality_score, | ||
) | ||
|
||
|
||
def test_calculate_comfort_index(): | ||
assert calculate_comfort_index(25, 60) == 45 | ||
assert calculate_comfort_index(30, 70, 10) == 25 | ||
assert calculate_comfort_index(20, 50, 5) == 57.5 | ||
|
||
|
||
def test_calculate_traffic_flow_efficiency(): | ||
assert calculate_traffic_flow_efficiency(60, [0.5, 0.3, 0.2]) == 30.0 | ||
assert calculate_traffic_flow_efficiency(50, [0.4, 0.4, 0.2], 2) == 21 | ||
assert calculate_traffic_flow_efficiency(40, [0.1, 0.1], 0) == 33.333333333333336 | ||
|
||
|
||
def test_calculate_safety_score(): | ||
assert calculate_safety_score(8, 7, 2, 50, [0.3, 0.4, 0.3]) == 353.6666666666667 | ||
assert calculate_safety_score(9, 8, 1, 60, [0.2, 0.2, 0.1], 3, 5) == 478.5 | ||
assert calculate_safety_score(7, 6, 3, 40, [0.5, 0.5], 1) == 241.75 | ||
|
||
|
||
def test_calculate_overall_commute_quality_score(): | ||
assert calculate_overall_commute_quality_score(45, 60, 120) == 75 | ||
assert calculate_overall_commute_quality_score(25, 21, 472) == 172.66666666666666 |