expresspigeon-ruby 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,55 +6,55 @@ describe 'campaigns integration test' do
6
6
  include PigeonSpecHelper
7
7
 
8
8
  it 'should return more than 0 campaign ids' do
9
- res = PIGEON.campaigns.all
9
+ res = ExpressPigeon::API.campaigns.all
10
10
  res.class.should == Array
11
11
  res.size.should > 0
12
12
  end
13
13
 
14
14
  it 'cannot send with missing parameters' do
15
- res = PIGEON.campaigns.send(:template_id => 15233, :name => 'API Test campaign',
16
- :from_name => 'Igor Polevoy', :reply_to => 'igor@polevoy.org',
17
- :subject => 'API test', :google_analytics => true)
15
+ res = ExpressPigeon::API.campaigns.send(:template_id => 15233, :name => 'API Test campaign',
16
+ :from_name => 'Igor Polevoy', :reply_to => 'igor@polevoy.org',
17
+ :subject => 'API test', :google_analytics => true)
18
18
  validate_response res, 400, 'error', /required parameters: list_id, template_id, name, from_name, reply_to, subject, google_analytics/
19
19
  end
20
20
 
21
21
  it 'cannot send with bad reply_to' do
22
- res = PIGEON.campaigns.send(:list_id => -1, :template_id => -1, :name => 'My Campaign', :from_name => 'John', :reply_to => 'j',
23
- :subject => 'Hi', :google_analytics => false)
22
+ res = ExpressPigeon::API.campaigns.send(:list_id => -1, :template_id => -1, :name => 'My Campaign', :from_name => 'John', :reply_to => 'j',
23
+ :subject => 'Hi', :google_analytics => false)
24
24
  validate_response res, 400, 'error', /reply_to should be valid email address/
25
25
  end
26
26
 
27
27
  it 'cannot send with non-existing template' do
28
- res = PIGEON.campaigns.send(:list_id => -1, :template_id => -1, :name => 'My Campaign', :from_name => 'John',
29
- :reply_to => 'j@j.j',
30
- :subject => 'Hi', :google_analytics => false)
28
+ res = ExpressPigeon::API.campaigns.send(:list_id => -1, :template_id => -1, :name => 'My Campaign', :from_name => 'John',
29
+ :reply_to => 'j@j.j',
30
+ :subject => 'Hi', :google_analytics => false)
31
31
  validate_response res, 400, 'error', /template=-1 is not found/
32
32
  end
33
33
 
34
34
  it 'cannot send to non-existing list' do
35
- res = PIGEON.campaigns.send(:list_id => -1, :template_id => TEMPLATE_ID, :name => 'My Campaign', :from_name => 'John',
36
- :reply_to => 'j@j.j',
37
- :subject => 'Hi', :google_analytics => false)
35
+ res = ExpressPigeon::API.campaigns.send(:list_id => -1, :template_id => TEMPLATE_ID, :name => 'My Campaign', :from_name => 'John',
36
+ :reply_to => 'j@j.j',
37
+ :subject => 'Hi', :google_analytics => false)
38
38
  validate_response res, 400, 'error', /list=-1 is not found/
39
39
  end
40
40
 
41
41
  it 'cannot send to disabled list' do
42
- res = PIGEON.campaigns.send(:list_id => LIST_ID, :template_id => TEMPLATE_ID, :name => 'My Campaign', :from_name => 'John',
43
- :reply_to => 'j@j.j',
44
- :subject => 'Hi', :google_analytics => false)
42
+ res = ExpressPigeon::API.campaigns.send(:list_id => LIST_ID, :template_id => TEMPLATE_ID, :name => 'My Campaign', :from_name => 'John',
43
+ :reply_to => 'j@j.j',
44
+ :subject => 'Hi', :google_analytics => false)
45
45
  validate_response res, 400, 'error', /list=#{DISABLED_LIST} is disabled/
46
46
  end
47
47
 
48
48
  it 'should create new list, add contact and send successful campaign' do
