apidae 1.4.29 → 1.4.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/models/apidae/apidae_data_parser.rb +46 -18
- data/app/models/apidae/selection.rb +1 -1
- data/lib/apidae/version.rb +1 -1
- data/test/dummy/log/development.log +1416 -0
- data/test/models/apidae/apidae_data_parser_test.rb +103 -0
- metadata +4 -2
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
module Apidae
|
|
4
|
+
class ApidaeDataParserTest < ActiveSupport::TestCase
|
|
5
|
+
|
|
6
|
+
test 'opening without detailed hours is a single time period' do
|
|
7
|
+
opening = {type: 'OUVERTURE_SEMAINE', ouverturesJournalieres: [{jour: 'LUNDI'}, {jour: 'MARDI'}],
|
|
8
|
+
horaireOuverture: '09:00:00', horaireFermeture: '18:00:00'}
|
|
9
|
+
|
|
10
|
+
assert_equal [{type: 'opening', weekdays: ['MON', 'TUE'],
|
|
11
|
+
time_frames: [{start_time: '09:00:00', end_time: '18:00:00', recurrence: nil}]}],
|
|
12
|
+
ApidaeDataParser.build_time_periods(opening)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
test 'each time period keeps its own weekdays and hours' do
|
|
16
|
+
opening = {type: 'OUVERTURE_TOUS_LES_JOURS', horaires: [hours(7487, [
|
|
17
|
+
time_period(['SUN'], ['10:00', '16:00']),
|
|
18
|
+
time_period(['WED', 'THU'], ['08:00', '20:00']),
|
|
19
|
+
time_period(['FRI'], ['08:00', '23:00']),
|
|
20
|
+
time_period(['SAT'], ['09:30', '13:30']),
|
|
21
|
+
time_period(['TUE', 'MON'], ['08:00', '16:00'])
|
|
22
|
+
])]}
|
|
23
|
+
|
|
24
|
+
assert_equal [
|
|
25
|
+
{type: 'opening', weekdays: ['MON', 'TUE'], time_frames: [{start_time: '08:00', end_time: '16:00', recurrence: nil}]},
|
|
26
|
+
{type: 'opening', weekdays: ['WED', 'THU'], time_frames: [{start_time: '08:00', end_time: '20:00', recurrence: nil}]},
|
|
27
|
+
{type: 'opening', weekdays: ['FRI'], time_frames: [{start_time: '08:00', end_time: '23:00', recurrence: nil}]},
|
|
28
|
+
{type: 'opening', weekdays: ['SAT'], time_frames: [{start_time: '09:30', end_time: '13:30', recurrence: nil}]},
|
|
29
|
+
{type: 'opening', weekdays: ['SUN'], time_frames: [{start_time: '10:00', end_time: '16:00', recurrence: nil}]}
|
|
30
|
+
], ApidaeDataParser.build_time_periods(opening)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
test 'time periods of the same weekdays keep all their hours' do
|
|
34
|
+
opening = {type: 'OUVERTURE_TOUS_LES_JOURS', horaires: [hours(7487, [
|
|
35
|
+
time_period(['MON', 'TUE'], ['09:00', '12:00'], ['14:00', '18:00'])
|
|
36
|
+
])]}
|
|
37
|
+
|
|
38
|
+
assert_equal [{type: 'opening', weekdays: ['MON', 'TUE'],
|
|
39
|
+
time_frames: [{start_time: '09:00', end_time: '12:00', recurrence: nil},
|
|
40
|
+
{start_time: '14:00', end_time: '18:00', recurrence: nil}]}],
|
|
41
|
+
ApidaeDataParser.build_time_periods(opening)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
test 'hours type is read from its identifier' do
|
|
45
|
+
opening = {type: 'OUVERTURE_TOUS_LES_JOURS', horaires: [
|
|
46
|
+
hours(7487, [time_period(['SAT'], ['10:00', '19:00'])]),
|
|
47
|
+
hours(7492, [time_period(['SAT'], ['12:00', '14:00'])]),
|
|
48
|
+
hours(7498, [time_period(['SUN'], ['08:00', '11:00'])])
|
|
49
|
+
]}
|
|
50
|
+
|
|
51
|
+
assert_equal ['opening', 'service', 'Checkout'], ApidaeDataParser.build_time_periods(opening).map {|tp| tp[:type]}
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
test 'hours type provided by the API is used first' do
|
|
55
|
+
opening = {type: 'OUVERTURE_TOUS_LES_JOURS', horaires: [
|
|
56
|
+
{type: {elementReferenceType: 'HoraireType', id: 1, externalType: 'guided_tour'}, timePeriods: [time_period(['SAT'], ['10:00', '11:00'])]}
|
|
57
|
+
]}
|
|
58
|
+
|
|
59
|
+
assert_equal ['guided_tour'], ApidaeDataParser.build_time_periods(opening).map {|tp| tp[:type]}
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
test 'closed time periods are ignored' do
|
|
63
|
+
opening = {type: 'OUVERTURE_TOUS_LES_JOURS', horaires: [hours(7487, [
|
|
64
|
+
{closed: true, weekdays: ['MON'], timeFrames: []},
|
|
65
|
+
time_period(['TUE'], ['10:00', '19:00'])
|
|
66
|
+
])]}
|
|
67
|
+
|
|
68
|
+
assert_equal [['TUE']], ApidaeDataParser.build_time_periods(opening).map {|tp| tp[:weekdays]}
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
test 'time period without weekdays uses the weekdays of the opening' do
|
|
72
|
+
opening = {type: 'OUVERTURE_SAUF', ouverturesJournalieres: [{jour: 'DIMANCHE'}],
|
|
73
|
+
horaires: [hours(7487, [time_period(nil, ['10:00', '19:00'])])]}
|
|
74
|
+
|
|
75
|
+
assert_equal [['MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']], ApidaeDataParser.build_time_periods(opening).map {|tp| tp[:weekdays]}
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
test 'recurrence is kept and empty time frames are ignored' do
|
|
79
|
+
opening = {type: 'OUVERTURE_TOUS_LES_JOURS', horaires: [hours(7490, [
|
|
80
|
+
{closed: false, weekdays: ['SAT'], timeFrames: [{startTime: '10:00', endTime: '16:00', recurrence: '01:30'}, {startTime: nil, endTime: nil}]}
|
|
81
|
+
])]}
|
|
82
|
+
|
|
83
|
+
assert_equal [{type: 'guided_tour', weekdays: ['SAT'], time_frames: [{start_time: '10:00', end_time: '16:00', recurrence: '01:30'}]}],
|
|
84
|
+
ApidaeDataParser.build_time_periods(opening)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
test 'opening whose detailed hours are all closed falls back to a single time period' do
|
|
88
|
+
opening = {type: 'OUVERTURE_TOUS_LES_JOURS', horaires: [hours(7487, [{closed: true, weekdays: ['MON'], timeFrames: []}])]}
|
|
89
|
+
|
|
90
|
+
assert_equal [{type: 'opening', weekdays: ApidaeDataParser::ALL_DAYS, time_frames: []}], ApidaeDataParser.build_time_periods(opening)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
private
|
|
94
|
+
|
|
95
|
+
def hours(type_id, time_periods)
|
|
96
|
+
{type: {elementReferenceType: 'HoraireType', id: type_id}, timePeriods: time_periods}
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def time_period(weekdays, *time_frames)
|
|
100
|
+
{closed: false, weekdays: weekdays, timeFrames: time_frames.map {|tf| {startTime: tf.first, endTime: tf.last}}}
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: apidae
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.4.
|
|
4
|
+
version: 1.4.30
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jean-Baptiste Vilain
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-11-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -263,6 +263,7 @@ files:
|
|
|
263
263
|
- test/fixtures/apidae/selections.yml
|
|
264
264
|
- test/fixtures/apidae/towns.yml
|
|
265
265
|
- test/integration/navigation_test.rb
|
|
266
|
+
- test/models/apidae/apidae_data_parser_test.rb
|
|
266
267
|
- test/models/apidae/export_test.rb
|
|
267
268
|
- test/models/apidae/file_import_test.rb
|
|
268
269
|
- test/models/apidae/obj_test.rb
|
|
@@ -338,6 +339,7 @@ test_files:
|
|
|
338
339
|
- test/dummy/README.rdoc
|
|
339
340
|
- test/integration/navigation_test.rb
|
|
340
341
|
- test/models/apidae/selection_object_test.rb
|
|
342
|
+
- test/models/apidae/apidae_data_parser_test.rb
|
|
341
343
|
- test/models/apidae/selection_test.rb
|
|
342
344
|
- test/models/apidae/file_import_test.rb
|
|
343
345
|
- test/models/apidae/export_test.rb
|