|
@@ 157-202 (lines=46) @@
|
| 154 |
|
assert isinstance(res, Optimization) |
| 155 |
|
assert res.ID == '1EDB78F63556D99336E06A13A34CF139' |
| 156 |
|
|
| 157 |
|
def test_get(self): |
| 158 |
|
|
| 159 |
|
sample_response_data = load_json( |
| 160 |
|
# '..', '..', '..', |
| 161 |
|
'submodules', 'route4me-api-data-examples', 'Optimizations', |
| 162 |
|
'get_response.json' |
| 163 |
|
) |
| 164 |
|
|
| 165 |
|
self.set_response(data=sample_response_data) |
| 166 |
|
|
| 167 |
|
r = Optimizations(api_key='test') |
| 168 |
|
res = r.get('07372F2CF3814EC6DFFAFE92E22771AA') |
| 169 |
|
|
| 170 |
|
log.debug(self.mock_fluent_request_class.mock_calls) |
| 171 |
|
|
| 172 |
|
# ---------- |
| 173 |
|
# assertions |
| 174 |
|
mock_freq = self.last_request() |
| 175 |
|
mock_freq.method.assert_called_with('GET') |
| 176 |
|
mock_freq.url.assert_called_with( |
| 177 |
|
'https://www.route4me.com/api.v4/optimization_problem.php' |
| 178 |
|
) |
| 179 |
|
mock_freq.qs.assert_any_call({ |
| 180 |
|
'optimization_problem_id': '07372F2CF3814EC6DFFAFE92E22771AA' |
| 181 |
|
}) |
| 182 |
|
assert not mock_freq.json.called |
| 183 |
|
assert not mock_freq.data.called |
| 184 |
|
|
| 185 |
|
# assertions on response |
| 186 |
|
assert isinstance(res, Optimization) |
| 187 |
|
assert res.ID == '07372F2CF3814EC6DFFAFE92E22771AA' |
| 188 |
|
assert res.name == 'Sunday 10th of April 2016 01:20 AM (+03:00)' |
| 189 |
|
assert res.algorithm_type == AlgorithmTypeEnum.CVRP_TW_SD |
| 190 |
|
assert res.state == OptimizationStateEnum.OPTIMIZED |
| 191 |
|
assert res.optimization_factor == OptimizationFactorEnum.TIME |
| 192 |
|
assert res.member_id == 44143 |
| 193 |
|
assert res.vehicle_id is None |
| 194 |
|
assert res.device_id is None |
| 195 |
|
assert res.round_trip is True |
| 196 |
|
|
| 197 |
|
log.debug(res) |
| 198 |
|
assert isinstance(res.addresses, list) |
| 199 |
|
assert len(res.addresses) > 0 |
| 200 |
|
a0 = res.addresses[0] |
| 201 |
|
assert isinstance(a0, Address) |
| 202 |
|
assert a0.ID == 154456307 |
| 203 |
|
|
| 204 |
|
def test_list_no_states(self): |
| 205 |
|
|
|
@@ 204-248 (lines=45) @@
|
| 201 |
|
assert isinstance(a0, Address) |
| 202 |
|
assert a0.ID == 154456307 |
| 203 |
|
|
| 204 |
|
def test_list_no_states(self): |
| 205 |
|
|
| 206 |
|
sample_response_data = load_json( |
| 207 |
|
# '..', '..', '..', |
| 208 |
|
'submodules', 'route4me-api-data-examples', 'Optimizations', |
| 209 |
|
'list_response.json' |
| 210 |
|
) |
| 211 |
|
|
| 212 |
|
self.set_response(data=sample_response_data) |
| 213 |
|
|
| 214 |
|
r = Optimizations(api_key='test') |
| 215 |
|
res = r.list() |
| 216 |
|
|
| 217 |
|
log.debug(self.mock_fluent_request_class.mock_calls) |
| 218 |
|
|
| 219 |
|
# ---------- |
| 220 |
|
# assertions |
| 221 |
|
mock_freq = self.last_request() |
| 222 |
|
mock_freq.method.assert_called_with('GET') |
| 223 |
|
mock_freq.url.assert_called_with( |
| 224 |
|
'https://www.route4me.com/api.v4/optimization_problem.php' |
| 225 |
|
) |
| 226 |
|
mock_freq.qs.assert_any_call({}) |
| 227 |
|
|
| 228 |
|
assert not mock_freq.json.called |
| 229 |
|
assert not mock_freq.data.called |
| 230 |
|
|
| 231 |
|
# assertions on response |
| 232 |
|
assert isinstance(res, list) |
| 233 |
|
assert isinstance(res, PagedList) |
| 234 |
|
assert res.total == 447 |
| 235 |
|
assert res.limit is None |
| 236 |
|
assert res.offset is None |
| 237 |
|
|
| 238 |
|
res0 = res[0] |
| 239 |
|
assert isinstance(res0, Optimization) |
| 240 |
|
assert res0.ID == '7EC3FC88737C29E93A54E88243ACBC77' |
| 241 |
|
assert res0.name == 'Fri, 20 May 2016 12:43:46 +0000 UTC' |
| 242 |
|
assert res0.algorithm_type == AlgorithmTypeEnum.CVRP_TW_SD |
| 243 |
|
assert res0.state == OptimizationStateEnum.INITIAL |
| 244 |
|
assert res0.optimization_factor == OptimizationFactorEnum.DISTANCE |
| 245 |
|
assert res0.member_id == 1 |
| 246 |
|
assert res0.vehicle_id is None |
| 247 |
|
assert res0.device_id is None |
| 248 |
|
assert res0.round_trip is True |
| 249 |
|
|
| 250 |
|
def test_list_with_states(self): |
| 251 |
|
|