49
49
 
50
- list_resp = PIGEON.lists.create('My list', 'John', API_USER)
50
+ list_resp = ExpressPigeon::API.lists.create('My list', 'John', API_USER)
51
51
  list_id = list_resp.list.id
52
- PIGEON.contacts.upsert(list_id, {:email => API_USER})
53
- resp = PIGEON.campaigns.send(:list_id => list_id, :template_id => TEMPLATE_ID, :name => 'My Campaign', :from_name => 'John',
54
- :reply_to => API_USER,
55
- :subject => 'Hi', :google_analytics => false)
52
+ ExpressPigeon::API.contacts.upsert(list_id, {:email => API_USER})
53
+ resp = ExpressPigeon::API.campaigns.send(:list_id => list_id, :template_id => TEMPLATE_ID, :name => 'My Campaign', :from_name => 'John',
54
+ :reply_to => API_USER,
55
+ :subject => 'Hi', :google_analytics => false)
56
56
  validate_response resp, 200, 'success', /new campaign created successfully/
57
- report = PIGEON.campaigns.report(resp.campaign_id)
57
+ report = ExpressPigeon::API.campaigns.report(resp.campaign_id)
58
58
  (report.delivered == 0 or report.delivered == 1).should be_true
59
59
  report.clicked.should eq 0
60
60
  report.opened.should eq 0
@@ -62,45 +62,45 @@ describe 'campaigns integration test' do
62
62
  (report.in_transit == 0 or report.in_transit == 1).should be_true
63
63
  report.unsubscribed.should eq 0
64
64
  report.bounced.should eq 0
65
- bounced = PIGEON.campaigns.bounced(resp.campaign_id)
66
- unsubscribed = PIGEON.campaigns.unsubscribed(resp.campaign_id)
67
- spam = PIGEON.campaigns.spam(resp.campaign_id)
65
+ bounced = ExpressPigeon::API.campaigns.bounced(resp.campaign_id)
66
+ unsubscribed = ExpressPigeon::API.campaigns.unsubscribed(resp.campaign_id)
67
+ spam = ExpressPigeon::API.campaigns.spam(resp.campaign_id)
68
68
 
69
69
  bounced.size.should eq 0
70
70
  unsubscribed.size.should eq 0
71
71
  spam.size.should eq 0
72
72
 
73
- resp = PIGEON.contacts.delete(API_USER)
73
+ resp = ExpressPigeon::API.contacts.delete(API_USER)
74
74
  validate_response resp, 200, 'success', /contact=non@non.non deleted successfully/
75
75
 
76
- resp = PIGEON.contacts.find_by_email(API_USER)
76
+ resp = ExpressPigeon::API.contacts.find_by_email(API_USER)
77
77
  validate_response resp, 404, 'error', /contact=non@non.non not found/
78
78
 
79
- resp = PIGEON.lists.delete(list_id)
79
+ resp = ExpressPigeon::API.lists.delete(list_id)
80
80
  validate_response resp, 200, 'success', /deleted successfully/
81
81
  end
82
82
 
83
83
 
84
84
  it 'cannot send campaign if scheduling with bad date' do
85
85
 
86
- list_resp = PIGEON.lists.create "My list", "John", API_USER
87
- resp = PIGEON.campaigns.schedule :list_id => list_resp.list.id, :template_id => TEMPLATE_ID, :name => 'My Campaign',
86
+ list_resp = ExpressPigeon::API.lists.create "My list", "John", API_USER
87
+ resp = ExpressPigeon::API.campaigns.schedule :list_id => list_resp.list.id, :template_id => TEMPLATE_ID, :name => 'My Campaign',
88
88
 
89
- :from_name => 'John',
90
- :reply_to => API_USER, :subject => 'Hi',
91
- :google_analytics => false, :schedule_for => "2013-05-28"
89
+ :from_name => 'John',
90
+ :reply_to => API_USER, :subject => 'Hi',
91
+ :google_analytics => false, :schedule_for => "2013-05-28"
92
92
 
