toodledo 1.3.5 → 1.3.8
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/History.txt +14 -0
- data/{README.txt → README.md} +61 -48
- data/Rakefile +60 -18
- data/lib/toodledo.rb +5 -4
- data/lib/toodledo/command_line/client.rb +893 -840
- data/lib/toodledo/command_line/parser_helper.rb +24 -1
- data/lib/toodledo/command_line/task_formatter.rb +174 -150
- data/lib/toodledo/priority.rb +1 -0
- data/lib/toodledo/repeat.rb +2 -0
- data/lib/toodledo/server_error.rb +17 -0
- data/lib/toodledo/session.rb +53 -18
- data/lib/toodledo/status.rb +37 -35
- data/lib/toodledo/task.rb +8 -3
- data/lib/toodledo/version.rb +11 -0
- data/test/client_test.rb +60 -12
- data/test/helper.rb +11 -0
- data/test/parser_helper_test.rb +36 -6
- data/test/session_test.rb +221 -39
- data/test/toodledo_functional_test.rb +33 -7
- data/toodledo.gemspec +97 -0
- metadata +35 -60
- data/Manifest.txt +0 -41
- data/lib/toodledo/item_not_found_error.rb +0 -8
data/lib/toodledo/status.rb
CHANGED
@@ -1,44 +1,46 @@
|
|
1
1
|
#
|
2
2
|
# The possible values for the status field of a task.
|
3
3
|
#
|
4
|
-
|
4
|
+
module Toodledo
|
5
|
+
class Status
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
7
|
+
NONE = 0
|
8
|
+
NEXT_ACTION = 1
|
9
|
+
ACTIVE = 2
|
10
|
+
PLANNING = 3
|
11
|
+
DELEGATED = 4
|
12
|
+
WAITING = 5
|
13
|
+
HOLD = 6
|
14
|
+
POSTPONED = 7
|
15
|
+
SOMEDAY = 8
|
16
|
+
CANCELLED = 9
|
17
|
+
REFERENCE = 10
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
19
|
+
STATUS_ARRAY = [
|
20
|
+
NONE,
|
21
|
+
NEXT_ACTION,
|
22
|
+
ACTIVE,
|
23
|
+
PLANNING,
|
24
|
+
DELEGATED,
|
25
|
+
WAITING,
|
26
|
+
HOLD,
|
27
|
+
POSTPONED,
|
28
|
+
SOMEDAY,
|
29
|
+
CANCELLED,
|
30
|
+
REFERENCE
|
31
|
+
]
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
33
|
+
def self.each
|
34
|
+
STATUS_ARRAY.each{|value| yield(value)}
|
35
|
+
end
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
def self.valid?(input)
|
38
|
+
for status in STATUS_ARRAY
|
39
|
+
if (status == input)
|
40
|
+
return true
|
41
|
+
end
|
40
42
|
end
|
43
|
+
return false
|
41
44
|
end
|
42
|
-
|
43
|
-
|
44
|
-
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/toodledo/task.rb
CHANGED
@@ -55,6 +55,7 @@ module Toodledo
|
|
55
55
|
return @num_children
|
56
56
|
end
|
57
57
|
|
58
|
+
# TODO Repetitious. Refactor
|
58
59
|
def initialize(id, params = {})
|
59
60
|
@id = id
|
60
61
|
|
@@ -129,7 +130,7 @@ module Toodledo
|
|
129
130
|
# <parent>1122</parent>
|
130
131
|
# <children>0</children>
|
131
132
|
# <title>Buy Milk</title>
|
132
|
-
# <tag>After work</tag>
|
133
|
+
# <tag>After work</tag> # Actually, this counts as two tags
|
133
134
|
# <folder>123</folder>
|
134
135
|
# <context id="123">Home</context>
|
135
136
|
# <goal id="123">Get a Raise</goal>
|
@@ -223,7 +224,11 @@ module Toodledo
|
|
223
224
|
title = el.elements['title'].text
|
224
225
|
|
225
226
|
tag = el.elements['tag'].text
|
226
|
-
|
227
|
+
if tag == '0'
|
228
|
+
tag = nil
|
229
|
+
elsif tag
|
230
|
+
tag = tag.split(/\s+/)
|
231
|
+
end
|
227
232
|
|
228
233
|
length = el.elements['length'].text
|
229
234
|
length = nil if (length == '0')
|
@@ -276,7 +281,7 @@ module Toodledo
|
|
276
281
|
# <parent>#{@parent_id}</parent>
|
277
282
|
# <children>#{@children}</children>
|
278
283
|
# <title>#{@title}</title>
|
279
|
-
# <tag>#{@tag}</tag>
|
284
|
+
# <tag>#{@tag.join(' ')}</tag>
|
280
285
|
# <folder>#{@folder.server_id}</folder>
|
281
286
|
# <context id="#{@context.server_id}">#{@context.name}</context>
|
282
287
|
# <goal id="#{@goal.server_id}">#{@goal.name}</goal>
|
data/test/client_test.rb
CHANGED
@@ -1,8 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'toodledo/command_line/client'
|
5
|
-
require 'flexmock/test_unit'
|
1
|
+
require 'helper'
|
6
2
|
|
7
3
|
module Toodledo
|
8
4
|
module CommandLine
|
@@ -78,6 +74,39 @@ module Toodledo
|
|
78
74
|
|
79
75
|
@client.add_task(@session, input)
|
80
76
|
end
|
77
|
+
|
78
|
+
def test_add_task_with_duedate()
|
79
|
+
|
80
|
+
input = '#2011-03-04 This is a test'
|
81
|
+
|
82
|
+
args = { :duedate => "2011-03-04" }
|
83
|
+
|
84
|
+
@session.should_receive(:add_task).with('This is a test', args).and_return(1)
|
85
|
+
@client.should_receive(:print).with('Task 1 added.')
|
86
|
+
@client.add_task(@session, input)
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_add_task_with_single_tag()
|
90
|
+
|
91
|
+
input = '%tag This is a test'
|
92
|
+
|
93
|
+
args = { :tag => %w{tag} }
|
94
|
+
|
95
|
+
@session.should_receive(:add_task).with('This is a test', args).and_return(1)
|
96
|
+
@client.should_receive(:print).with('Task 1 added.')
|
97
|
+
@client.add_task(@session, input)
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_add_task_with_multiple_tags()
|
101
|
+
|
102
|
+
input = '%[tag1 tag2] This is a test'
|
103
|
+
|
104
|
+
args = { :tag => %w{tag1 tag2} }
|
105
|
+
|
106
|
+
@session.should_receive(:add_task).with('This is a test', args).and_return(1)
|
107
|
+
@client.should_receive(:print).with('Task 1 added.')
|
108
|
+
@client.add_task(@session, input)
|
109
|
+
end
|
81
110
|
|
82
111
|
def test_add_folder()
|
83
112
|
input = 'name'
|
@@ -109,7 +138,7 @@ module Toodledo
|
|
109
138
|
|
110
139
|
@client.add_goal(@session, input)
|
111
140
|
end
|
112
|
-
|
141
|
+
|
113
142
|
def test_list_tasks_with_nothing()
|
114
143
|
|
115
144
|
params = {
|
@@ -130,24 +159,43 @@ module Toodledo
|
|
130
159
|
@client.list_tasks(@session, input)
|
131
160
|
end
|
132
161
|
|
133
|
-
|
134
162
|
def test_list_tasks_with_everything()
|
135
163
|
|
136
|
-
|
164
|
+
parent_fields = {
|
165
|
+
:priority => Priority::HIGH,
|
166
|
+
:title => 'bar',
|
167
|
+
:folder => Folder::NO_FOLDER,
|
168
|
+
:context => Context::NO_CONTEXT,
|
169
|
+
:goal => Goal::NO_GOAL,
|
170
|
+
:status => Status::NONE,
|
171
|
+
:repeat => Repeat::NONE
|
172
|
+
}
|
173
|
+
parent_task = Task.new(54321, parent_fields)
|
174
|
+
|
175
|
+
child_fields = {
|
137
176
|
:priority => Priority::LOW,
|
138
177
|
:title => 'foo',
|
139
178
|
:folder => Folder.new(1234, 0, 0, 'test folder'),
|
140
179
|
:context => Context.new(345, 'test context'),
|
141
180
|
:goal => Goal.new(342341, 0, 0, 'test goal'),
|
142
181
|
:repeat => Repeat::BIWEEKLY,
|
182
|
+
:duedatemodifier => 1, # Due On
|
183
|
+
:duedate => Time.local(2011,06,25,13,45,56),
|
184
|
+
:startdate => Date.new(2010,05,23),
|
143
185
|
:status => Status::NEXT_ACTION,
|
186
|
+
:star => true,
|
144
187
|
:tag => 'some tag',
|
145
|
-
:
|
188
|
+
:parent_id => 54321,
|
189
|
+
:parent => parent_task,
|
190
|
+
:length => 125, # Minutes of duration
|
191
|
+
:timer => 423, # Seconds timer has been running
|
192
|
+
:num_children => 5
|
146
193
|
}
|
147
|
-
|
148
|
-
tasks = [
|
194
|
+
child_task = Task.new(1234, child_fields)
|
195
|
+
tasks = [ parent_task, child_task ]
|
149
196
|
@session.should_receive(:get_tasks).and_return(tasks)
|
150
|
-
@client.should_receive(:print).with(
|
197
|
+
@client.should_receive(:print).with("<54321> -- !high bar").once.ordered
|
198
|
+
@client.should_receive(:print).with("<1234> -- !low *[test folder] @[test context] ^[test goal] repeat[biweekly] #[=06/25/2011 01:45 PM] startdate[05/23/2010] status[Next Action] starred %[some tag] parent[bar] length[125] timer[423] children[5] foo").once.ordered
|
151
199
|
|
152
200
|
input = ''
|
153
201
|
@client.list_tasks(@session, input)
|
data/test/helper.rb
ADDED
data/test/parser_helper_test.rb
CHANGED
@@ -1,9 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'toodledo'
|
5
|
-
require 'toodledo/command_line/parser_helper'
|
6
|
-
|
1
|
+
require 'helper'
|
7
2
|
|
8
3
|
#
|
9
4
|
# Tests the parser helper
|
@@ -47,6 +42,41 @@ class ParserHelperTest < Test::Unit::TestCase
|
|
47
42
|
|
48
43
|
assert(folder == 'Harder Folder', "Folder not found")
|
49
44
|
end
|
45
|
+
|
46
|
+
def test_find_duedate
|
47
|
+
input = "#duedate @Context ^Goal blah blah blah"
|
48
|
+
|
49
|
+
duedate = parse_date(input)
|
50
|
+
|
51
|
+
assert(duedate == 'duedate', "duedate not found")
|
52
|
+
end
|
53
|
+
|
54
|
+
# TODO Separate parse_date from parse_duedate?
|
55
|
+
def test_find_harder_duedate
|
56
|
+
|
57
|
+
input = "Some Text @[Harder Context] #[Harder duedate] ^[Harder Goal]"
|
58
|
+
|
59
|
+
duedate = parse_date(input)
|
60
|
+
|
61
|
+
assert(duedate == 'Harder duedate', "duedate not found")
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_find_tag
|
65
|
+
input = "%tag @Context ^Goal blah blah blah"
|
66
|
+
|
67
|
+
tag = parse_tag(input)
|
68
|
+
|
69
|
+
assert(tag == ['tag'], "tag not found")
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_find_harder_tag
|
73
|
+
|
74
|
+
input = "Some Text @[Harder Context] %[Harder tag] ^[Harder Goal]"
|
75
|
+
|
76
|
+
tag = parse_tag(input)
|
77
|
+
|
78
|
+
assert(tag == ['Harder','tag'], "tag not found")
|
79
|
+
end
|
50
80
|
|
51
81
|
def test_find_goal
|
52
82
|
input = "*Folder @Context ^Goal wefawef wefawefawfe"
|
data/test/session_test.rb
CHANGED
@@ -1,33 +1,33 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
require 'rubygems'
|
5
|
-
require 'test/unit'
|
6
|
-
require 'flexmock/test_unit'
|
7
|
-
require 'toodledo/session'
|
1
|
+
require 'helper'
|
8
2
|
|
9
3
|
#
|
10
4
|
# This class tests that various handle methods in the session work as they're
|
11
5
|
# supposed to.
|
12
6
|
#
|
13
|
-
class SessionTest < Test::Unit::TestCase
|
14
7
|
|
15
|
-
|
8
|
+
class SessionTest < Test::Unit::TestCase
|
9
|
+
|
10
|
+
def setup
|
16
11
|
@session = Toodledo::Session.new('userid', 'password')
|
17
12
|
|
18
13
|
# mock out the get_token & call methods.
|
19
|
-
|
14
|
+
mock_connection(@session)
|
20
15
|
|
21
16
|
@session.connect()
|
22
17
|
end
|
23
18
|
|
19
|
+
def mock_connection(session)
|
20
|
+
flexmock(session, :get_token => 'token')
|
21
|
+
flexmock(session, :get_server_info => {:token_expires=>4*60.0})
|
22
|
+
end
|
23
|
+
|
24
24
|
def teardown
|
25
25
|
@session.disconnect()
|
26
26
|
end
|
27
27
|
|
28
28
|
def test_handle_app_id_in_session
|
29
29
|
new_sess = Toodledo::Session.new('userid', 'password', nil, 'appid')
|
30
|
-
|
30
|
+
mock_connection(new_sess)
|
31
31
|
new_sess.connect()
|
32
32
|
assert_not_nil new_sess.app_id
|
33
33
|
end
|
@@ -42,7 +42,7 @@ class SessionTest < Test::Unit::TestCase
|
|
42
42
|
flexmock(@session, :get_goal_by_name => goal)
|
43
43
|
@session.handle_goal(myhash, params)
|
44
44
|
|
45
|
-
|
45
|
+
assert_equal goal_id, myhash[:goal]
|
46
46
|
end
|
47
47
|
|
48
48
|
def test_handle_goal_with_id()
|
@@ -52,7 +52,7 @@ class SessionTest < Test::Unit::TestCase
|
|
52
52
|
|
53
53
|
@session.handle_goal(myhash, params)
|
54
54
|
|
55
|
-
|
55
|
+
assert_equal goal_id, myhash[:goal]
|
56
56
|
end
|
57
57
|
|
58
58
|
def test_handle_goal_with_obj()
|
@@ -63,7 +63,7 @@ class SessionTest < Test::Unit::TestCase
|
|
63
63
|
|
64
64
|
@session.handle_goal(myhash, params)
|
65
65
|
|
66
|
-
|
66
|
+
assert_equal goal_id, myhash[:goal]
|
67
67
|
end
|
68
68
|
|
69
69
|
def test_handle_context_with_obj()
|
@@ -74,7 +74,7 @@ class SessionTest < Test::Unit::TestCase
|
|
74
74
|
myhash = {}
|
75
75
|
@session.handle_context(myhash, params)
|
76
76
|
|
77
|
-
|
77
|
+
assert_equal context_id, myhash[:context]
|
78
78
|
end
|
79
79
|
|
80
80
|
def test_handle_context_with_id()
|
@@ -84,7 +84,7 @@ class SessionTest < Test::Unit::TestCase
|
|
84
84
|
myhash = {}
|
85
85
|
@session.handle_context(myhash, params)
|
86
86
|
|
87
|
-
|
87
|
+
assert_equal context_id, myhash[:context]
|
88
88
|
end
|
89
89
|
|
90
90
|
def test_handle_context_with_name()
|
@@ -95,7 +95,7 @@ class SessionTest < Test::Unit::TestCase
|
|
95
95
|
flexmock(@session, :get_context_by_name => context)
|
96
96
|
@session.handle_context(myhash, params)
|
97
97
|
|
98
|
-
|
98
|
+
assert_equal context_id, myhash[:context]
|
99
99
|
end
|
100
100
|
|
101
101
|
def test_handle_boolean_with_string_true()
|
@@ -103,7 +103,7 @@ class SessionTest < Test::Unit::TestCase
|
|
103
103
|
params = { :bool => 'true' }
|
104
104
|
@session.handle_boolean(myhash, params, :bool)
|
105
105
|
|
106
|
-
|
106
|
+
assert_equal "1", myhash[:bool]
|
107
107
|
end
|
108
108
|
|
109
109
|
def test_handle_boolean_with_string_false()
|
@@ -111,7 +111,7 @@ class SessionTest < Test::Unit::TestCase
|
|
111
111
|
params = { :bool => 'false' }
|
112
112
|
@session.handle_boolean(myhash, params, :bool)
|
113
113
|
|
114
|
-
|
114
|
+
assert_equal "0", myhash[:bool]
|
115
115
|
end
|
116
116
|
|
117
117
|
def test_handle_boolean_with_true()
|
@@ -119,7 +119,7 @@ class SessionTest < Test::Unit::TestCase
|
|
119
119
|
params = { :bool => true }
|
120
120
|
@session.handle_boolean(myhash, params, :bool)
|
121
121
|
|
122
|
-
|
122
|
+
assert_equal "1", myhash[:bool]
|
123
123
|
end
|
124
124
|
|
125
125
|
def test_handle_boolean_with_false()
|
@@ -127,7 +127,7 @@ class SessionTest < Test::Unit::TestCase
|
|
127
127
|
params = { :bool => false }
|
128
128
|
@session.handle_boolean(myhash, params, :bool)
|
129
129
|
|
130
|
-
|
130
|
+
assert_equal "0", myhash[:bool]
|
131
131
|
end
|
132
132
|
|
133
133
|
def test_handle_folder()
|
@@ -137,7 +137,7 @@ class SessionTest < Test::Unit::TestCase
|
|
137
137
|
params = { :folder => folder_id }
|
138
138
|
@session.handle_folder(myhash, params)
|
139
139
|
|
140
|
-
|
140
|
+
assert_equal folder_id, myhash[:folder]
|
141
141
|
end
|
142
142
|
|
143
143
|
def test_handle_folder_with_obj()
|
@@ -149,7 +149,7 @@ class SessionTest < Test::Unit::TestCase
|
|
149
149
|
params = { :folder => folder }
|
150
150
|
@session.handle_folder(myhash, params)
|
151
151
|
|
152
|
-
|
152
|
+
assert_equal folder_id, myhash[:folder]
|
153
153
|
end
|
154
154
|
|
155
155
|
|
@@ -164,7 +164,7 @@ class SessionTest < Test::Unit::TestCase
|
|
164
164
|
params = { :folder => folder_name }
|
165
165
|
@session.handle_folder(myhash, params)
|
166
166
|
|
167
|
-
|
167
|
+
assert_equal folder_id, myhash[:folder]
|
168
168
|
end
|
169
169
|
|
170
170
|
def test_handle_parent_with_task()
|
@@ -175,7 +175,7 @@ class SessionTest < Test::Unit::TestCase
|
|
175
175
|
|
176
176
|
@session.handle_parent(myhash, params)
|
177
177
|
|
178
|
-
|
178
|
+
assert_equal task_id, myhash[:parent]
|
179
179
|
end
|
180
180
|
|
181
181
|
def test_handle_parent_with_id()
|
@@ -185,23 +185,205 @@ class SessionTest < Test::Unit::TestCase
|
|
185
185
|
|
186
186
|
@session.handle_parent(myhash, params)
|
187
187
|
|
188
|
-
|
188
|
+
assert_equal task_id, myhash[:parent]
|
189
|
+
end
|
190
|
+
|
191
|
+
def test_handle_number_with_nil()
|
192
|
+
myhash = {}
|
193
|
+
params = { :num => nil }
|
194
|
+
@session.handle_number(myhash, params, :num)
|
195
|
+
|
196
|
+
assert_equal nil, myhash[:num]
|
197
|
+
end
|
198
|
+
|
199
|
+
def test_handle_number_with_string()
|
200
|
+
myhash = {}
|
201
|
+
params = { :num => '12345' }
|
202
|
+
@session.handle_number(myhash, params, :num)
|
203
|
+
|
204
|
+
assert_equal nil, myhash[:num]
|
189
205
|
end
|
190
206
|
|
207
|
+
def test_handle_number_with_integer()
|
208
|
+
myhash = {}
|
209
|
+
params = { :num => 12345 }
|
210
|
+
@session.handle_number(myhash, params, :num)
|
211
|
+
|
212
|
+
assert_equal '12345', myhash[:num]
|
213
|
+
end
|
191
214
|
|
215
|
+
def test_handle_string_with_nil()
|
216
|
+
myhash = {}
|
217
|
+
params = { :string => nil }
|
218
|
+
@session.handle_string(myhash, params, :string)
|
219
|
+
|
220
|
+
assert_equal nil, myhash[:string]
|
221
|
+
end
|
192
222
|
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
223
|
+
def test_handle_string()
|
224
|
+
myhash = {}
|
225
|
+
params = { :string => '12345' }
|
226
|
+
@session.handle_string(myhash, params, :string)
|
227
|
+
|
228
|
+
assert_equal '12345', myhash[:string]
|
229
|
+
end
|
230
|
+
|
231
|
+
def test_handle_date_with_nil()
|
232
|
+
myhash = {}
|
233
|
+
params = { :date => nil }
|
234
|
+
@session.handle_date(myhash, params, :date)
|
235
|
+
|
236
|
+
assert_equal nil, myhash[:date]
|
237
|
+
end
|
238
|
+
|
239
|
+
def test_handle_date()
|
240
|
+
myhash = {}
|
241
|
+
params = { :date => Time.local(2011,05,23,14,45,56) }
|
242
|
+
@session.handle_date(myhash, params, :date)
|
243
|
+
|
244
|
+
assert_equal '2011-05-23', myhash[:date]
|
245
|
+
end
|
246
|
+
|
247
|
+
def test_handle_date_with_string()
|
248
|
+
myhash = {}
|
249
|
+
params = { :date => '2011-05-23' }
|
250
|
+
@session.handle_date(myhash, params, :date)
|
251
|
+
|
252
|
+
assert_equal '2011-05-23', myhash[:date]
|
253
|
+
end
|
254
|
+
|
255
|
+
def test_handle_time_with_nil()
|
256
|
+
myhash = {}
|
257
|
+
params = { :time => nil }
|
258
|
+
@session.handle_time(myhash, params, :time)
|
259
|
+
|
260
|
+
assert_equal nil, myhash[:time]
|
261
|
+
end
|
262
|
+
|
263
|
+
def test_handle_time()
|
264
|
+
myhash = {}
|
265
|
+
params = { :time => Time.local(2011,05,23,14,45,56) }
|
266
|
+
@session.handle_time(myhash, params, :time)
|
267
|
+
|
268
|
+
assert_equal '02:45 PM', myhash[:time]
|
269
|
+
end
|
270
|
+
|
271
|
+
def test_handle_time_with_string()
|
272
|
+
myhash = {}
|
273
|
+
params = { :time => '02:45 PM' }
|
274
|
+
@session.handle_time(myhash, params, :time)
|
275
|
+
|
276
|
+
assert_equal '02:45 PM', myhash[:time]
|
277
|
+
end
|
278
|
+
|
279
|
+
def test_handle_datetime_with_nil()
|
280
|
+
myhash = {}
|
281
|
+
params = { :datetime => nil }
|
282
|
+
@session.handle_datetime(myhash, params, :datetime)
|
283
|
+
|
284
|
+
assert_equal nil, myhash[:datetime]
|
285
|
+
end
|
286
|
+
|
287
|
+
def test_handle_datetime()
|
288
|
+
myhash = {}
|
289
|
+
params = { :datetime => Time.local(2011,05,23,14,45,56) }
|
290
|
+
@session.handle_datetime(myhash, params, :datetime)
|
291
|
+
|
292
|
+
assert_equal '2011-05-23 14:45:56', myhash[:datetime]
|
293
|
+
end
|
294
|
+
|
295
|
+
def test_handle_datetime_with_string()
|
296
|
+
myhash = {}
|
297
|
+
params = { :datetime => '2011-05-23 14:45:56' }
|
298
|
+
@session.handle_datetime(myhash, params, :datetime)
|
299
|
+
|
300
|
+
assert_equal '2011-05-23 14:45:56', myhash[:datetime]
|
301
|
+
end
|
302
|
+
|
303
|
+
def test_handle_repeat_with_nil()
|
304
|
+
myhash = {}
|
305
|
+
params = { :repeat => nil }
|
306
|
+
@session.handle_repeat(myhash, params)
|
307
|
+
|
308
|
+
assert_equal nil, myhash[:repeat]
|
309
|
+
end
|
310
|
+
|
311
|
+
REPEAT_VALUES = %w{NONE WEEKLY MONTHLY YEARLY DAILY BIWEEKLY BIMONTHLY SEMIANNUALLY QUARTERLY WITH_PARENT}
|
312
|
+
|
313
|
+
def test_handle_repeat()
|
314
|
+
REPEAT_VALUES.each do |repeat|
|
315
|
+
repeat_value = Toodledo::Repeat.const_get(repeat)
|
316
|
+
myhash = {}
|
317
|
+
params = { :repeat => repeat_value }
|
318
|
+
@session.handle_repeat(myhash, params)
|
319
|
+
|
320
|
+
assert_equal repeat_value, myhash[:repeat], "does not handle repeat code #{repeat} (value #{repeat_value})"
|
321
|
+
end
|
322
|
+
end
|
323
|
+
|
324
|
+
def test_handle_priority_with_nil()
|
325
|
+
myhash = {}
|
326
|
+
params = { :priority => nil }
|
327
|
+
@session.handle_priority(myhash, params)
|
328
|
+
|
329
|
+
assert_equal nil, myhash[:priority]
|
330
|
+
end
|
331
|
+
|
332
|
+
PRIORITY_VALUES = %w{TOP HIGH MEDIUM LOW NEGATIVE}
|
333
|
+
|
334
|
+
def test_handle_priority()
|
335
|
+
PRIORITY_VALUES.each do |priority|
|
336
|
+
priority_value = Toodledo::Priority.const_get(priority)
|
337
|
+
myhash = {}
|
338
|
+
params = { :priority => priority_value }
|
339
|
+
@session.handle_priority(myhash, params)
|
340
|
+
|
341
|
+
assert_equal priority_value, myhash[:priority], "does not handle priority code #{priority} (value #{priority_value})"
|
342
|
+
end
|
343
|
+
end
|
344
|
+
|
345
|
+
def test_handle_status_with_nil()
|
346
|
+
myhash = {}
|
347
|
+
params = { :status => nil }
|
348
|
+
@session.handle_status(myhash, params)
|
349
|
+
|
350
|
+
assert_equal nil, myhash[:status]
|
351
|
+
end
|
352
|
+
|
353
|
+
STATUS_VALUES = %w{NONE NEXT_ACTION ACTIVE PLANNING DELEGATED WAITING HOLD POSTPONED SOMEDAY CANCELLED REFERENCE}
|
206
354
|
|
355
|
+
def test_handle_status()
|
356
|
+
STATUS_VALUES.each do |status|
|
357
|
+
status_value = Toodledo::Status.const_get(status)
|
358
|
+
myhash = {}
|
359
|
+
params = { :status => status_value }
|
360
|
+
@session.handle_status(myhash, params)
|
361
|
+
|
362
|
+
assert_equal status_value, myhash[:status], "does not handle status code #{status} (value #{status_value})"
|
363
|
+
end
|
364
|
+
end
|
365
|
+
|
366
|
+
def test_handle_tag_with_nil()
|
367
|
+
myhash = {}
|
368
|
+
params = { :tag => nil }
|
369
|
+
@session.handle_tag(myhash, params)
|
370
|
+
|
371
|
+
assert_equal nil, myhash[:tag]
|
372
|
+
end
|
373
|
+
|
374
|
+
def test_handle_tag_with_array()
|
375
|
+
myhash = {}
|
376
|
+
params = { :tag => %w{tag1 tag2 tag3} }
|
377
|
+
@session.handle_tag(myhash, params)
|
378
|
+
|
379
|
+
assert_equal 'tag1 tag2 tag3', myhash[:tag]
|
380
|
+
end
|
381
|
+
|
382
|
+
def test_handle_tag_with_string()
|
383
|
+
myhash = {}
|
384
|
+
params = { :tag => 'tags' }
|
385
|
+
@session.handle_tag(myhash, params)
|
386
|
+
|
387
|
+
assert_equal 'tags', myhash[:tag]
|
388
|
+
end
|
207
389
|
end
|