one-email_direct 0.6
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.
- data/README.md +9 -0
- data/lib/emaildirect.secure.wsdl +5224 -0
- data/lib/emaildirect.wsdl +5224 -0
- data/lib/one/email_direct/client.rb +11 -0
- data/lib/one/email_direct/credentials.rb +42 -0
- data/lib/one/email_direct/facade.rb +74 -0
- data/lib/one/email_direct/mixins/email.rb +151 -0
- data/lib/one/email_direct/mixins/list.rb +133 -0
- data/lib/one/email_direct/mixins/publication.rb +91 -0
- data/lib/one/email_direct/mixins/source.rb +90 -0
- data/lib/one/email_direct/mixins/template/email/soap11_email_add.rbxml +26 -0
- data/lib/one/email_direct/mixins/template/email/soap11_email_add.rbxml.cache +26 -0
- data/lib/one/email_direct/mixins/template/email/soap11_email_add_with_fields.rbxml +34 -0
- data/lib/one/email_direct/mixins/template/email/soap11_email_add_with_fields.rbxml.cache +34 -0
- data/lib/one/email_direct/mixins/template/email/soap11_email_addwithfields.rbxml.cache +34 -0
- data/lib/one/email_direct/mixins/template/email/soap11_email_delete.rbxml +10 -0
- data/lib/one/email_direct/mixins/template/email/soap11_email_delete.rbxml.cache +10 -0
- data/lib/one/email_direct/mixins/template/email/soap11_email_get_properties.rbxml +9 -0
- data/lib/one/email_direct/mixins/template/email/soap11_email_get_properties.rbxml.cache +9 -0
- data/lib/one/email_direct/mixins/template/email/soap11_email_getproperties.rbxml.cache +9 -0
- data/lib/one/email_direct/mixins/template/list/soap11_list_add.rbxml +10 -0
- data/lib/one/email_direct/mixins/template/list/soap11_list_add.rbxml.cache +10 -0
- data/lib/one/email_direct/mixins/template/list/soap11_list_delete.rbxml +9 -0
- data/lib/one/email_direct/mixins/template/list/soap11_list_delete.rbxml.cache +9 -0
- data/lib/one/email_direct/mixins/template/list/soap11_list_get_all.rbxml +8 -0
- data/lib/one/email_direct/mixins/template/list/soap11_list_get_all.rbxml.cache +8 -0
- data/lib/one/email_direct/mixins/template/list/soap11_list_getall.rbxml.cache +8 -0
- data/lib/one/email_direct/mixins/template/list/soap11_list_getmembers.rbxml +11 -0
- data/lib/one/email_direct/mixins/template/publication/soap11_publication_add.rbxml +10 -0
- data/lib/one/email_direct/mixins/template/publication/soap11_publication_add.rbxml.cache +10 -0
- data/lib/one/email_direct/mixins/template/publication/soap11_publication_delete.rbxml +9 -0
- data/lib/one/email_direct/mixins/template/publication/soap11_publication_delete.rbxml.cache +9 -0
- data/lib/one/email_direct/mixins/template/publication/soap11_publication_get_all.rbxml +7 -0
- data/lib/one/email_direct/mixins/template/publication/soap11_publication_get_all.rbxml.cache +7 -0
- data/lib/one/email_direct/mixins/template/publication/soap11_publication_getall.rbxml.cache +7 -0
- data/lib/one/email_direct/mixins/template/soap11_credentials.rbxml +5 -0
- data/lib/one/email_direct/mixins/template/soap11_credentials.rbxml.cache +5 -0
- data/lib/one/email_direct/mixins/template/soap11_footer.rbxml +2 -0
- data/lib/one/email_direct/mixins/template/soap11_footer.rbxml.cache +2 -0
- data/lib/one/email_direct/mixins/template/soap11_header.rbxml +5 -0
- data/lib/one/email_direct/mixins/template/soap11_header.rbxml.cache +5 -0
- data/lib/one/email_direct/mixins/template/source/soap11_source_add.rbxml +10 -0
- data/lib/one/email_direct/mixins/template/source/soap11_source_add.rbxml.cache +10 -0
- data/lib/one/email_direct/mixins/template/source/soap11_source_delete.rbxml +9 -0
- data/lib/one/email_direct/mixins/template/source/soap11_source_delete.rbxml.cache +9 -0
- data/lib/one/email_direct/mixins/template/source/soap11_source_get_all.rbxml +7 -0
- data/lib/one/email_direct/mixins/template/source/soap11_source_get_all.rbxml.cache +7 -0
- data/lib/one/email_direct/mixins/template/source/soap11_source_getall.rbxml.cache +7 -0
- data/lib/one-email_direct.rb +37 -0
- data/test/unit/one/emaildirect/client_test.rb +49 -0
- data/test/unit/one/emaildirect/credentials_test.rb +36 -0
- data/test/unit/one/emaildirect/email/facade_test.rb +430 -0
- data/test/unit/one/emaildirect/list/facade_test.rb +154 -0
- data/test/unit/one/emaildirect/publication/facade_test.rb +151 -0
- data/test/unit/one/emaildirect/source/facade_test.rb +153 -0
- metadata +175 -0
@@ -0,0 +1,430 @@
|
|
1
|
+
require "#{File.dirname(__FILE__)}/../helpers/requires"
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
class TestEmailFacade < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def setup()
|
8
|
+
|
9
|
+
# preparation to build test resources
|
10
|
+
config = Steenzout::ConfigurationManager.configuration_for_gem :'one-emaildirect'
|
11
|
+
@credentials = One::EmailDirect::Credentials.create_from config
|
12
|
+
|
13
|
+
generator = UUID.new()
|
14
|
+
uuid1 = generator.generate(:compact)
|
15
|
+
uuid2 = generator.generate(:compact)
|
16
|
+
|
17
|
+
@list1 = {:name => "name#{uuid1}", :description => "description#{uuid1}"}
|
18
|
+
@list2 = {:name => "name#{uuid2}", :description => "description#{uuid2}"}
|
19
|
+
|
20
|
+
@publication1 = @list1.clone
|
21
|
+
@publication2 = @list2.clone
|
22
|
+
|
23
|
+
@source1 = @list1.clone
|
24
|
+
@source2 = @list2.clone
|
25
|
+
|
26
|
+
@email1 = 'john.doe.%s@1on1.com' % [uuid1]
|
27
|
+
@email2 = 'john.doe.%s@1on1.com' % [uuid2]
|
28
|
+
@email2 = 'john.doe.%s@1on1.com' % [generator.generate(:compact)]
|
29
|
+
@email3 = 'john.doe.%s@1on1.com' % [generator.generate(:compact)]
|
30
|
+
@email4 = 'john.doe.%s@1on1.com' % [generator.generate(:compact)]
|
31
|
+
@email5 = 'john.doe.%s@1on1.com' % [generator.generate(:compact)]
|
32
|
+
@email6 = 'john.doe.%s@1on1.com' % [generator.generate(:compact)]
|
33
|
+
@email7 = 'john.doe.%s@1on1.com' % [generator.generate(:compact)]
|
34
|
+
|
35
|
+
@autoresponder = 0
|
36
|
+
@force = false
|
37
|
+
|
38
|
+
|
39
|
+
# create test resources
|
40
|
+
One::EmailDirect::Facade.source_add(@credentials, @source1[:name], @source1[:description])
|
41
|
+
One::EmailDirect::Facade.source_add(@credentials, @source2[:name], @source2[:description])
|
42
|
+
One::EmailDirect::Facade.list_add(@credentials, @list1[:name], @list1[:description])
|
43
|
+
One::EmailDirect::Facade.list_add(@credentials, @list2[:name], @list2[:description])
|
44
|
+
One::EmailDirect::Facade.publication_add(@credentials, @publication1[:name], @publication1[:description])
|
45
|
+
One::EmailDirect::Facade.publication_add(@credentials, @publication2[:name], @publication2[:description])
|
46
|
+
|
47
|
+
@source1 = One::EmailDirect::Facade.source_get(@credentials, @source1[:name])
|
48
|
+
@source2 = One::EmailDirect::Facade.source_get(@credentials, @source2[:name])
|
49
|
+
|
50
|
+
@list1 = One::EmailDirect::Facade.list_get(@credentials, @list1[:name])
|
51
|
+
@list2 = One::EmailDirect::Facade.list_get(@credentials, @list2[:name])
|
52
|
+
|
53
|
+
@publication1 = One::EmailDirect::Facade.publication_get(@credentials, @publication1[:name])
|
54
|
+
@publication2 = One::EmailDirect::Facade.publication_get(@credentials, @publication2[:name])
|
55
|
+
|
56
|
+
@custom_fields1 = {
|
57
|
+
'FirstName' => 'John',
|
58
|
+
'LastName' => 'Doe',
|
59
|
+
'Age' => 30
|
60
|
+
}
|
61
|
+
@custom_fields2 = {
|
62
|
+
'FirstName' => 'Johny',
|
63
|
+
'LastName' => 'Doey',
|
64
|
+
'Age' => 31
|
65
|
+
}
|
66
|
+
|
67
|
+
@expected_custom_fields1 = [
|
68
|
+
{:value => 'John', :field_name => 'FirstName'},
|
69
|
+
{:value => 'Doe', :field_name => 'LastName'},
|
70
|
+
{:value => '30', :field_name => 'Age'}
|
71
|
+
]
|
72
|
+
@expected_custom_fields2 = [
|
73
|
+
{:value => 'Johny', :field_name => 'FirstName'},
|
74
|
+
{:value => 'Doey', :field_name => 'LastName'},
|
75
|
+
{:value => '31', :field_name => 'Age'}
|
76
|
+
]
|
77
|
+
end
|
78
|
+
|
79
|
+
def teardown()
|
80
|
+
One::EmailDirect::Facade.list_getall(@credentials).each {|element|
|
81
|
+
One::EmailDirect::Facade.list_delete(@credentials, element[:element_id])
|
82
|
+
}
|
83
|
+
One::EmailDirect::Facade.publication_getall(@credentials).each {|element|
|
84
|
+
One::EmailDirect::Facade.publication_delete(@credentials, element[:element_id])
|
85
|
+
}
|
86
|
+
One::EmailDirect::Facade.source_getall(@credentials).each {|element|
|
87
|
+
One::EmailDirect::Facade.source_delete(@credentials, element[:element_id])
|
88
|
+
}
|
89
|
+
[@email1, @email2, @email3, @email4, @email5, @email6, @email7].each {|email|
|
90
|
+
One::EmailDirect::Facade.email_delete(@credentials, email, false) rescue nil
|
91
|
+
}
|
92
|
+
end
|
93
|
+
|
94
|
+
# Tests for One::EmailDirect::Facade.email_add.
|
95
|
+
#
|
96
|
+
# 1. create a new email
|
97
|
+
# 1.1 specifying all parameters (one list and one publication)
|
98
|
+
# 1.2 specifying all parameters (two lists and two publication)
|
99
|
+
# 1.3 with no force parameter
|
100
|
+
# 1.4 with no list
|
101
|
+
# 1.5 with no list and publications
|
102
|
+
# 1.6 with no email
|
103
|
+
# 1.7 using a previously inserted email
|
104
|
+
#
|
105
|
+
def test_email_add()
|
106
|
+
# 1.1
|
107
|
+
assert_nil One::EmailDirect::Facade.email_add(
|
108
|
+
@credentials, @email1,
|
109
|
+
@source1[:element_id], [@publication1[:element_id]], [@list1[:element_id]],
|
110
|
+
@autoresponder, @force
|
111
|
+
)
|
112
|
+
|
113
|
+
|
114
|
+
# 1.2
|
115
|
+
assert_nil One::EmailDirect::Facade.email_add(
|
116
|
+
@credentials, @email2,
|
117
|
+
@source1[:element_id], [@publication1[:element_id], @publication2[:element_id]], [@list1[:element_id], @list2[:element_id]],
|
118
|
+
@autoresponder, @force
|
119
|
+
)
|
120
|
+
|
121
|
+
|
122
|
+
# 1.3
|
123
|
+
assert_nil One::EmailDirect::Facade.email_add(
|
124
|
+
@credentials, @email3,
|
125
|
+
@source1[:element_id], [@publication1[:element_id]], [@list1[:element_id]],
|
126
|
+
@autoresponder
|
127
|
+
)
|
128
|
+
|
129
|
+
|
130
|
+
# 1.4
|
131
|
+
assert_nil One::EmailDirect::Facade.email_add(
|
132
|
+
@credentials, @email4,
|
133
|
+
@source1[:element_id], [@publication1[:element_id]], [],
|
134
|
+
@autoresponder, @force
|
135
|
+
)
|
136
|
+
assert_nil One::EmailDirect::Facade.email_add(
|
137
|
+
@credentials, @email5,
|
138
|
+
@source1[:element_id], [@publication1[:element_id]], nil,
|
139
|
+
@autoresponder, @force
|
140
|
+
)
|
141
|
+
|
142
|
+
|
143
|
+
# 1.5
|
144
|
+
assert_nil One::EmailDirect::Facade.email_add(
|
145
|
+
@credentials, @email6,
|
146
|
+
@source1[:element_id], [], [@list1[:element_id]],
|
147
|
+
@autoresponder, @force
|
148
|
+
)
|
149
|
+
assert_nil One::EmailDirect::Facade.email_add(
|
150
|
+
@credentials, @email7,
|
151
|
+
@source1[:element_id], nil, [@list1[:element_id]],
|
152
|
+
@autoresponder, @force
|
153
|
+
)
|
154
|
+
|
155
|
+
|
156
|
+
# 1.6
|
157
|
+
assert_raises StandardError do
|
158
|
+
One::EmailDirect::Facade.email_add(
|
159
|
+
@credentials, nil,
|
160
|
+
@source1[:element_id], [@publication1[:element_id]], [@list1[:element_id]],
|
161
|
+
@autoresponder
|
162
|
+
)
|
163
|
+
end
|
164
|
+
|
165
|
+
|
166
|
+
# 1.7
|
167
|
+
assert_nil One::EmailDirect::Facade.email_add(
|
168
|
+
@credentials, @email1,
|
169
|
+
@source1[:element_id], [@publication1[:element_id]], [@list1[:element_id]],
|
170
|
+
@autoresponder, @force
|
171
|
+
)
|
172
|
+
end
|
173
|
+
|
174
|
+
def clean_email_getproperties(result)
|
175
|
+
result.delete(:create_date)
|
176
|
+
result.delete(:date_stamp)
|
177
|
+
result.delete(:ip_address)
|
178
|
+
result.delete(:email_id)
|
179
|
+
cleaned_custom_fields = []
|
180
|
+
result[:custom_fields][:custom_field].each { |element|
|
181
|
+
cleaned_custom_fields << element if !element[:field_name].eql? 'DateStamp' and !element[:field_name].eql? 'IPAddress'
|
182
|
+
}
|
183
|
+
result[:custom_fields][:custom_field] = cleaned_custom_fields
|
184
|
+
return result
|
185
|
+
end
|
186
|
+
|
187
|
+
|
188
|
+
# Tests for One::EmailDirect::Facade.email_add_with_fields.
|
189
|
+
#
|
190
|
+
# 1. create a new email
|
191
|
+
# 1.1 specifying all parameters (one list and one publication)
|
192
|
+
# 1.2 specifying all parameters (two lists and two publication)
|
193
|
+
# 1.3 with no list
|
194
|
+
# 1.4 with no publications
|
195
|
+
# 1.5 with no email
|
196
|
+
# 1.6 using a previously inserted email
|
197
|
+
#
|
198
|
+
def test_email_addwithfields()
|
199
|
+
# 1.1
|
200
|
+
assert_nil One::EmailDirect::Facade.email_addwithfields(
|
201
|
+
@credentials, @email1,
|
202
|
+
@source1[:element_id],
|
203
|
+
[@publication1[:element_id]], [@list1[:element_id]],
|
204
|
+
@autoresponder, @force,
|
205
|
+
@custom_fields1
|
206
|
+
)
|
207
|
+
|
208
|
+
result = clean_email_getproperties(
|
209
|
+
One::EmailDirect::Facade.email_getproperties(
|
210
|
+
@credentials, @email1
|
211
|
+
)
|
212
|
+
)
|
213
|
+
expected = {
|
214
|
+
:status => 'Active',
|
215
|
+
:publications => {:element => [@publication1]},
|
216
|
+
:lists => {:element => [@list1]},
|
217
|
+
:email => @email1,
|
218
|
+
:custom_fields => {:custom_field => @expected_custom_fields1},
|
219
|
+
:source => @source1
|
220
|
+
}
|
221
|
+
expected[:custom_fields][:custom_field] = [{:value => @email1, :field_name => 'Email'}] + expected[:custom_fields][:custom_field]
|
222
|
+
assert_equal expected, result
|
223
|
+
|
224
|
+
|
225
|
+
# 1.2
|
226
|
+
assert_nil One::EmailDirect::Facade.email_addwithfields(
|
227
|
+
@credentials, @email2,
|
228
|
+
@source1[:element_id],
|
229
|
+
[@publication1[:element_id], @publication2[:element_id]],
|
230
|
+
[@list1[:element_id], @list2[:element_id]],
|
231
|
+
@autoresponder, @force,
|
232
|
+
@custom_fields1
|
233
|
+
)
|
234
|
+
|
235
|
+
result = clean_email_getproperties(
|
236
|
+
One::EmailDirect::Facade.email_getproperties(
|
237
|
+
@credentials, @email2
|
238
|
+
)
|
239
|
+
)
|
240
|
+
expected = {
|
241
|
+
:status => 'Active',
|
242
|
+
:publications => {:element => [@publication1, @publication2]},
|
243
|
+
:lists => {:element => [@list1, @list2]},
|
244
|
+
:email => @email2,
|
245
|
+
:custom_fields => {:custom_field => @expected_custom_fields1},
|
246
|
+
:source => @source1
|
247
|
+
}
|
248
|
+
expected[:custom_fields][:custom_field] = [{:value => @email2, :field_name => 'Email'}] + expected[:custom_fields][:custom_field]
|
249
|
+
assert_equal expected, result
|
250
|
+
|
251
|
+
|
252
|
+
# 1.3.1
|
253
|
+
assert_nil One::EmailDirect::Facade.email_addwithfields(
|
254
|
+
@credentials, @email3,
|
255
|
+
@source1[:element_id],
|
256
|
+
[@publication1[:element_id]], [],
|
257
|
+
@autoresponder, @force,
|
258
|
+
@custom_fields1
|
259
|
+
)
|
260
|
+
|
261
|
+
result = clean_email_getproperties(
|
262
|
+
One::EmailDirect::Facade.email_getproperties(
|
263
|
+
@credentials, @email3
|
264
|
+
)
|
265
|
+
)
|
266
|
+
expected = {
|
267
|
+
:status => 'Active',
|
268
|
+
:publications => {:element => [@publication1]},
|
269
|
+
:lists => {:element => []},
|
270
|
+
:email => @email3,
|
271
|
+
:custom_fields => {:custom_field => @expected_custom_fields1},
|
272
|
+
:source => @source1
|
273
|
+
}
|
274
|
+
expected[:custom_fields][:custom_field] = [{:value => @email3, :field_name => 'Email'}] + expected[:custom_fields][:custom_field]
|
275
|
+
assert_equal expected, result
|
276
|
+
|
277
|
+
|
278
|
+
# 1.3.2
|
279
|
+
assert_nil One::EmailDirect::Facade.email_addwithfields(
|
280
|
+
@credentials, @email4,
|
281
|
+
@source1[:element_id], [@publication1[:element_id]], nil,
|
282
|
+
@autoresponder, @force,
|
283
|
+
@custom_fields1
|
284
|
+
)
|
285
|
+
|
286
|
+
result = clean_email_getproperties(
|
287
|
+
One::EmailDirect::Facade.email_getproperties(
|
288
|
+
@credentials, @email4
|
289
|
+
)
|
290
|
+
)
|
291
|
+
expected = {
|
292
|
+
:status => 'Active',
|
293
|
+
:publications => {:element => [@publication1]},
|
294
|
+
:lists => {:element => []},
|
295
|
+
:email => @email4,
|
296
|
+
:custom_fields => {:custom_field => @expected_custom_fields1},
|
297
|
+
:source => @source1
|
298
|
+
}
|
299
|
+
expected[:custom_fields][:custom_field] = [{:value => @email4, :field_name => 'Email'}] + expected[:custom_fields][:custom_field]
|
300
|
+
assert_equal expected, result
|
301
|
+
|
302
|
+
|
303
|
+
# 1.4.1
|
304
|
+
assert_nil One::EmailDirect::Facade.email_addwithfields(
|
305
|
+
@credentials, @email5,
|
306
|
+
@source1[:element_id], [], [@list1[:element_id]],
|
307
|
+
@autoresponder, @force,
|
308
|
+
@custom_fields1
|
309
|
+
)
|
310
|
+
|
311
|
+
result = clean_email_getproperties(
|
312
|
+
One::EmailDirect::Facade.email_getproperties(
|
313
|
+
@credentials, @email5
|
314
|
+
)
|
315
|
+
)
|
316
|
+
expected = {
|
317
|
+
:status => 'Active',
|
318
|
+
:publications => {:element => []},
|
319
|
+
:lists => {:element => [@list1]},
|
320
|
+
:email => @email5,
|
321
|
+
:custom_fields => {:custom_field => @expected_custom_fields1},
|
322
|
+
:source => @source1
|
323
|
+
}
|
324
|
+
expected[:custom_fields][:custom_field] = [{:value => @email5, :field_name => 'Email'}] + expected[:custom_fields][:custom_field]
|
325
|
+
assert_equal expected, result
|
326
|
+
|
327
|
+
|
328
|
+
# 1.4.2
|
329
|
+
assert_nil One::EmailDirect::Facade.email_addwithfields(
|
330
|
+
@credentials, @email6,
|
331
|
+
@source1[:element_id], nil, [@list1[:element_id]],
|
332
|
+
@autoresponder, @force,
|
333
|
+
@custom_fields1
|
334
|
+
)
|
335
|
+
|
336
|
+
result = clean_email_getproperties(
|
337
|
+
One::EmailDirect::Facade.email_getproperties(
|
338
|
+
@credentials, @email6
|
339
|
+
)
|
340
|
+
)
|
341
|
+
expected = {
|
342
|
+
:status => 'Active',
|
343
|
+
:publications => {:element => []},
|
344
|
+
:lists => {:element => [@list1]},
|
345
|
+
:email => @email6,
|
346
|
+
:custom_fields => {:custom_field => @expected_custom_fields1},
|
347
|
+
:source => @source1
|
348
|
+
}
|
349
|
+
expected[:custom_fields][:custom_field] = [{:value => @email6, :field_name => 'Email'}] + expected[:custom_fields][:custom_field]
|
350
|
+
assert_equal expected, result
|
351
|
+
|
352
|
+
|
353
|
+
# 1.5
|
354
|
+
assert_raises StandardError do
|
355
|
+
One::EmailDirect::Facade.email_addwithfields(
|
356
|
+
@credentials, nil,
|
357
|
+
@source1[:element_id], [@publication1[:element_id]], [@list1[:element_id]],
|
358
|
+
@autoresponder, @force,
|
359
|
+
@custom_fields1
|
360
|
+
)
|
361
|
+
end
|
362
|
+
|
363
|
+
|
364
|
+
# 1.6.1 using the exact same lists and publications
|
365
|
+
assert_nil One::EmailDirect::Facade.email_addwithfields(
|
366
|
+
@credentials, @email1,
|
367
|
+
@source1[:element_id], [@publication1[:element_id]], [@list1[:element_id]],
|
368
|
+
@autoresponder, @force,
|
369
|
+
@custom_fields1
|
370
|
+
)
|
371
|
+
|
372
|
+
result = clean_email_getproperties(
|
373
|
+
One::EmailDirect::Facade.email_getproperties(
|
374
|
+
@credentials, @email1
|
375
|
+
)
|
376
|
+
)
|
377
|
+
expected = {
|
378
|
+
:status => 'Active',
|
379
|
+
:publications => {:element => [@publication1]},
|
380
|
+
:lists => {:element => [@list1]},
|
381
|
+
:email => @email1,
|
382
|
+
:custom_fields => {:custom_field => @expected_custom_fields1},
|
383
|
+
:source => @source1
|
384
|
+
}
|
385
|
+
expected[:custom_fields][:custom_field] = [{:value => @email1, :field_name => 'Email'}] + expected[:custom_fields][:custom_field]
|
386
|
+
assert_equal expected, result
|
387
|
+
|
388
|
+
|
389
|
+
# 1.6.2 using different lists, publications and custom fields
|
390
|
+
assert_nil One::EmailDirect::Facade.email_addwithfields(
|
391
|
+
@credentials, @email1,
|
392
|
+
@source1[:element_id], [@publication2[:element_id]], [@list2[:element_id]],
|
393
|
+
@autoresponder, @force,
|
394
|
+
@custom_fields2
|
395
|
+
)
|
396
|
+
|
397
|
+
result = clean_email_getproperties(
|
398
|
+
One::EmailDirect::Facade.email_getproperties(
|
399
|
+
@credentials, @email1
|
400
|
+
)
|
401
|
+
)
|
402
|
+
expected = {
|
403
|
+
:status => 'Active',
|
404
|
+
:publications => {:element => [@publication1, @publication2]},
|
405
|
+
:lists => {:element => [@list1, @list2]},
|
406
|
+
:email => @email1,
|
407
|
+
:custom_fields => {:custom_field => @expected_custom_fields2},
|
408
|
+
:source => @source1
|
409
|
+
}
|
410
|
+
expected[:custom_fields][:custom_field] = [{:value => @email1, :field_name => 'Email'}] + expected[:custom_fields][:custom_field]
|
411
|
+
assert_equal expected, result
|
412
|
+
end
|
413
|
+
|
414
|
+
|
415
|
+
|
416
|
+
# Tests for One::EmailDirect::Facade.email_getproperties.
|
417
|
+
#
|
418
|
+
# 1. use an email not registered in the account
|
419
|
+
#
|
420
|
+
def test_email_getproperties()
|
421
|
+
|
422
|
+
# 1.
|
423
|
+
assert_raises Savon::SOAP::Fault do
|
424
|
+
One::EmailDirect::Facade.email_getproperties(
|
425
|
+
@credentials, @email7
|
426
|
+
)
|
427
|
+
end
|
428
|
+
end
|
429
|
+
|
430
|
+
end
|
@@ -0,0 +1,154 @@
|
|
1
|
+
require "#{File.dirname(__FILE__)}/../helpers/requires"
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
class TestListFacade < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def setup()
|
8
|
+
config = Steenzout::ConfigurationManager.configuration_for_gem :'one-emaildirect'
|
9
|
+
@credentials = One::EmailDirect::Credentials.create_from config
|
10
|
+
|
11
|
+
generator = UUID.new()
|
12
|
+
|
13
|
+
uuid1 = generator.generate(:compact)
|
14
|
+
@list_add = {:name => "name#{uuid1}", :description => "description#{uuid1}"}
|
15
|
+
|
16
|
+
|
17
|
+
uuid2 = generator.generate(:compact)
|
18
|
+
@list_getall1 = {:name => "name#{uuid2}", :description => "description#{uuid2}"}
|
19
|
+
|
20
|
+
uuid3 = generator.generate(:compact)
|
21
|
+
@list_getall2 = {:name => "name#{uuid3}", :description => "description#{uuid3}"}
|
22
|
+
|
23
|
+
uuid4 = generator.generate(:compact)
|
24
|
+
@list_getall3 = {:name => "name#{uuid4}", :description => "description#{uuid4}"}
|
25
|
+
|
26
|
+
|
27
|
+
uuid5 = generator.generate(:compact)
|
28
|
+
@list_get = {:name => "name#{uuid5}", :description => "description#{uuid5}"}
|
29
|
+
end
|
30
|
+
|
31
|
+
def teardown()
|
32
|
+
One::EmailDirect::Facade.list_getall(@credentials).each {|element|
|
33
|
+
One::EmailDirect::Facade.list_delete(@credentials, element[:element_id])
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
def get_single_list(list_name)
|
38
|
+
One::EmailDirect::Facade.list_getall(@credentials).each {|element|
|
39
|
+
return element if element[:element_name] == list_name
|
40
|
+
}
|
41
|
+
nil
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
# Tests for One::EmailDirect::Facade.list_add.
|
46
|
+
#
|
47
|
+
# 1. create a new list
|
48
|
+
# 2. create a new list with a previously used name
|
49
|
+
#
|
50
|
+
def test_list_add()
|
51
|
+
# 1. create a new list
|
52
|
+
One::EmailDirect::Facade.list_add(@credentials, @list_add[:name], @list_add[:description])
|
53
|
+
result = get_single_list(@list_add[:name])
|
54
|
+
expected = {
|
55
|
+
:element_name => @list_add[:name],
|
56
|
+
:description => @list_add[:description]
|
57
|
+
}
|
58
|
+
|
59
|
+
assert_not_nil result
|
60
|
+
result.delete(:element_id)
|
61
|
+
assert_equal expected, result
|
62
|
+
|
63
|
+
|
64
|
+
# 2. create a new list with a previously used name
|
65
|
+
assert_raises StandardError do
|
66
|
+
One::EmailDirect::Facade.list_add(@credentials, @list_add[:name], @list_add[:description])
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
# Tests for One::EmailDirect::Facade.list_get.
|
73
|
+
#
|
74
|
+
# 1. using an existing list
|
75
|
+
# 2. using an inexistent list
|
76
|
+
#
|
77
|
+
def test_list_get()
|
78
|
+
One::EmailDirect::Facade.list_add(@credentials, @list_get[:name], @list_get[:description])
|
79
|
+
|
80
|
+
|
81
|
+
# 1.
|
82
|
+
result = One::EmailDirect::Facade.list_get(@credentials, @list_get[:name])
|
83
|
+
assert result.has_key? :element_id
|
84
|
+
assert result.has_key? :element_name
|
85
|
+
assert result.has_key? :description
|
86
|
+
result.delete(:element_id)
|
87
|
+
expected = {
|
88
|
+
:element_name => @list_get[:name],
|
89
|
+
:description => @list_get[:description]
|
90
|
+
}
|
91
|
+
assert_equal expected, result
|
92
|
+
|
93
|
+
|
94
|
+
# 2.
|
95
|
+
assert_nil One::EmailDirect::Facade.list_get(@credentials, 'inexistent')
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
# Tests for One::EmailDirect::Facade.list_getall.
|
101
|
+
#
|
102
|
+
# 1. no lists
|
103
|
+
# 2. one list
|
104
|
+
# 3. two lists
|
105
|
+
# 4. three lists
|
106
|
+
#
|
107
|
+
def test_list_getall()
|
108
|
+
# 1. no lists
|
109
|
+
assert_equal [], One::EmailDirect::Facade.list_getall(@credentials)
|
110
|
+
|
111
|
+
|
112
|
+
# 2. one list
|
113
|
+
One::EmailDirect::Facade.list_add(@credentials, @list_getall1[:name], @list_getall1[:description])
|
114
|
+
result = One::EmailDirect::Facade.list_getall(@credentials)
|
115
|
+
expected = [{
|
116
|
+
:element_name => @list_getall1[:name],
|
117
|
+
:description => @list_getall1[:description]
|
118
|
+
}]
|
119
|
+
result.collect! {|element| element.delete(:element_id); element} # remove ids
|
120
|
+
assert_equal expected, result
|
121
|
+
|
122
|
+
|
123
|
+
# 3. two lists
|
124
|
+
One::EmailDirect::Facade.list_add(@credentials, @list_getall2[:name], @list_getall2[:description])
|
125
|
+
result = One::EmailDirect::Facade.list_getall(@credentials)
|
126
|
+
expected = [{
|
127
|
+
:element_name => @list_getall1[:name],
|
128
|
+
:description => @list_getall1[:description]
|
129
|
+
}, {
|
130
|
+
:element_name => @list_getall2[:name],
|
131
|
+
:description => @list_getall2[:description]
|
132
|
+
}]
|
133
|
+
result.collect! {|element| element.delete(:element_id); element} # remove ids
|
134
|
+
assert_equal expected, result
|
135
|
+
|
136
|
+
|
137
|
+
# 4. three lists
|
138
|
+
One::EmailDirect::Facade.list_add(@credentials, @list_getall3[:name], @list_getall3[:description])
|
139
|
+
result = One::EmailDirect::Facade.list_getall(@credentials)
|
140
|
+
expected = [{
|
141
|
+
:element_name => @list_getall1[:name],
|
142
|
+
:description => @list_getall1[:description]
|
143
|
+
}, {
|
144
|
+
:element_name => @list_getall2[:name],
|
145
|
+
:description => @list_getall2[:description]
|
146
|
+
}, {
|
147
|
+
:element_name => @list_getall3[:name],
|
148
|
+
:description => @list_getall3[:description]
|
149
|
+
}]
|
150
|
+
result.collect! {|element| element.delete(:element_id); element} # remove ids
|
151
|
+
assert_equal expected, result
|
152
|
+
end
|
153
|
+
|
154
|
+
end
|