93
93
  validate_response resp, 400, 'error', /schedule_for is not in ISO date format, example: 2013-05-28T17:19:50.779/
94
- resp = PIGEON.lists.delete(list_resp.list.id)
94
+ resp = ExpressPigeon::API.lists.delete(list_resp.list.id)
95
95
  validate_response resp, 200, 'success', /deleted successfully/
96
96
  end
97
97
 
98
98
  it 'should not schedule campaign with date in the past' do
99
- list_resp = PIGEON.lists.create('My list', 'John', API_USER)
100
- resp = PIGEON.campaigns.schedule :list_id => list_resp.list.id, :template_id => TEMPLATE_ID, :name => 'My Campaign',
101
- :from_name => 'John',
102
- :reply_to => API_USER, :subject => 'Hi',
103
- :google_analytics => false, :schedule_for => '2010-05-28T17:19:50.779+0300'
99
+ list_resp = ExpressPigeon::API.lists.create('My list', 'John', API_USER)
100
+ resp = ExpressPigeon::API.campaigns.schedule :list_id => list_resp.list.id, :template_id => TEMPLATE_ID, :name => 'My Campaign',
101
+ :from_name => 'John',
102
+ :reply_to => API_USER, :subject => 'Hi',
103
+ :google_analytics => false, :schedule_for => '2010-05-28T17:19:50.779+0300'
104
104
 
105
105
  validate_response resp, 400, 'error', /schedule_for should be in the future/
106
106
  end
@@ -108,26 +108,48 @@ describe 'campaigns integration test' do
108
108
 
109
109
 
110
110
  it 'should delete scheduled campaign' do
111
- list_resp = PIGEON.lists.create('My list', 'John', API_USER)
112
- resp = PIGEON.campaigns.schedule :list_id => list_resp.list.id, :template_id => TEMPLATE_ID, :name => 'My Campaign',
113
- :from_name => 'John',
114
- :reply_to => API_USER, :subject => 'Hi',
115
- :google_analytics => false, :schedule_for => '2030-05-28T17:19:50.779+0300'
111
+ list_resp = ExpressPigeon::API.lists.create('My list', 'John', API_USER)
112
+ resp = ExpressPigeon::API.campaigns.schedule :list_id => list_resp.list.id, :template_id => TEMPLATE_ID, :name => 'My Campaign',
113
+ :from_name => 'John',
114
+ :reply_to => API_USER, :subject => 'Hi',
115
+ :google_analytics => false, :schedule_for => '2030-05-28T17:19:50.779+0300'
116
116
 
117
117
  validate_response resp, 200, 'success', /new campaign created successfully/
118
118
  campaign_id = resp.campaign_id
119
- resp = PIGEON.campaigns.delete campaign_id
119
+ resp = ExpressPigeon::API.campaigns.delete campaign_id
120
120
  resp.message.should eq "campaign #{campaign_id} was deleted"
121
121
  end
122
122
 
123
123
 
124
124
  # This test uses account ep.api.tester@expresspigeon.com and expects two specific campaign there.
125
125
  it 'should list campaigns from account' do
126
- campaigns = PIGEON.campaigns.all
126
+ campaigns = ExpressPigeon::API.campaigns.all
127
127
  campaigns.size.should eq 4
128
- campaigns = PIGEON.campaigns.all from_id: 53853
128
+ campaigns = ExpressPigeon::API.campaigns.all from_id: 53853
129
129
  campaigns.size.should eq 3
130
130
  end
131
131
 
132
+
133
+ it 'should get opened from campaign' do
134
+ opened = ExpressPigeon::API.campaigns.opened 441663
135
+
136
+ puts opened
137
+
138
+ end
139
+
140
+ it 'should get clicked from campaign' do
141
+ clicked = ExpressPigeon::API.campaigns.clicked 441663
142
+
143
+ puts clicked
144
+
145
+ end
146
+
147
+ it 'should get unsubs from campaign' do
148
+ unsubscribed = ExpressPigeon::API.campaigns.unsubscribed 441663
149
+
150
+ puts unsubscribed
151
+
152
+ end
153
+
132
154
  end
