11# -*- coding: utf-8 -*-
22from datetime import datetime
3- from tests .base import MockVim , MockCache
3+ from tests .base import MockVim , MockCacheWithPriorities
44import sys
55
66from tasklib import local_zone
77
88class TestParsingVimwikiTask (object ):
99 def setup (self ):
1010 self .mockvim = MockVim ()
11- self .cache = MockCache ()
11+ self .cache = MockCacheWithPriorities ()
1212 sys .modules ['vim' ] = self .mockvim
1313 from taskwiki .vwtask import VimwikiTask
1414 self .VimwikiTask = VimwikiTask
@@ -56,23 +56,23 @@ def test_due_short(self):
5656 assert vwtask ['priority' ] == None
5757 assert vwtask ['indent' ] == ''
5858
59- def test_priority_low (self ):
59+ def test_default_priority_low (self ):
6060 self .cache .buffer [0 ] = "* [ ] Semi-Important task !"
6161 vwtask = self .VimwikiTask .from_line (self .cache , 0 )
6262
6363 assert vwtask ['description' ] == u"Semi-Important task"
6464 assert vwtask ['priority' ] == 'L'
6565 assert vwtask ['uuid' ] == None
6666
67- def test_priority_medium (self ):
67+ def test_default_priority_medium (self ):
6868 self .cache .buffer [0 ] = "* [ ] Important task !!"
6969 vwtask = self .VimwikiTask .from_line (self .cache , 0 )
7070
7171 assert vwtask ['description' ] == u"Important task"
7272 assert vwtask ['priority' ] == 'M'
7373 assert vwtask ['uuid' ] == None
7474
75- def test_priority_high (self ):
75+ def test_default_priority_high (self ):
7676 self .cache .buffer [0 ] = "* [ ] Very important task !!!"
7777 vwtask = self .VimwikiTask .from_line (self .cache , 0 )
7878
@@ -81,6 +81,78 @@ def test_priority_high(self):
8181 assert vwtask ['uuid' ] == None
8282 assert vwtask ['due' ] == None
8383
84+ def test_custom_priority_0 (self ):
85+ self .cache = MockCacheWithPriorities ({
86+ - 2 : 0 , - 1 : 'L' , 0 : None , 1 : 'M' , 2 : 'H'
87+ })
88+ self .cache .buffer [0 ] = "* [ ] Very important task ¡¡"
89+ vwtask = self .VimwikiTask .from_line (self .cache , 0 )
90+
91+ assert vwtask ['description' ] == u"Very important task"
92+ assert vwtask ['priority' ] == 0
93+ assert vwtask ['uuid' ] == None
94+ assert vwtask ['due' ] == None
95+
96+ def test_custom_priority_L (self ):
97+ self .cache = MockCacheWithPriorities ({
98+ - 2 : 0 , - 1 : 'L' , 0 : None , 1 : 'M' , 2 : 'H'
99+ })
100+ self .cache .buffer [0 ] = "* [ ] Very important task ¡"
101+ vwtask = self .VimwikiTask .from_line (self .cache , 0 )
102+
103+ assert vwtask ['description' ] == u"Very important task"
104+ assert vwtask ['priority' ] == 'L'
105+ assert vwtask ['uuid' ] == None
106+ assert vwtask ['due' ] == None
107+
108+ def test_custom_priority_none (self ):
109+ self .cache = MockCacheWithPriorities ({
110+ - 2 : 0 , - 1 : 'L' , 0 : None , 1 : 'M' , 2 : 'H'
111+ })
112+ self .cache .buffer [0 ] = "* [ ] Very important task"
113+ vwtask = self .VimwikiTask .from_line (self .cache , 0 )
114+
115+ assert vwtask ['description' ] == u"Very important task"
116+ assert vwtask ['priority' ] == None
117+ assert vwtask ['uuid' ] == None
118+ assert vwtask ['due' ] == None
119+
120+ def test_custom_priority_M (self ):
121+ self .cache = MockCacheWithPriorities ({
122+ - 2 : 0 , - 1 : 'L' , 0 : None , 1 : 'M' , 2 : 'H'
123+ })
124+ self .cache .buffer [0 ] = "* [ ] Very important task !"
125+ vwtask = self .VimwikiTask .from_line (self .cache , 0 )
126+
127+ assert vwtask ['description' ] == u"Very important task"
128+ assert vwtask ['priority' ] == 'M'
129+ assert vwtask ['uuid' ] == None
130+ assert vwtask ['due' ] == None
131+
132+ def test_custom_priority_H (self ):
133+ self .cache = MockCacheWithPriorities ({
134+ - 2 : 0 , - 1 : 'L' , 0 : None , 1 : 'M' , 2 : 'H'
135+ })
136+ self .cache .buffer [0 ] = "* [ ] Very important task !!"
137+ vwtask = self .VimwikiTask .from_line (self .cache , 0 )
138+
139+ assert vwtask ['description' ] == u"Very important task"
140+ assert vwtask ['priority' ] == 'H'
141+ assert vwtask ['uuid' ] == None
142+ assert vwtask ['due' ] == None
143+
144+ def test_custom_priority_no_three_exclamations (self ):
145+ self .cache = MockCacheWithPriorities ({
146+ - 2 : 0 , - 1 : 'L' , 0 : None , 1 : 'M' , 2 : 'H'
147+ })
148+ self .cache .buffer [0 ] = "* [ ] Very important task !!!"
149+ vwtask = self .VimwikiTask .from_line (self .cache , 0 )
150+
151+ assert vwtask ['description' ] == u"Very important task"
152+ assert vwtask ['priority' ] == None
153+ assert vwtask ['uuid' ] == None
154+ assert vwtask ['due' ] == None
155+
84156 def test_priority_and_due (self ):
85157 self .cache .buffer [0 ] = "* [ ] Due today !!! (2015-08-08)"
86158 vwtask = self .VimwikiTask .from_line (self .cache , 0 )
0 commit comments