paradeiser 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Guardfile +16 -11
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/TODO.md +12 -1
- data/bin/par +5 -2
- data/lib/paradeiser.rb +22 -2
- data/lib/paradeiser/controllers/controller.rb +1 -0
- data/lib/paradeiser/controllers/paradeiser_controller.rb +0 -1
- data/lib/paradeiser/models/hook.rb +4 -0
- data/lib/paradeiser/models/repository.rb +1 -1
- data/lib/paradeiser/models/scheduled.rb +4 -0
- data/lib/paradeiser/version.rb +1 -1
- data/paradeiser.gemspec +1 -6
- data/templates/linux/hooks/after-finish-break +2 -0
- data/templates/linux/hooks/after-finish-pomodoro +2 -0
- data/templates/linux/hooks/after-start-break +2 -0
- data/templates/linux/hooks/after-start-pomodoro +2 -0
- data/templates/mac/hooks/after-finish-break +2 -0
- data/templates/mac/hooks/after-finish-pomodoro +2 -0
- data/templates/mac/hooks/after-start-break +2 -0
- data/templates/mac/hooks/after-start-pomodoro +2 -0
- data/test/helper.rb +14 -36
- data/test/integration/test_annotate.rb +15 -13
- data/test/integration/test_finish.rb +7 -5
- data/test/integration/test_interrupt.rb +7 -5
- data/test/integration/test_log.rb +9 -7
- data/test/integration/test_no_args.rb +5 -3
- data/test/integration/test_start.rb +5 -3
- data/test/integration/test_status.rb +8 -6
- data/test/integration/test_unknown.rb +5 -3
- data/test/lib/controller_test.rb +4 -2
- data/test/lib/integration_test.rb +8 -2
- data/test/lib/paradeiser_controller_test.rb +7 -1
- data/test/lib/token_file_registry.rb +19 -0
- data/test/lib/unit_test.rb +47 -0
- data/test/lib/view_test.rb +13 -8
- data/test/scripts/create-failing-hooks +17 -0
- data/test/scripts/fail +5 -0
- data/test/unit/test_break.rb +43 -40
- data/test/unit/test_break_view.rb +17 -14
- data/test/unit/test_breaks_controller.rb +55 -52
- data/test/unit/test_interrupt.rb +27 -24
- data/test/unit/test_paradeiser_controller_export.rb +103 -100
- data/test/unit/test_paradeiser_controller_init.rb +2 -2
- data/test/unit/test_paradeiser_controller_report.rb +72 -69
- data/test/unit/test_paradeiser_controller_status.rb +78 -75
- data/test/unit/test_paradeiser_view_init.rb +5 -3
- data/test/unit/test_paradeiser_view_report.rb +116 -114
- data/test/unit/test_paradeiser_view_status.rb +14 -11
- data/test/unit/test_pomodori_controller.rb +319 -316
- data/test/unit/test_pomodori_view.rb +40 -37
- data/test/unit/test_pomodoro.rb +116 -113
- data/test/unit/test_pomodoro_hooks.rb +172 -170
- data/test/unit/test_repository.rb +98 -95
- data/test/unit/test_scheduler.rb +39 -30
- data/test/unit/test_token_file_registry.rb +40 -0
- metadata +59 -49
data/test/unit/test_interrupt.rb
CHANGED
@@ -1,36 +1,39 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
module ParadeiserTest
|
4
|
+
class TestInterrupt < UnitTest
|
5
|
+
def setup
|
6
|
+
super
|
7
|
+
@now = srand
|
8
|
+
end
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
def test_created_at
|
11
|
+
int = new_interrupt
|
12
|
+
assert_equal(@now, int.created_at.to_i)
|
13
|
+
end
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
def test_defaults_to_internal
|
16
|
+
int = new_interrupt
|
17
|
+
assert_equal(:internal, int.type)
|
18
|
+
end
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
def test_external
|
21
|
+
int = new_interrupt(:external)
|
22
|
+
assert_equal(:external, int.type)
|
23
|
+
end
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
|
25
|
+
def test_unknown
|
26
|
+
assert_raises InvalidTypeError do
|
27
|
+
new_interrupt(:unknown)
|
28
|
+
end
|
26
29
|
end
|
27
|
-
end
|
28
30
|
|
29
|
-
private
|
31
|
+
private
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
-
|
33
|
+
def new_interrupt(type = nil)
|
34
|
+
Time.stub :now, Time.at(@now) do
|
35
|
+
Paradeiser::Interrupt.new(type)
|
36
|
+
end
|
34
37
|
end
|
35
38
|
end
|
36
39
|
end
|
@@ -3,105 +3,108 @@ require 'helper'
|
|
3
3
|
#
|
4
4
|
# There is no view for export, so we need to test the entire results here
|
5
5
|
#
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
6
|
+
module ParadeiserTest
|
7
|
+
class TestParadeiserControllerExport < ParadeiserControllerTest
|
8
|
+
def setup
|
9
|
+
super
|
10
|
+
@backend = PStoreMock.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_empty
|
14
|
+
attrs = invoke(:export)
|
15
|
+
assert_empty(attrs[:stderr])
|
16
|
+
|
17
|
+
result = JSON.parse(attrs[:stdout])
|
18
|
+
assert(result)
|
19
|
+
assert_empty(result)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_pomodoro
|
23
|
+
pom = produce(Pomodoro)
|
24
|
+
started_at = Time.new(8)
|
25
|
+
pom.started_at = started_at
|
26
|
+
pom.finish!
|
27
|
+
finished_at = Time.new(16)
|
28
|
+
pom.finished_at = finished_at
|
29
|
+
@backend[:bar] = pom
|
30
|
+
|
31
|
+
attrs = invoke(:export)
|
32
|
+
assert_empty(attrs[:stderr])
|
33
|
+
result = JSON.parse(attrs[:stdout])
|
34
|
+
|
35
|
+
assert(result)
|
36
|
+
refute_empty(result)
|
37
|
+
assert_equal(1, result.size)
|
38
|
+
p = result.first
|
39
|
+
assert(p)
|
40
|
+
|
41
|
+
assert_equal('Pomodoro', p['type'])
|
42
|
+
assert_equal(1500, p['length'])
|
43
|
+
assert_equal('finished', p['status'])
|
44
|
+
assert_equal(started_at.as_json, p['started_at'])
|
45
|
+
assert_equal(finished_at.as_json, p['finished_at'])
|
46
|
+
|
47
|
+
interrupts = p['interrupts']
|
48
|
+
assert(interrupts)
|
49
|
+
assert_empty(interrupts)
|
50
|
+
|
51
|
+
annotations = p['annotations']
|
52
|
+
assert(annotations)
|
53
|
+
assert_empty(annotations)
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_break
|
57
|
+
br3ak = produce(Break)
|
58
|
+
started_at = Time.new(8)
|
59
|
+
br3ak.started_at = started_at
|
60
|
+
br3ak.finish!
|
61
|
+
finished_at = Time.new(16)
|
62
|
+
br3ak.finished_at = finished_at
|
63
|
+
@backend[:bar] = br3ak
|
64
|
+
|
65
|
+
attrs = invoke(:export)
|
66
|
+
assert_empty(attrs[:stderr])
|
67
|
+
result = JSON.parse(attrs[:stdout])
|
68
|
+
|
69
|
+
assert(result)
|
70
|
+
refute_empty(result)
|
71
|
+
assert_equal(1, result.size)
|
72
|
+
p = result.first
|
73
|
+
assert(p)
|
74
|
+
|
75
|
+
assert_equal('Break', p['type'])
|
76
|
+
assert_equal(300, p['length'])
|
77
|
+
assert_equal('finished', p['status'])
|
78
|
+
assert_equal(started_at.as_json, p['started_at'])
|
79
|
+
assert_equal(finished_at.as_json, p['finished_at'])
|
80
|
+
|
81
|
+
refute(p['interrupts'])
|
82
|
+
refute(p['annotations'])
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_multiple
|
86
|
+
br3ak = produce(Break)
|
87
|
+
br3ak.started_at = Time.new(8)
|
88
|
+
br3ak.finish!
|
89
|
+
br3ak.finished_at = Time.new(16)
|
90
|
+
@backend[:bar] = br3ak
|
91
|
+
|
92
|
+
pom = produce(Pomodoro)
|
93
|
+
pom.started_at = Time.new(8)
|
94
|
+
pom.finish!
|
95
|
+
pom.finished_at = Time.new(16)
|
96
|
+
@backend[:foo] = pom
|
97
|
+
|
98
|
+
attrs = invoke(:export)
|
99
|
+
assert_empty(attrs[:stderr])
|
100
|
+
result = JSON.parse(attrs[:stdout])
|
101
|
+
|
102
|
+
assert(result)
|
103
|
+
refute_empty(result)
|
104
|
+
assert_equal(2, result.size)
|
105
|
+
|
106
|
+
assert_equal('Break', result.first['type'])
|
107
|
+
assert_equal('Pomodoro', result.last['type'])
|
108
|
+
end
|
106
109
|
end
|
107
110
|
end
|
@@ -26,7 +26,7 @@ class TestParadeiserControllerInit < MiniTest::Test
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def test_init_existing
|
29
|
-
FileUtils.mkdir_p(Paradeiser.par_dir, 0700)
|
29
|
+
FileUtils.mkdir_p(Paradeiser.par_dir, mode: 0700)
|
30
30
|
assert(Dir.exists?(Paradeiser.par_dir))
|
31
31
|
|
32
32
|
invoke(:init)
|
@@ -50,7 +50,7 @@ class TestParadeiserControllerInit < MiniTest::Test
|
|
50
50
|
def test_init_existing_with_env_override
|
51
51
|
ENV.delete('PAR_DIR')
|
52
52
|
|
53
|
-
Dir.mktmpdir do |dir|
|
53
|
+
Dir.mktmpdir(name) do |dir|
|
54
54
|
refute_equal(dir, Paradeiser.par_dir)
|
55
55
|
ENV['PAR_DIR'] = dir
|
56
56
|
assert_equal(dir, Paradeiser.par_dir)
|
@@ -1,91 +1,94 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
module ParadeiserTest
|
4
|
+
class TestParadeiserControllerReportTest < ParadeiserControllerTest
|
5
|
+
ATTR_NAMES = %w{has_output @finished @canceled @external_interrupts @internal_interrupts @breaks @break_minutes}
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
7
|
+
def setup
|
8
|
+
super
|
9
|
+
@backend = PStoreMock.new
|
10
|
+
end
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
def test_idle
|
13
|
+
attrs = invoke(:report, nil, nil, *ATTR_NAMES)
|
14
|
+
assert_equal(0, attrs[:finished])
|
15
|
+
end
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
def test_has_output
|
18
|
+
attrs = invoke(:report, nil, nil, *ATTR_NAMES)
|
19
|
+
assert_equal(true, attrs[:has_output])
|
20
|
+
end
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
def test_finished
|
23
|
+
pom = produce(Pomodoro) # can't use mocks as long as the controller uses kind_of?
|
24
|
+
pom.started_at = Time.new(8)
|
25
|
+
pom.finished_at = Time.new(16)
|
26
|
+
pom.finish!
|
27
|
+
@backend[:bar] = pom
|
26
28
|
|
27
|
-
|
28
|
-
|
29
|
-
|
29
|
+
attrs = invoke(:report, nil, nil, *ATTR_NAMES)
|
30
|
+
assert_equal(1, attrs[:finished])
|
31
|
+
end
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
def test_canceled
|
34
|
+
pom = produce(Pomodoro)
|
35
|
+
pom.started_at = Time.new(16)
|
36
|
+
pom.canceled_at = Time.new(24)
|
37
|
+
pom.cancel!
|
38
|
+
@backend[:bar] = pom
|
37
39
|
|
38
|
-
|
39
|
-
|
40
|
-
|
40
|
+
attrs = invoke(:report, nil, nil, *ATTR_NAMES)
|
41
|
+
assert_equal(1, attrs[:canceled])
|
42
|
+
end
|
41
43
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
44
|
+
def test_external_interrupts
|
45
|
+
pom = produce(Pomodoro)
|
46
|
+
pom.started_at = Time.new(24)
|
47
|
+
pom.canceled_at = Time.new(32)
|
48
|
+
pom.interrupt!(:external)
|
49
|
+
@backend[:bar] = pom
|
48
50
|
|
49
|
-
|
50
|
-
|
51
|
-
|
51
|
+
attrs = invoke(:report, nil, nil, *ATTR_NAMES)
|
52
|
+
assert_equal(1, attrs[:external_interrupts])
|
53
|
+
end
|
52
54
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
55
|
+
def test_internal_interrupts
|
56
|
+
pom = produce(Pomodoro)
|
57
|
+
pom.started_at = Time.new(32)
|
58
|
+
pom.canceled_at = Time.new(64)
|
59
|
+
pom.interrupt!(:internal)
|
60
|
+
@backend[:bar] = pom
|
59
61
|
|
60
|
-
|
61
|
-
|
62
|
-
|
62
|
+
attrs = invoke(:report, nil, nil, *ATTR_NAMES)
|
63
|
+
assert_equal(1, attrs[:internal_interrupts])
|
64
|
+
end
|
63
65
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
66
|
+
def test_breaks
|
67
|
+
br3ak = produce(Break)
|
68
|
+
br3ak.started_at = Time.new(164)
|
69
|
+
br3ak.finished_at = Time.new(128)
|
70
|
+
@backend[:foo] = br3ak
|
69
71
|
|
70
|
-
|
71
|
-
|
72
|
-
|
72
|
+
attrs = invoke(:report, nil, nil, *ATTR_NAMES)
|
73
|
+
assert_equal(1, attrs[:breaks])
|
74
|
+
end
|
73
75
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
76
|
+
def test_break_minutes
|
77
|
+
@backend[:foo] = make_break(5)
|
78
|
+
@backend[:bar] = make_break(3)
|
79
|
+
@backend[:baz] = make_break(2)
|
78
80
|
|
79
|
-
|
80
|
-
|
81
|
-
|
81
|
+
attrs = invoke(:report, nil, nil, *ATTR_NAMES)
|
82
|
+
assert_equal(10, attrs[:break_minutes])
|
83
|
+
end
|
82
84
|
|
83
|
-
private
|
85
|
+
private
|
84
86
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
87
|
+
def make_break(minutes = 5)
|
88
|
+
Break.new.tap do |b|
|
89
|
+
b.started_at = srand
|
90
|
+
b.finished_at = b.started_at + minutes * 60
|
91
|
+
end
|
89
92
|
end
|
90
93
|
end
|
91
94
|
end
|