133
155
 
@@ -6,24 +6,24 @@ describe 'contacts integration test' do
6
6
  include PigeonSpecHelper
7
7
 
8
8
  it 'should not create contact without contact data' do
9
- resp = PIGEON.contacts.upsert(-1, {})
9
+ resp = ExpressPigeon::API.contacts.upsert(-1, {})
10
10
  validate_response resp, 400, 'error', /email is required/
11
11
  end
12
12
 
13
13
  it 'should not create contact without email' do
14
- resp = PIGEON.contacts.upsert -1, :email => '', :first_name => 'Marylin', :last_name => 'Monroe'
14
+ resp = ExpressPigeon::API.contacts.upsert -1, :email => '', :first_name => 'Marylin', :last_name => 'Monroe'
15
15
  validate_response resp, 400, 'error', /email is required/
16
16
  end
17
17
 
18
18
  it 'should not add contact with too many custom fields' do
19
19
  custom_fields = {}
20
20
  (1..25).each { |n| custom_fields["custom_field_#{n}"] = n }
21
- resp = PIGEON.contacts.upsert -1, :email => "mary@e.e", :custom_fields => custom_fields
21
+ resp = ExpressPigeon::API.contacts.upsert -1, :email => "mary@e.e", :custom_fields => custom_fields
22
22
  validate_response resp, 400, 'error', /You cannot create more than 20 custom fields. Use one of the 'custom_fields'./
23
23
  end
24
24
 
25
25
  it 'should not create new contact without list_id' do
26
- resp = PIGEON.contacts.upsert '', :email => 'ee@e.e', :first_name => 'Marylin', :last_name => 'Monroe'
26
+ resp = ExpressPigeon::API.contacts.upsert '', :email => 'ee@e.e', :first_name => 'Marylin', :last_name => 'Monroe'
27
27
  # TODO: this is a pretty crappy message from API https://redmine.expresspigeon.com/issues/5479
28
28
  validate_response resp, 400, 'error', /failed to convert: '' to Long/
29
29
  end
@@ -34,21 +34,21 @@ describe 'contacts integration test' do
34
34
  # end
35
35
 
36
36
  it 'cannot upsert into non-existent_list' do
37
- resp = PIGEON.contacts.upsert -123, :email => "e@e.e"
37
+ resp = ExpressPigeon::API.contacts.upsert -123, :email => "e@e.e"
38
38
  # TODO: uncomment after: https://redmine.expresspigeon.com/issues/5478
39
39
  validate_response resp, 404, 'error', /contact=e@e.e not found/
40
40
  end
41
41
 
42
42
  it 'creates list with contacts' do
43
- list_response = PIGEON.lists.create 'My List', 'John Doe', 'john@doe.com'
43
+ list_response = ExpressPigeon::API.lists.create 'My List', 'John Doe', 'john@doe.com'
44
44
  list_id = list_response.list.id
45
- resp = PIGEON.contacts.upsert list_id, email: "mary@e.e",
46
- :custom_fields => {:custom_field_1 => "custom_value_1", }
45
+ resp = ExpressPigeon::API.contacts.upsert list_id, email: "mary@e.e",
46
+ :custom_fields => {:custom_field_1 => "custom_value_1", }
47
47
  validate_response resp, 200, 'success', /contacts created\/updated successfully/
48
48
 
49
- resp = PIGEON.contacts.find_by_email "mary@e.e"
49
+ resp = ExpressPigeon::API.contacts.find_by_email "mary@e.e"
50
50
 
51
- PIGEON.lists.delete(list_id)
51
+ ExpressPigeon::API.lists.delete(list_id)
52
52
 
53
53
  resp.custom_fields.custom_field_1 eq "custom_value_1"
54
54
  resp.email.should eq 'mary@e.e'
@@ -56,16 +56,16 @@ describe 'contacts integration test' do
56
56
  end
