tilia-vobject 4.0.0.pre.alpha2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.rubocop.yml +32 -0
- data/.simplecov +4 -0
- data/.travis.yml +3 -0
- data/CHANGELOG.sabre.md +626 -0
- data/CONTRIBUTING.md +25 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +68 -0
- data/LICENSE +27 -0
- data/LICENSE.sabre +27 -0
- data/README.md +63 -0
- data/Rakefile +17 -0
- data/bin/vobject +7 -0
- data/lib/tilia/v_object/birthday_calendar_generator.rb +142 -0
- data/lib/tilia/v_object/cli.rb +582 -0
- data/lib/tilia/v_object/component/available.rb +107 -0
- data/lib/tilia/v_object/component/v_alarm.rb +114 -0
- data/lib/tilia/v_object/component/v_availability.rb +128 -0
- data/lib/tilia/v_object/component/v_calendar.rb +468 -0
- data/lib/tilia/v_object/component/v_card.rb +457 -0
- data/lib/tilia/v_object/component/v_event.rb +127 -0
- data/lib/tilia/v_object/component/v_free_busy.rb +81 -0
- data/lib/tilia/v_object/component/v_journal.rb +75 -0
- data/lib/tilia/v_object/component/v_time_zone.rb +51 -0
- data/lib/tilia/v_object/component/v_todo.rb +147 -0
- data/lib/tilia/v_object/component.rb +591 -0
- data/lib/tilia/v_object/date_time_parser.rb +486 -0
- data/lib/tilia/v_object/document.rb +218 -0
- data/lib/tilia/v_object/element_list.rb +18 -0
- data/lib/tilia/v_object/eof_exception.rb +8 -0
- data/lib/tilia/v_object/free_busy_data.rb +149 -0
- data/lib/tilia/v_object/free_busy_generator.rb +465 -0
- data/lib/tilia/v_object/i_tip/broker.rb +909 -0
- data/lib/tilia/v_object/i_tip/i_tip_exception.rb +9 -0
- data/lib/tilia/v_object/i_tip/message.rb +109 -0
- data/lib/tilia/v_object/i_tip/same_organizer_for_all_components_exception.rb +13 -0
- data/lib/tilia/v_object/i_tip.rb +10 -0
- data/lib/tilia/v_object/node.rb +192 -0
- data/lib/tilia/v_object/parameter.rb +327 -0
- data/lib/tilia/v_object/parse_exception.rb +7 -0
- data/lib/tilia/v_object/parser/json.rb +149 -0
- data/lib/tilia/v_object/parser/mime_dir.rb +543 -0
- data/lib/tilia/v_object/parser/parser.rb +61 -0
- data/lib/tilia/v_object/parser/xml/element/key_value.rb +60 -0
- data/lib/tilia/v_object/parser/xml/element.rb +11 -0
- data/lib/tilia/v_object/parser/xml.rb +322 -0
- data/lib/tilia/v_object/parser.rb +10 -0
- data/lib/tilia/v_object/property/binary.rb +96 -0
- data/lib/tilia/v_object/property/boolean.rb +57 -0
- data/lib/tilia/v_object/property/flat_text.rb +52 -0
- data/lib/tilia/v_object/property/float_value.rb +107 -0
- data/lib/tilia/v_object/property/i_calendar/cal_address.rb +49 -0
- data/lib/tilia/v_object/property/i_calendar/date.rb +15 -0
- data/lib/tilia/v_object/property/i_calendar/date_time.rb +330 -0
- data/lib/tilia/v_object/property/i_calendar/duration.rb +65 -0
- data/lib/tilia/v_object/property/i_calendar/period.rb +124 -0
- data/lib/tilia/v_object/property/i_calendar/recur.rb +173 -0
- data/lib/tilia/v_object/property/i_calendar.rb +14 -0
- data/lib/tilia/v_object/property/integer_value.rb +60 -0
- data/lib/tilia/v_object/property/text.rb +352 -0
- data/lib/tilia/v_object/property/time.rb +85 -0
- data/lib/tilia/v_object/property/unknown.rb +30 -0
- data/lib/tilia/v_object/property/uri.rb +78 -0
- data/lib/tilia/v_object/property/utc_offset.rb +56 -0
- data/lib/tilia/v_object/property/v_card/date.rb +31 -0
- data/lib/tilia/v_object/property/v_card/date_and_or_time.rb +343 -0
- data/lib/tilia/v_object/property/v_card/date_time.rb +22 -0
- data/lib/tilia/v_object/property/v_card/language_tag.rb +41 -0
- data/lib/tilia/v_object/property/v_card/time_stamp.rb +74 -0
- data/lib/tilia/v_object/property/v_card.rb +13 -0
- data/lib/tilia/v_object/property.rb +532 -0
- data/lib/tilia/v_object/reader.rb +73 -0
- data/lib/tilia/v_object/recur/event_iterator.rb +417 -0
- data/lib/tilia/v_object/recur/no_instances_exception.rb +11 -0
- data/lib/tilia/v_object/recur/r_date_iterator.rb +138 -0
- data/lib/tilia/v_object/recur/r_rule_iterator.rb +717 -0
- data/lib/tilia/v_object/recur.rb +10 -0
- data/lib/tilia/v_object/settings.rb +32 -0
- data/lib/tilia/v_object/splitter/i_calendar.rb +95 -0
- data/lib/tilia/v_object/splitter/splitter_interface.rb +31 -0
- data/lib/tilia/v_object/splitter/v_card.rb +56 -0
- data/lib/tilia/v_object/splitter.rb +9 -0
- data/lib/tilia/v_object/string_util.rb +58 -0
- data/lib/tilia/v_object/time_zone_data/exchange_zones.rb +96 -0
- data/lib/tilia/v_object/time_zone_data/lotus_zones.rb +104 -0
- data/lib/tilia/v_object/time_zone_data/php_zones.rb +49 -0
- data/lib/tilia/v_object/time_zone_data/windows_zones.rb +121 -0
- data/lib/tilia/v_object/time_zone_data.rb +10 -0
- data/lib/tilia/v_object/time_zone_util.rb +213 -0
- data/lib/tilia/v_object/uuid_util.rb +51 -0
- data/lib/tilia/v_object/v_card_converter.rb +354 -0
- data/lib/tilia/v_object/version.rb +9 -0
- data/lib/tilia/v_object/writer.rb +56 -0
- data/lib/tilia/v_object.rb +45 -0
- data/lib/tilia/vobject.rb +1 -0
- data/resources/schema/xcal.rng +1192 -0
- data/resources/schema/xcard.rng +388 -0
- data/test/test_helper.rb +56 -0
- data/test/v_object/attach_issue_test.rb +19 -0
- data/test/v_object/birthday_calendar_generator_test.rb +463 -0
- data/test/v_object/cli_mock.rb +19 -0
- data/test/v_object/cli_test.rb +460 -0
- data/test/v_object/component/available_test.rb +59 -0
- data/test/v_object/component/v_alarm_test.rb +160 -0
- data/test/v_object/component/v_availability_test.rb +388 -0
- data/test/v_object/component/v_calendar_test.rb +646 -0
- data/test/v_object/component/v_card_test.rb +258 -0
- data/test/v_object/component/v_event_test.rb +85 -0
- data/test/v_object/component/v_free_busy_test.rb +59 -0
- data/test/v_object/component/v_journal_test.rb +85 -0
- data/test/v_object/component/v_time_zone_test.rb +47 -0
- data/test/v_object/component/v_todo_test.rb +172 -0
- data/test/v_object/component_test.rb +419 -0
- data/test/v_object/date_time_parser_test.rb +526 -0
- data/test/v_object/document_test.rb +71 -0
- data/test/v_object/element_list_test.rb +27 -0
- data/test/v_object/em_client_test.rb +53 -0
- data/test/v_object/empty_parameter_test.rb +65 -0
- data/test/v_object/empty_value_issue_test.rb +25 -0
- data/test/v_object/fake_component.rb +21 -0
- data/test/v_object/free_busy_data_test.rb +285 -0
- data/test/v_object/free_busy_generator_test.rb +637 -0
- data/test/v_object/google_colon_escaping_test.rb +27 -0
- data/test/v_object/i_calendar/attach_parse_test.rb +24 -0
- data/test/v_object/i_tip/broker_attendee_reply_test.rb +1042 -0
- data/test/v_object/i_tip/broker_delete_event_test.rb +175 -0
- data/test/v_object/i_tip/broker_new_event_test.rb +440 -0
- data/test/v_object/i_tip/broker_process_message_test.rb +153 -0
- data/test/v_object/i_tip/broker_process_reply_test.rb +402 -0
- data/test/v_object/i_tip/broker_tester.rb +71 -0
- data/test/v_object/i_tip/broker_update_event_test.rb +763 -0
- data/test/v_object/i_tip/evolution_test.rb +2644 -0
- data/test/v_object/i_tip/message_test.rb +25 -0
- data/test/v_object/issue153.vcf +352 -0
- data/test/v_object/issue153_test.rb +12 -0
- data/test/v_object/issue26_test.rb +25 -0
- data/test/v_object/issue36_work_around_test.rb +37 -0
- data/test/v_object/issue40_test.rb +26 -0
- data/test/v_object/issue64.vcf +351 -0
- data/test/v_object/issue64_test.rb +17 -0
- data/test/v_object/issue96_test.rb +22 -0
- data/test/v_object/issue_undefined_index_test.rb +24 -0
- data/test/v_object/j_cal_test.rb +150 -0
- data/test/v_object/j_card_test.rb +192 -0
- data/test/v_object/line_folding_issue_test.rb +19 -0
- data/test/v_object/mock_document.rb +6 -0
- data/test/v_object/parameter_test.rb +109 -0
- data/test/v_object/parser/json_test.rb +370 -0
- data/test/v_object/parser/mime_dir_test.rb +14 -0
- data/test/v_object/parser/quoted_printable_test.rb +78 -0
- data/test/v_object/parser/xml_test.rb +2563 -0
- data/test/v_object/property/binary_test.rb +12 -0
- data/test/v_object/property/boolean_test.rb +18 -0
- data/test/v_object/property/compound_test.rb +43 -0
- data/test/v_object/property/float_test.rb +20 -0
- data/test/v_object/property/i_calendar/cal_address_test.rb +26 -0
- data/test/v_object/property/i_calendar/date_time_test.rb +303 -0
- data/test/v_object/property/i_calendar/duration_test.rb +14 -0
- data/test/v_object/property/i_calendar/recur_test.rb +39 -0
- data/test/v_object/property/text_test.rb +81 -0
- data/test/v_object/property/v_card/date_and_or_time_test.rb +205 -0
- data/test/v_object/property/v_card/language_tag_test.rb +35 -0
- data/test/v_object/property_test.rb +338 -0
- data/test/v_object/reader_test.rb +403 -0
- data/test/v_object/recur/event_iterator/by_month_in_daily_test.rb +52 -0
- data/test/v_object/recur/event_iterator/by_set_pos_hang_test.rb +55 -0
- data/test/v_object/recur/event_iterator/expand_floating_times_test.rb +109 -0
- data/test/v_object/recur/event_iterator/fifth_tuesday_problem_test.rb +45 -0
- data/test/v_object/recur/event_iterator/incorrect_expand_test.rb +53 -0
- data/test/v_object/recur/event_iterator/infinite_loop_problem_test.rb +75 -0
- data/test/v_object/recur/event_iterator/issue48_test.rb +43 -0
- data/test/v_object/recur/event_iterator/issue50_test.rb +123 -0
- data/test/v_object/recur/event_iterator/main_test.rb +1222 -0
- data/test/v_object/recur/event_iterator/missing_overridden_test.rb +55 -0
- data/test/v_object/recur/event_iterator/no_instances_test.rb +32 -0
- data/test/v_object/recur/event_iterator/override_first_event_test.rb +106 -0
- data/test/v_object/recur/r_date_iterator_test.rb +44 -0
- data/test/v_object/recur/r_rule_iterator_test.rb +608 -0
- data/test/v_object/recurrence_iterator/UntilRespectsTimezoneTest.ics +39 -0
- data/test/v_object/slash_r_test.rb +15 -0
- data/test/v_object/splitter/i_calendar_test.rb +299 -0
- data/test/v_object/splitter/v_card_test.rb +173 -0
- data/test/v_object/string_util_test.rb +37 -0
- data/test/v_object/test_case.rb +42 -0
- data/test/v_object/time_zone_util_test.rb +271 -0
- data/test/v_object/uuid_util_test.rb +18 -0
- data/test/v_object/v_card21_test.rb +43 -0
- data/test/v_object/v_card_converter_test.rb +419 -0
- data/test/v_object/version_test.rb +15 -0
- data/test/v_object/writer_test.rb +33 -0
- data/tilia-vobject.gemspec +17 -0
- metadata +308 -0
@@ -0,0 +1,388 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Tilia
|
4
|
+
module VObject
|
5
|
+
class VAvailabilityTest < Minitest::Test
|
6
|
+
def assert_is_valid(document)
|
7
|
+
validation_result = document.validate
|
8
|
+
if validation_result.any?
|
9
|
+
messages = validation_result.map { |i| i['message'] }
|
10
|
+
fail "Failed to assert that the supplied document is a valid document. Validation messages: #{messages.join(', ')}"
|
11
|
+
end
|
12
|
+
assert_equal(0, document.validate.size)
|
13
|
+
end
|
14
|
+
|
15
|
+
def assert_is_not_valid(document)
|
16
|
+
assert(document.validate.size > 0)
|
17
|
+
end
|
18
|
+
|
19
|
+
def template(properties)
|
20
|
+
vcal = <<VCAL
|
21
|
+
BEGIN:VCALENDAR
|
22
|
+
VERSION:2.0
|
23
|
+
PRODID:-//id
|
24
|
+
BEGIN:VAVAILABILITY
|
25
|
+
UID:foo@test
|
26
|
+
DTSTAMP:20111005T133225Z
|
27
|
+
…
|
28
|
+
END:VAVAILABILITY
|
29
|
+
END:VCALENDAR
|
30
|
+
VCAL
|
31
|
+
_template(vcal, properties)
|
32
|
+
end
|
33
|
+
|
34
|
+
def template_available(properties)
|
35
|
+
vcal = <<VCAL
|
36
|
+
BEGIN:VCALENDAR
|
37
|
+
VERSION:2.0
|
38
|
+
PRODID:-//id
|
39
|
+
BEGIN:VAVAILABILITY
|
40
|
+
UID:foo@test
|
41
|
+
DTSTAMP:20111005T133225Z
|
42
|
+
BEGIN:AVAILABLE
|
43
|
+
UID:foo@test
|
44
|
+
DTSTAMP:20111005T133225Z
|
45
|
+
DTSTART:20111005T133225Z
|
46
|
+
…
|
47
|
+
END:AVAILABLE
|
48
|
+
END:VAVAILABILITY
|
49
|
+
END:VCALENDAR
|
50
|
+
VCAL
|
51
|
+
|
52
|
+
_template(vcal, properties)
|
53
|
+
end
|
54
|
+
|
55
|
+
def _template(template, properties)
|
56
|
+
template.gsub('…', properties.join("\r\n"))
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_v_availability_component
|
60
|
+
vcal = <<VCAL
|
61
|
+
BEGIN:VCALENDAR
|
62
|
+
BEGIN:VAVAILABILITY
|
63
|
+
END:VAVAILABILITY
|
64
|
+
END:VCALENDAR
|
65
|
+
VCAL
|
66
|
+
document = Tilia::VObject::Reader.read(vcal)
|
67
|
+
|
68
|
+
assert_kind_of(Tilia::VObject::Component::VAvailability, document['VAVAILABILITY'])
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_get_effective_start_end
|
72
|
+
vcal = <<VCAL
|
73
|
+
BEGIN:VCALENDAR
|
74
|
+
BEGIN:VAVAILABILITY
|
75
|
+
DTSTART:20150717T162200Z
|
76
|
+
DTEND:20150717T172200Z
|
77
|
+
END:VAVAILABILITY
|
78
|
+
END:VCALENDAR
|
79
|
+
VCAL
|
80
|
+
|
81
|
+
document = Tilia::VObject::Reader.read(vcal)
|
82
|
+
tz = ActiveSupport::TimeZone.new('UTC')
|
83
|
+
assert_equal(
|
84
|
+
[
|
85
|
+
tz.parse('2015-07-17 16:22:00'),
|
86
|
+
tz.parse('2015-07-17 17:22:00')
|
87
|
+
],
|
88
|
+
document['VAVAILABILITY'].effective_start_end
|
89
|
+
)
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_get_effective_start_duration
|
93
|
+
vcal = <<VCAL
|
94
|
+
BEGIN:VCALENDAR
|
95
|
+
BEGIN:VAVAILABILITY
|
96
|
+
DTSTART:20150717T162200Z
|
97
|
+
DURATION:PT1H
|
98
|
+
END:VAVAILABILITY
|
99
|
+
END:VCALENDAR
|
100
|
+
VCAL
|
101
|
+
|
102
|
+
document = Tilia::VObject::Reader.read(vcal)
|
103
|
+
tz = ActiveSupport::TimeZone.new('UTC')
|
104
|
+
assert_equal(
|
105
|
+
[
|
106
|
+
tz.parse('2015-07-17 16:22:00'),
|
107
|
+
tz.parse('2015-07-17 17:22:00')
|
108
|
+
],
|
109
|
+
document['VAVAILABILITY'].effective_start_end
|
110
|
+
)
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_get_effective_start_end_unbound
|
114
|
+
vcal = <<VCAL
|
115
|
+
BEGIN:VCALENDAR
|
116
|
+
BEGIN:VAVAILABILITY
|
117
|
+
END:VAVAILABILITY
|
118
|
+
END:VCALENDAR
|
119
|
+
VCAL
|
120
|
+
|
121
|
+
document = Tilia::VObject::Reader.read(vcal)
|
122
|
+
assert_equal(
|
123
|
+
[
|
124
|
+
nil,
|
125
|
+
nil
|
126
|
+
],
|
127
|
+
document['VAVAILABILITY'].effective_start_end
|
128
|
+
)
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_is_in_time_range_unbound
|
132
|
+
vcal = <<VCAL
|
133
|
+
BEGIN:VCALENDAR
|
134
|
+
BEGIN:VAVAILABILITY
|
135
|
+
END:VAVAILABILITY
|
136
|
+
END:VCALENDAR
|
137
|
+
VCAL
|
138
|
+
|
139
|
+
document = Tilia::VObject::Reader.read(vcal)
|
140
|
+
assert(document['VAVAILABILITY'].in_time_range?(Time.zone.parse('2015-07-17'), Time.zone.parse('2015-07-18')))
|
141
|
+
end
|
142
|
+
|
143
|
+
def test_is_in_time_range_outside
|
144
|
+
vcal = <<VCAL
|
145
|
+
BEGIN:VCALENDAR
|
146
|
+
BEGIN:VAVAILABILITY
|
147
|
+
DTSTART:20140101T000000Z
|
148
|
+
DTEND:20140102T000000Z
|
149
|
+
END:VAVAILABILITY
|
150
|
+
END:VCALENDAR
|
151
|
+
VCAL
|
152
|
+
|
153
|
+
document = Tilia::VObject::Reader.read(vcal)
|
154
|
+
refute(document['VAVAILABILITY'].in_time_range?(Time.zone.parse('2015-07-17'), Time.zone.parse('2015-07-18')))
|
155
|
+
end
|
156
|
+
|
157
|
+
def test_rf_cxxx_section3_1_availabilityprop_required
|
158
|
+
# UID and DTSTAMP are present.
|
159
|
+
assert_is_valid(Tilia::VObject::Reader.read(
|
160
|
+
<<VCAL
|
161
|
+
BEGIN:VCALENDAR
|
162
|
+
VERSION:2.0
|
163
|
+
PRODID:-//id
|
164
|
+
BEGIN:VAVAILABILITY
|
165
|
+
UID:foo@test
|
166
|
+
DTSTAMP:20111005T133225Z
|
167
|
+
END:VAVAILABILITY
|
168
|
+
END:VCALENDAR
|
169
|
+
VCAL
|
170
|
+
))
|
171
|
+
|
172
|
+
# UID and DTSTAMP are missing.
|
173
|
+
assert_is_not_valid(Tilia::VObject::Reader.read(
|
174
|
+
<<VCAL
|
175
|
+
BEGIN:VCALENDAR
|
176
|
+
VERSION:2.0
|
177
|
+
PRODID:-//id
|
178
|
+
BEGIN:VAVAILABILITY
|
179
|
+
END:VAVAILABILITY
|
180
|
+
END:VCALENDAR
|
181
|
+
VCAL
|
182
|
+
))
|
183
|
+
|
184
|
+
# DTSTAMP is missing.
|
185
|
+
assert_is_not_valid(Tilia::VObject::Reader.read(
|
186
|
+
<<VCAL
|
187
|
+
BEGIN:VCALENDAR
|
188
|
+
VERSION:2.0
|
189
|
+
PRODID:-//id
|
190
|
+
BEGIN:VAVAILABILITY
|
191
|
+
UID:foo@test
|
192
|
+
END:VAVAILABILITY
|
193
|
+
END:VCALENDAR
|
194
|
+
VCAL
|
195
|
+
))
|
196
|
+
|
197
|
+
# UID is missing.
|
198
|
+
assert_is_not_valid(Tilia::VObject::Reader.read(
|
199
|
+
<<VCAL
|
200
|
+
BEGIN:VCALENDAR
|
201
|
+
VERSION:2.0
|
202
|
+
PRODID:-//id
|
203
|
+
BEGIN:VAVAILABILITY
|
204
|
+
DTSTAMP:20111005T133225Z
|
205
|
+
END:VAVAILABILITY
|
206
|
+
END:VCALENDAR
|
207
|
+
VCAL
|
208
|
+
))
|
209
|
+
end
|
210
|
+
|
211
|
+
def test_rf_cxxx_section3_1_availabilityprop_optional_once
|
212
|
+
properties = [
|
213
|
+
'BUSYTYPE:BUSY',
|
214
|
+
'CLASS:PUBLIC',
|
215
|
+
'CREATED:20111005T135125Z',
|
216
|
+
'DESCRIPTION:Long bla bla',
|
217
|
+
'DTSTART:20111005T020000',
|
218
|
+
'LAST-MODIFIED:20111005T135325Z',
|
219
|
+
'ORGANIZER:mailto:foo@example.com',
|
220
|
+
'PRIORITY:1',
|
221
|
+
'SEQUENCE:0',
|
222
|
+
'SUMMARY:Bla bla',
|
223
|
+
'URL:http://example.org/'
|
224
|
+
]
|
225
|
+
|
226
|
+
# They are all present, only once.
|
227
|
+
assert_is_valid(Tilia::VObject::Reader.read(template(properties)))
|
228
|
+
|
229
|
+
# We duplicate each one to see if it fails.
|
230
|
+
properties.each do |property|
|
231
|
+
assert_is_not_valid(Tilia::VObject::Reader.read(template([property, property])))
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
def test_rf_cxxx_section3_1_availabilityprop_dtend_duration
|
236
|
+
# Only DTEND.
|
237
|
+
assert_is_valid(Tilia::VObject::Reader.read(template(['DTEND:21111005T133225Z'])))
|
238
|
+
|
239
|
+
# Only DURATION.
|
240
|
+
assert_is_valid(Tilia::VObject::Reader.read(template(['DURATION:PT1H'])))
|
241
|
+
|
242
|
+
# Both (not allowed).
|
243
|
+
assert_is_not_valid(Tilia::VObject::Reader.read(template(['DTEND:21111005T133225Z', 'DURATION:PT1H'])))
|
244
|
+
end
|
245
|
+
|
246
|
+
def test_available_sub_component
|
247
|
+
vcal = <<VCAL
|
248
|
+
BEGIN:VCALENDAR
|
249
|
+
BEGIN:VAVAILABILITY
|
250
|
+
BEGIN:AVAILABLE
|
251
|
+
END:AVAILABLE
|
252
|
+
END:VAVAILABILITY
|
253
|
+
END:VCALENDAR
|
254
|
+
VCAL
|
255
|
+
document = Tilia::VObject::Reader.read(vcal)
|
256
|
+
|
257
|
+
assert_kind_of(Tilia::VObject::Component, document['VAVAILABILITY']['AVAILABLE'])
|
258
|
+
end
|
259
|
+
|
260
|
+
def test_rf_cxxx_section3_1_availableprop_required
|
261
|
+
# UID, DTSTAMP and DTSTART are present.
|
262
|
+
assert_is_valid(Tilia::VObject::Reader.read(
|
263
|
+
<<VCAL
|
264
|
+
BEGIN:VCALENDAR
|
265
|
+
VERSION:2.0
|
266
|
+
PRODID:-//id
|
267
|
+
BEGIN:VAVAILABILITY
|
268
|
+
UID:foo@test
|
269
|
+
DTSTAMP:20111005T133225Z
|
270
|
+
BEGIN:AVAILABLE
|
271
|
+
UID:foo@test
|
272
|
+
DTSTAMP:20111005T133225Z
|
273
|
+
DTSTART:20111005T133225Z
|
274
|
+
END:AVAILABLE
|
275
|
+
END:VAVAILABILITY
|
276
|
+
END:VCALENDAR
|
277
|
+
VCAL
|
278
|
+
))
|
279
|
+
|
280
|
+
# UID, DTSTAMP and DTSTART are missing.
|
281
|
+
assert_is_not_valid(Tilia::VObject::Reader.read(
|
282
|
+
<<VCAL
|
283
|
+
BEGIN:VCALENDAR
|
284
|
+
VERSION:2.0
|
285
|
+
PRODID:-//id
|
286
|
+
BEGIN:VAVAILABILITY
|
287
|
+
UID:foo@test
|
288
|
+
DTSTAMP:20111005T133225Z
|
289
|
+
BEGIN:AVAILABLE
|
290
|
+
END:AVAILABLE
|
291
|
+
END:VAVAILABILITY
|
292
|
+
END:VCALENDAR
|
293
|
+
VCAL
|
294
|
+
))
|
295
|
+
|
296
|
+
# UID is missing.
|
297
|
+
assert_is_not_valid(Tilia::VObject::Reader.read(
|
298
|
+
<<VCAL
|
299
|
+
BEGIN:VCALENDAR
|
300
|
+
VERSION:2.0
|
301
|
+
PRODID:-//id
|
302
|
+
BEGIN:VAVAILABILITY
|
303
|
+
UID:foo@test
|
304
|
+
DTSTAMP:20111005T133225Z
|
305
|
+
BEGIN:AVAILABLE
|
306
|
+
DTSTAMP:20111005T133225Z
|
307
|
+
DTSTART:20111005T133225Z
|
308
|
+
END:AVAILABLE
|
309
|
+
END:VAVAILABILITY
|
310
|
+
END:VCALENDAR
|
311
|
+
VCAL
|
312
|
+
))
|
313
|
+
|
314
|
+
# DTSTAMP is missing.
|
315
|
+
assert_is_not_valid(Tilia::VObject::Reader.read(
|
316
|
+
<<VCAL
|
317
|
+
BEGIN:VCALENDAR
|
318
|
+
VERSION:2.0
|
319
|
+
PRODID:-//id
|
320
|
+
BEGIN:VAVAILABILITY
|
321
|
+
UID:foo@test
|
322
|
+
DTSTAMP:20111005T133225Z
|
323
|
+
BEGIN:AVAILABLE
|
324
|
+
UID:foo@test
|
325
|
+
DTSTART:20111005T133225Z
|
326
|
+
END:AVAILABLE
|
327
|
+
END:VAVAILABILITY
|
328
|
+
END:VCALENDAR
|
329
|
+
VCAL
|
330
|
+
))
|
331
|
+
|
332
|
+
# DTSTART is missing.
|
333
|
+
assert_is_not_valid(Tilia::VObject::Reader.read(
|
334
|
+
<<VCAL
|
335
|
+
BEGIN:VCALENDAR
|
336
|
+
VERSION:2.0
|
337
|
+
PRODID:-//id
|
338
|
+
BEGIN:VAVAILABILITY
|
339
|
+
UID:foo@test
|
340
|
+
DTSTAMP:20111005T133225Z
|
341
|
+
BEGIN:AVAILABLE
|
342
|
+
UID:foo@test
|
343
|
+
DTSTAMP:20111005T133225Z
|
344
|
+
END:AVAILABLE
|
345
|
+
END:VAVAILABILITY
|
346
|
+
END:VCALENDAR
|
347
|
+
VCAL
|
348
|
+
))
|
349
|
+
end
|
350
|
+
|
351
|
+
def test_rf_cxxx_section3_1_available_dtend_duration
|
352
|
+
# Only DTEND.
|
353
|
+
assert_is_valid(Tilia::VObject::Reader.read(template_available(['DTEND:21111005T133225Z'])))
|
354
|
+
|
355
|
+
# Only DURATION.
|
356
|
+
assert_is_valid(Tilia::VObject::Reader.read(template_available(['DURATION:PT1H'])))
|
357
|
+
|
358
|
+
# Both (not allowed).
|
359
|
+
assert_is_not_valid(Tilia::VObject::Reader.read(template_available(['DTEND:21111005T133225Z', 'DURATION:PT1H'])))
|
360
|
+
end
|
361
|
+
|
362
|
+
def test_rf_cxxx_section3_1_available_optional_once
|
363
|
+
properties = [
|
364
|
+
'CREATED:20111005T135125Z',
|
365
|
+
'DESCRIPTION:Long bla bla',
|
366
|
+
'LAST-MODIFIED:20111005T135325Z',
|
367
|
+
'RECURRENCE-ID;RANGE=THISANDFUTURE:19980401T133000Z',
|
368
|
+
'RRULE:FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR',
|
369
|
+
'SUMMARY:Bla bla'
|
370
|
+
]
|
371
|
+
|
372
|
+
# They are all present, only once.
|
373
|
+
assert_is_valid(Tilia::VObject::Reader.read(template_available(properties)))
|
374
|
+
|
375
|
+
# We duplicate each one to see if it fails.
|
376
|
+
properties.each do |property|
|
377
|
+
assert_is_not_valid(Tilia::VObject::Reader.read(template_available([property, property])))
|
378
|
+
end
|
379
|
+
end
|
380
|
+
|
381
|
+
def test_rf_cxxx_section3_2
|
382
|
+
assert_equal('BUSY', Tilia::VObject::Reader.read(template_available(['BUSYTYPE:BUSY']))['VAVAILABILITY']['AVAILABLE']['BUSYTYPE'].value)
|
383
|
+
assert_equal('BUSY-UNAVAILABLE', Tilia::VObject::Reader.read(template_available(['BUSYTYPE:BUSY-UNAVAILABLE']))['VAVAILABILITY']['AVAILABLE']['BUSYTYPE'].value)
|
384
|
+
assert_equal('BUSY-TENTATIVE', Tilia::VObject::Reader.read(template_available(['BUSYTYPE:BUSY-TENTATIVE']))['VAVAILABILITY']['AVAILABLE']['BUSYTYPE'].value)
|
385
|
+
end
|
386
|
+
end
|
387
|
+
end
|
388
|
+
end
|