-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_collision.py
137 lines (130 loc) · 4.85 KB
/
test_collision.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
import copy
from unittest import TestCase
from road_collisions_uk.models.collision import Collision
from road_collisions_uk.models.vehicle import Vehicles
from road_collisions_uk.models.casualty import Casualties
class CollisionTest(TestCase):
TEST_COLLISION_DATA = {
'casualties': Casualties(),
'vehicles': Vehicles(),
'accident_year': 2016,
'date': '01/01/2016',
'accident_reference': 10000005,
'accident_severity': 3.0,
'age_band_of_casualty': 5.0,
'age_band_of_driver': 5.0,
'age_of_casualty': 23.0,
'age_of_driver': 23.0,
'age_of_vehicle': 4.0,
'bus_or_coach_passenger': 0.0,
'car_passenger': 0.0,
'carriageway_hazards': 0.0,
'casualty_class': 1.0,
'casualty_home_area_type': 1.0,
'casualty_imd_decile': 4.0,
'casualty_reference': 1.0,
'casualty_severity': 3.0,
'casualty_type': 2.0,
'day_of_week': 3.0,
'did_police_officer_attend_scene_of_accident': 1.0,
'driver_home_area_type': 1.0,
'driver_imd_decile': 4.0,
'engine_capacity_cc': 124.0,
'first_point_of_impact': 1.0,
'first_road_class': 3.0,
'first_road_number': 4006.0,
'generic_make_model': -1,
'hit_object_in_carriageway': 0.0,
'hit_object_off_carriageway': 0.0,
'accident_index': 2016010000005,
'journey_purpose_of_driver': 6.0,
'junction_control': -1.0,
'junction_detail': 0.0,
'junction_location': 0.0,
'latitude': 51.584754,
'light_conditions': 5.0,
'longitude': -0.279323,
'local_authority_district': 28.0,
'local_authority_highway': 'E09000005',
'local_authority_ons_district': 'E09000005',
'location_easting_osgr': 519310.0,
'location_northing_osgr': 188730.0,
'lsoa_of_accident_location': 'E01000543',
'number_of_casualties': 1.0,
'number_of_vehicles': 2.0,
'pedestrian_crossing_human_control': 0.0,
'pedestrian_crossing_physical_facilities': 0.0,
'pedestrian_location': 0.0,
'pedestrian_movement': 0.0,
'pedestrian_road_maintenance_worker': 0.0,
'police_force': 1.0,
'propulsion_code': 1.0,
'road_surface_conditions': 1.0,
'road_type': 6.0,
'second_road_class': -1.0,
'second_road_number': -1.0,
'sex_of_casualty': 1.0,
'sex_of_driver': 1.0,
'skidding_and_overturning': 0.0,
'special_conditions_at_site': 0.0,
'speed_limit': 30.0,
'time': '02:30',
'towing_and_articulation': 0.0,
'trunk_road_flag': 2.0,
'urban_or_rural_area': 1.0,
'vehicle_direction_from': 7.0,
'vehicle_direction_to': 3.0,
'vehicle_leaving_carriageway': 0.0,
'vehicle_left_hand_drive': 1.0,
'vehicle_location_restricted_lane': 0.0,
'vehicle_manoeuvre': 18.0,
'vehicle_reference': 2.0,
'vehicle_type': 2.0,
'weather_conditions': 1.0,
'year': 2016
}
def test_complete_serialize(self):
collision = Collision(
**self.TEST_COLLISION_DATA
)
self.assertEqual(
collision.serialize(),
{
'accident_index': 2016010000005,
'accident_severity': 3.0,
'accident_year': 2016,
'carriageway_hazards': 0.0,
'casualties': [],
'date': '01/01/2016',
'did_police_officer_attend_scene_of_accident': 1.0,
'first_road_class': 3.0,
'first_road_number': 4006.0,
'junction_control': -1.0,
'junction_detail': 0.0,
'latitude': 51.584754,
'light_conditions': 5.0,
'local_authority_district': 28.0,
'local_authority_highway': 'E09000005',
'local_authority_ons_district': 'E09000005',
'location_easting_osgr': 519310.0,
'location_northing_osgr': 188730.0,
'longitude': -0.279323,
'lsoa_of_accident_location': 'E01000543',
'number_of_casualties': 1.0,
'number_of_vehicles': 2.0,
'pedestrian_crossing_human_control': 0.0,
'pedestrian_crossing_physical_facilities': 0.0,
'police_force': 1.0,
'road_surface_conditions': 1.0,
'road_type': 6.0,
'second_road_class': -1.0,
'second_road_number': -1.0,
'special_conditions_at_site': 0.0,
'speed_limit': 30.0,
'time': '02:30',
'trunk_road_flag': 2.0,
'urban_or_rural_area': 1.0,
'vehicles': [],
'weather_conditions': 1.0
}
)