57
57
 
58
58
  it 'creates list non-existent custom field' do
59
- list_response = PIGEON.lists.create 'My List', 'John Doe', 'a@a.a'
59
+ list_response = ExpressPigeon::API.lists.create 'My List', 'John Doe', 'a@a.a'
60
60
  list_id = list_response.list.id
61
- resp = PIGEON.contacts.upsert(list_id, {:email => "mary@e.e", :custom_fields => {:c => "c", }})
62
- PIGEON.lists.delete(list_id)
61
+ resp = ExpressPigeon::API.contacts.upsert(list_id, {:email => "mary@e.e", :custom_fields => {:c => "c", }})
62
+ ExpressPigeon::API.lists.delete(list_id)
63
63
  validate_response resp, 200, 'success', nil
64
64
  end
65
65
 
66
66
  it 'cannot export contacts from list without list_id' do
67
67
  content = ''
68
- PIGEON.lists.csv "-1" do |c|
68
+ ExpressPigeon::API.lists.csv "-1" do |c|
69
69
  content << c
70
70
  end
71
71
  resp = JSON.parse(content)
@@ -76,7 +76,7 @@ describe 'contacts integration test' do
76
76
 
77
77
  it 'should get contacts from suppressed list' do
78
78
  content =''
79
- PIGEON.lists.csv "suppress_list" do |c|
79
+ ExpressPigeon::API.lists.csv "suppress_list" do |c|
80
80
  content += c
81
81
  end
82
82
  resp = content.split /\n/
@@ -87,13 +87,13 @@ describe 'contacts integration test' do
87
87
  end
88
88
 
89
89
  it 'should get single contact' do
90
- resp = PIGEON.contacts.find_by_email 'suppressed@e.e'
90
+ resp = ExpressPigeon::API.contacts.find_by_email 'suppressed@e.e'
91
91
  # TODO: have these on account before checking.
92
92
  # resp.email.should eq 'suppressed@e.e'
93
93
  end
94
94
 
95
95
  it 'should not find non existent contact' do
96
- resp = PIGEON.contacts.find_by_email 'a@a.a'
96
+ resp = ExpressPigeon::API.contacts.find_by_email 'a@a.a'
97
97
  # TODO: have these on account before checking.
98
98
 
99
99
  # validate_response resp, 404, 'error', /contact=a@a.a not found/
@@ -103,56 +103,56 @@ describe 'contacts integration test' do
103
103
 
104
104
 
105
105
 
106
- list_response = PIGEON.lists.create('My List', 'John Doe', "a@a.a")
106
+ list_response = ExpressPigeon::API.lists.create('My List', 'John Doe', "a@a.a")
107
107
 
108
108
  # PIGEON.contacts.find_by_email("mary@e.e").last_name.should eq 'Doe'
109
109
 
110
- resp = PIGEON.contacts.upsert list_response.list.id,
111
- :email => 'mary@e.e', :first_name => 'Mary', :last_name => 'Johns'
110
+ resp = ExpressPigeon::API.contacts.upsert list_response.list.id,
111
+ :email => 'mary@e.e', :first_name => 'Mary', :last_name => 'Johns'
112
112
  validate_response resp, 200, 'success', /contacts created\/updated successfully/
113
- PIGEON.contacts.find_by_email("mary@e.e").last_name.should eq 'Johns'
114
- PIGEON.lists.delete list_response.list.id
113
+ ExpressPigeon::API.contacts.find_by_email("mary@e.e").last_name.should eq 'Johns'
114
+ ExpressPigeon::API.lists.delete list_response.list.id
115
115
  end
116
116
 
117
117
  it 'cannot delete contact with non-existent email' do
118
- res = PIGEON.contacts.delete("g@g.g")
118
+ res = ExpressPigeon::API.contacts.delete("g@g.g")
119
119
  validate_response res, 404, 'error', /contact=g@g.g not found/
120
120
  end
121
121
 
