0001-planitech-filter-dates-by-place-id-28298.patch
functests/planitech/test_planitech.py | ||
---|---|---|
7 | 7 | |
8 | 8 | |
9 | 9 |
def test_main(conn): |
10 |
# get a free gap
|
|
10 |
# get days
|
|
11 | 11 |
today = datetime.datetime.now().date().isoformat() |
12 | 12 |
query_string = urllib.urlencode({ |
13 | 13 |
'start_date': today, 'start_time': '10:00', 'end_time': '11:00' |
... | ... | |
34 | 34 |
assert data |
35 | 35 |
place = data[random.randint(0, len(data) - 1)]['id'] |
36 | 36 | |
37 |
# get days on one place |
|
38 |
today = datetime.datetime.now().date().isoformat() |
|
39 |
query_string = urllib.urlencode({ |
|
40 |
'start_date': today, 'start_time': '10:00', 'end_time': '11:00', 'place_id': place |
|
41 |
}) |
|
42 |
url = conn + '/getdays?%s' % query_string |
|
43 |
resp = requests.get(url) |
|
44 |
resp.raise_for_status() |
|
45 |
res = resp.json() |
|
46 |
assert res['err'] == 0 |
|
47 |
data = res['data'] |
|
48 |
assert data |
|
49 | ||
37 | 50 |
# create reservation |
38 | 51 |
params = { |
39 | 52 |
'date': date, 'start_time': '10:00', 'end_time': '11:00', |
passerelle/contrib/planitech/models.py | ||
---|---|---|
319 | 319 |
'example_value': 'true', |
320 | 320 |
'type': 'bool', |
321 | 321 |
}, |
322 |
'place_id': { |
|
323 |
'description': _('Place identifer'), |
|
324 |
'example_value': '2', |
|
325 |
'type': 'int', |
|
326 |
} |
|
322 | 327 |
}) |
323 | 328 |
def getdays( |
324 | 329 |
self, request, start_date, start_time, end_time, min_capacity=0, |
325 |
end_date=None, max_capacity=100000, weekdays=False): |
|
326 |
places_id = self._get_places_by_capacity(int(min_capacity), int(max_capacity)) |
|
330 |
end_date=None, max_capacity=100000, weekdays=False, place_id=None): |
|
331 |
if place_id is not None: |
|
332 |
places_id = [float(place_id)] |
|
333 |
else: |
|
334 |
places_id = self._get_places_by_capacity(int(min_capacity), int(max_capacity)) |
|
327 | 335 | |
328 | 336 |
utc_start_datetime = get_utc_datetime(start_date, start_time) |
329 | 337 |
if end_date is None: |
tests/test_planitech.py | ||
---|---|---|
364 | 364 |
call_params = mock_call_planitech.call_args[0][2] |
365 | 365 |
assert call_params['requestedEndingTime'] == 180.0 |
366 | 366 | |
367 |
# place_id filter |
|
368 |
mock_call_planitech.reset_mock() |
|
369 |
response = app.get( |
|
370 |
'/planitech/slug-planitech/getdays?start_time=11:00&&end_time=14:00' |
|
371 |
'&start_date=2018-11-11&place_id=2' |
|
372 |
) |
|
373 |
call_params = mock_call_planitech.call_args[0][2] |
|
374 |
assert call_params['placeIdentifiers'] == [2.0] |
|
375 | ||
367 | 376 |
# date bad format |
368 | 377 |
response = app.get( |
369 | 378 |
'/planitech/slug-planitech/getdays?start_time=11:00&&end_time=14:00' |
370 |
- |