122
122
  it 'should not delete suppressed contact' do
123
- res = PIGEON.contacts.delete("suppressed@e.e")
123
+ res = ExpressPigeon::API.contacts.delete("suppressed@e.e")
124
124
 
125
125
  # TODO: add this to the account at setup.
126
126
  # validate_response res, 400, 'error', /contact=suppressed@e.e is in suppress list/
127
127
  end
128
128
 
129
129
  it 'should delete single contact from all lists' do
130
- list_response = PIGEON.lists.create 'My List', 'Jane Doe', 'a@a.a'
131
- PIGEON.contacts.upsert list_response.list.id, :email => 'mary@e.e'
132
- res = PIGEON.contacts.delete 'mary@e.e'
130
+ list_response = ExpressPigeon::API.lists.create 'My List', 'Jane Doe', 'a@a.a'
131
+ ExpressPigeon::API.contacts.upsert list_response.list.id, :email => 'mary@e.e'
132
+ res = ExpressPigeon::API.contacts.delete 'mary@e.e'
133
133
  validate_response res, 200, 'success', /contact=mary@e.e deleted successfully/
134
- PIGEON.lists.delete list_response.list.id
134
+ ExpressPigeon::API.lists.delete list_response.list.id
135
135
  end
136
136
 
137
137
  it 'deletes single contact from single list' do
138
- list_response = PIGEON.lists.create 'My List', 'John D.', 'a@a.a'
139
- list_response_2 = PIGEON.lists.create('My List2', "Jane D.", 'a@a.a')
140
- PIGEON.contacts.upsert(list_response.list.id, {:email => 'mary@e.e'})
141
- PIGEON.contacts.upsert(list_response_2.list.id, {:email => 'mary@e.e'})
138
+ list_response = ExpressPigeon::API.lists.create 'My List', 'John D.', 'a@a.a'
139
+ list_response_2 = ExpressPigeon::API.lists.create('My List2', "Jane D.", 'a@a.a')
140
+ ExpressPigeon::API.contacts.upsert(list_response.list.id, {:email => 'mary@e.e'})
141
+ ExpressPigeon::API.contacts.upsert(list_response_2.list.id, {:email => 'mary@e.e'})
142
142
 
143
- res = PIGEON.contacts.delete 'mary@e.e', list_response.list.id
143
+ res = ExpressPigeon::API.contacts.delete 'mary@e.e', list_response.list.id
144
144
 
145
145
  validate_response res, 200, 'success', /contact=mary@e.e deleted successfully/
146
146
 
147
147
  contacts_exported = ''
148
- PIGEON.lists.csv list_response.list.id do |c|
148
+ ExpressPigeon::API.lists.csv list_response.list.id do |c|
149
149
  contacts_exported << c
150
150
  end
151
151
  contacts_exported = contacts_exported.split /\n/
152
152
  contacts_exported.size.should eq 1
153
153
 
154
154
  contacts_exported_2 = ''
155
- PIGEON.lists.csv list_response_2.list.id do |c|
155
+ ExpressPigeon::API.lists.csv list_response_2.list.id do |c|
156
156
  contacts_exported_2 << c
157
157
  end
158
158
 
@@ -160,9 +160,9 @@ describe 'contacts integration test' do
160
160
  contacts_exported_2.size.should eq 2
161
161
  contacts_exported_2[1].should =~ /"mary@e.e"/
162
162
 
163
- PIGEON.lists.delete(list_response.list.id)
164
- PIGEON.lists.delete(list_response_2.list.id)
165
- PIGEON.contacts.delete('mary@e.e')
163
+ ExpressPigeon::API.lists.delete(list_response.list.id)
164
+ ExpressPigeon::API.lists.delete(list_response_2.list.id)
165
+ ExpressPigeon::API.contacts.delete('mary@e.e')
166
166
  end
167
167
  end
168
168
 
@@ -6,39 +6,39 @@ describe 'lists integration test' do
6
6
  include PigeonSpecHelper
7
7
 
8
8
  it 'test_create_and_delete_new_list(self):' do
9
- contact_list = PIGEON.lists.create 'Active customers', 'Bob', 'bob@acmetools.com'
9
+ contact_list = ExpressPigeon::API.lists.create 'Active customers', 'Bob', 'bob@acmetools.com'
10
10
  validate_response contact_list, 200, 'success', /list=#{contact_list.list.id} created\/updated successfully/
11
11
  contact_list.list.name.should eq "Active customers"
12
12
  contact_list.list.from_name.should eq "Bob"
13
13
  contact_list.list.reply_to.should eq "bob@acmetools.com"
14
14
  contact_list.list.contact_count.should eq 0
15
- res = PIGEON.lists.delete contact_list.list.id
15
+ res = ExpressPigeon::API.lists.delete contact_list.list.id
16
16
  validate_response res, 200, 'success', /list=#{contact_list.list.id} deleted successfully/
17
17
  end
18
18
 
19
19
  it 'should update existing list' do
20
- contact_list = PIGEON.lists.create("Update", "Bob", "bob@acmetools.com")
21
- res = PIGEON.lists.update contact_list.list.id, :name => 'Updated Name', :from_name => 'Bob', :reply_to => 'Frank@zappa.com'
20
+ contact_list = ExpressPigeon::API.lists.create("Update", "Bob", "bob@acmetools.com")
21
+ res = ExpressPigeon::API.lists.update contact_list.list.id, :name => 'Updated Name', :from_name => 'Bob', :reply_to => 'Frank@zappa.com'
22
22
  validate_response res, 200, 'success', /list=#{res.list.id} created\/updated successfully/
23
23
  res.list.name.should eq "Updated Name"
24
24
  res.list.from_name.should eq 'Bob'
25
- res = PIGEON.lists.delete(contact_list.list.id)
25
+ res = ExpressPigeon::API.lists.delete(contact_list.list.id)
26
26
  validate_response res, 200, 'success', /list=#{contact_list.list.id} deleted successfully/
27
27
  end
28
28
 
29
29
 
30
30
  it 'should upload contacts as CSV file' do
31
31
  list_name = "Upload_#{Kernel.rand(9999).to_s}"
32
- list_resp = PIGEON.lists.create(list_name, 'Bob', 'bob@acmetools.com')
32
+ list_resp = ExpressPigeon::API.lists.create(list_name, 'Bob', 'bob@acmetools.com')
33
33
  begin
34
- resp = PIGEON.lists.upload(list_resp.list.id, 'spec/resources/upload.csv')
34
+ resp = ExpressPigeon::API.lists.upload(list_resp.list.id, 'spec/resources/upload.csv')
35
35
  validate_response resp, 200, 'success', /file uploaded successfully/
36
- res = PIGEON.contacts.find_by_email 'x@x.x'
36
+ res = ExpressPigeon::API.contacts.find_by_email 'x@x.x'
37
37
  res.lists[0]['id'].should eq list_resp.list.id
38
38
  ensure
39
- res = PIGEON.lists.delete(list_resp.list.id)
39
+ res = ExpressPigeon::API.lists.delete(list_resp.list.id)
40
40
  validate_response res, 200, 'success', /list=#{list_resp.list.id} deleted successfully/
41
- PIGEON.contacts.find_by_email('x@x.x').message.should eq 'contact=x@x.x not found'
41
+ ExpressPigeon::API.contacts.find_by_email('x@x.x').message.should eq 'contact=x@x.x not found'
42
42
  end
43
43
  end
44
44
 
@@ -72,11 +72,19 @@ describe 'lists integration test' do
72
72
  # self.assertEqual(res.code, 404)
73
73
  # self.assertEqual(res.message, "list=-1 not found")
74
74
  #
75
- # def test_upload_status_without_upload_id(self):
76
- # res = self.api.lists.upload_status("")
77
- # self.assertEqual(res.code, 400)
78
- # self.assertEqual(res.status, "error")
79
- # self.assertEqual(res.message, "you must provide upload id")
75
+ it 'should check upload status' do
76
+ list_response = ExpressPigeon::API.lists.create("My List", "a@a.a", "a@a.a")
77
+ resp = ExpressPigeon::API.lists.upload(list_response.list.id, 'spec/resources/upload.csv')
78
+
79
+ sleep 20
80
+
81
+ begin
82
+ puts ExpressPigeon::API.lists.upload_status list_response.list.id
83
+ ensure
84
+ ExpressPigeon::API.lists.delete list_response.list.id
85
+ end
86
+
87
+ end
80
88
  #
81
89
  # def test_enabled_list_removal(self):
82
90
  # list_resp = self.api.lists.create("My list", "John", os.environ['EXPRESSPIGEON_API_USER'])
@@ -102,22 +110,32 @@ describe 'lists integration test' do
102
110
  # "could not delete list={0}, it has dependent subscriptions and/or scheduled campaigns".format(
103
111
  # list_resp.list.id))
104
112
  #
105
- # def test_export_csv(self):
106
- # list_response = self.api.lists.create("My List", "a@a.a", "a@a.a")
107
- # self.api.contacts.upsert(list_response.list.id, {"email": "mary@a.a"})
108
- #
109
- # res = self.api.lists.csv(list_response.list.id).split("\n")
110
- # self.assertEquals(len(res), 2)
111
- # headers = '"Email", "First name", "Last name", "City", "Phone", "Company", "Title", "Address 1", "Address 2", ' \
112
- # '"State", "Zip", "Country", "Date of birth", "custom_field_1", "custom_field_10", "custom_field_11", ' \
113
- # '"custom_field_12", "custom_field_13", "custom_field_18", "custom_field_19", "custom_field_2", ' \
114
- # '"custom_field_20", "custom_field_21", "custom_field_22", "custom_field_23", "custom_field_24", ' \
115
- # '"custom_field_3", "custom_field_4", "custom_field_5", "custom_field_6", "custom_field_7", ' \
116
- # '"custom_field_8", "custom_field_9"'
117
- # self.assertEquals(res[0], headers)
118
- # self.assertEquals(res[1], '"mary@a.a",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,')
119
- #
120
- # self.api.lists.delete(list_response.list.id)
121
- # self.api.contacts.delete("mary@a.a")
113
+ it 'should upload and download CSV' do
114
+ list_response = ExpressPigeon::API.lists.create("My List", "a@a.a", "a@a.a")
115
+ resp = ExpressPigeon::API.lists.upload(list_response.list.id, 'spec/resources/upload.csv')
116
+ res = ExpressPigeon::API.lists.csv(list_response.list.id)
117
+ ExpressPigeon::API.lists.delete list_response.list.id
118
+
119
+ count = 0
120
+ res.each_line do |line|
121
+ count = count + 1
122
+ end
123
+ count.should eq 4
124
+
125
+
126
+
127
+ # self.assertEquals(len(res), 2)
128
+ # headers = '"Email", "First name", "Last name", "City", "Phone", "Company", "Title", "Address 1", "Address 2", ' \
129
+ # '"State", "Zip", "Country", "Date of birth", "custom_field_1", "custom_field_10", "custom_field_11", ' \
130
+ # '"custom_field_12", "custom_field_13", "custom_field_18", "custom_field_19", "custom_field_2", ' \
131
+ # '"custom_field_20", "custom_field_21", "custom_field_22", "custom_field_23", "custom_field_24", ' \
132
+ # '"custom_field_3", "custom_field_4", "custom_field_5", "custom_field_6", "custom_field_7", ' \
133
+ # '"custom_field_8", "custom_field_9"'
134
+ # self.assertEquals(res[0], headers)
135
+ # self.assertEquals(res[1], '"mary@a.a",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,')
136
+ #
137
+ # self.api.lists.delete(list_response.list.id)
138
+ # self.api.contacts.delete("mary@a.a")
139
+ end
122
140
 
123
141
  end