Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
topydo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
topydo
Commits
c9c36d67
Commit
c9c36d67
authored
Oct 19, 2015
by
MinchinWeb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for configuration
parent
a40b2dd9
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
141 additions
and
7 deletions
+141
-7
test/data/ConfigTest1.conf
test/data/ConfigTest1.conf
+0
-0
test/data/ConfigTest2.conf
test/data/ConfigTest2.conf
+0
-0
test/data/ConfigTest4.conf
test/data/ConfigTest4.conf
+26
-0
test/data/ConfigTest5.conf
test/data/ConfigTest5.conf
+6
-0
test/test_config.py
test/test_config.py
+109
-7
No files found.
test/data/
config1
→
test/data/
ConfigTest1.conf
View file @
c9c36d67
File moved
test/data/
config2
→
test/data/
ConfigTest2.conf
View file @
c9c36d67
File moved
test/data/ConfigTest4.conf
0 → 100644
View file @
c9c36d67
[
topydo
]
colors
=
junk
[
add
]
auto_creation_date
=
junk
[
ls
]
indent
=
junk
list_limit
=
junk
human_readable_dates
=
junk
[
sort
]
keep_sorted
=
junk
ignore_weekends
=
junk
[
dep
]
append_parent_projects
=
junk
append_parent_contexts
=
junk
[
colorscheme
]
priority_colors
=
junk
project_color
=
junk
context_color
=
junk
metadata_color
=
junk
link_color
=
junk
test/data/ConfigTest5.conf
0 → 100644
View file @
c9c36d67
[
colorscheme
]
;
priority_colors
=
junk
;
project_color
=
junk
;
context_color
=
junk
;
metadata_color
=
junk
;
link_color
=
junk
test/test_config.py
View file @
c9c36d67
...
@@ -15,28 +15,130 @@
...
@@ -15,28 +15,130 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import
unittest
import
unittest
from
unittest
import
skip
from
test.topydo_testcase
import
TopydoTest
from
test.topydo_testcase
import
TopydoTest
from
topydo.lib.Config
import
config
from
topydo.lib.Config
import
config
class
ConfigTest
(
TopydoTest
):
class
ConfigTest
(
TopydoTest
):
def
test_config1
(
self
):
def
test_config
0
1
(
self
):
self
.
assertEqual
(
config
(
"test/data/
config1
"
).
default_command
(),
'do'
)
self
.
assertEqual
(
config
(
"test/data/
ConfigTest1.conf
"
).
default_command
(),
'do'
)
def
test_config2
(
self
):
def
test_config
0
2
(
self
):
self
.
assertNotEqual
(
config
(
""
).
default_command
(),
'do'
)
self
.
assertNotEqual
(
config
(
""
).
default_command
(),
'do'
)
def
test_config3
(
self
):
def
test_config
0
3
(
self
):
self
.
assertTrue
(
config
(
"test/data/
config2
"
).
ignore_weekends
())
self
.
assertTrue
(
config
(
"test/data/
ConfigTest2.conf
"
).
ignore_weekends
())
def
test_config4
(
self
):
def
test_config
0
4
(
self
):
""" Test that value in file is overridden by parameter. """
""" Test that value in file is overridden by parameter. """
overrides
=
{
overrides
=
{
(
'topydo'
,
'default_command'
):
'edit'
(
'topydo'
,
'default_command'
):
'edit'
}
}
self
.
assertEqual
(
config
(
"test/data/config1"
,
p_overrides
=
overrides
).
default_command
(),
'edit'
)
self
.
assertEqual
(
config
(
"test/data/ConfigTest1.conf"
,
p_overrides
=
overrides
).
default_command
(),
'edit'
)
def
test_config05
(
self
):
""" Bad colour switch value. """
# boolean settings must first be typecast to integers, because all
# strings evaulate to 'True'
self
.
assertEqual
(
config
(
"test/data/ConfigTest4.conf"
).
colors
(),
bool
(
int
(
config
().
defaults
[
"topydo"
][
"colors"
])))
def
test_config06
(
self
):
""" Bad auto creation date switch value. """
self
.
assertEqual
(
config
(
"test/data/ConfigTest4.conf"
).
auto_creation_date
(),
bool
(
int
(
config
().
defaults
[
"add"
][
"auto_creation_date"
])))
def
test_config07
(
self
):
""" Bad indent value. """
self
.
assertEqual
(
config
(
"test/data/ConfigTest4.conf"
).
list_indent
(),
int
(
config
().
defaults
[
"ls"
][
"indent"
]))
def
test_config08
(
self
):
""" Bad list limit value. """
self
.
assertEqual
(
config
(
"test/data/ConfigTest4.conf"
).
list_limit
(),
int
(
config
().
defaults
[
"ls"
][
"list_limit"
]))
def
test_config10
(
self
):
""" Bad keep sorted switch value. """
self
.
assertEqual
(
config
(
"test/data/ConfigTest4.conf"
).
keep_sorted
(),
bool
(
int
(
config
().
defaults
[
"sort"
][
"keep_sorted"
])))
def
test_config11
(
self
):
""" Bad ignore weekends switch value. """
self
.
assertEqual
(
config
(
"test/data/ConfigTest4.conf"
).
ignore_weekends
(),
bool
(
int
(
config
().
defaults
[
"sort"
][
"ignore_weekends"
])))
def
test_config12
(
self
):
""" Bad append parent projects switch value. """
self
.
assertEqual
(
config
(
"test/data/ConfigTest4.conf"
).
append_parent_projects
(),
bool
(
int
(
config
().
defaults
[
"dep"
][
"append_parent_projects"
])))
def
test_config13
(
self
):
""" Bad append parent project contexts switch value. """
self
.
assertEqual
(
config
(
"test/data/ConfigTest4.conf"
).
append_parent_contexts
(),
bool
(
int
(
config
().
defaults
[
"dep"
][
"append_parent_contexts"
])))
@
skip
(
"Error checking not yet implemented"
)
def
test_config14
(
self
):
""" Bad priority color value. """
self
.
assertEqual
(
config
(
"test/data/ConfigTest4.conf"
).
priority_colors
(),
config
().
defaults
[
"colorscheme"
][
"priority_colors"
])
@
skip
(
"Error checking not yet implemented"
)
def
test_config15
(
self
):
""" Bad project color value. """
self
.
assertEqual
(
config
(
"test/data/ConfigTest4.conf"
).
project_color
(),
config
().
defaults
[
"colorscheme"
][
"project_color"
])
@
skip
(
"Error checking not yet implemented"
)
def
test_config16
(
self
):
""" Bad context color value. """
self
.
assertEqual
(
config
(
"test/data/ConfigTest4.conf"
).
context_color
(),
config
().
defaults
[
"colorscheme"
][
"context_color"
])
@
skip
(
"Error checking not yet implemented"
)
def
test_config17
(
self
):
""" Bad metadata color value. """
self
.
assertEqual
(
config
(
"test/data/ConfigTest4.conf"
).
metadata_color
(),
config
().
defaults
[
"colorscheme"
][
"metadata_color"
])
@
skip
(
"Error checking not yet implemented"
)
def
test_config18
(
self
):
""" Bad link color value. """
self
.
assertEqual
(
config
(
"test/data/ConfigTest4.conf"
).
link_color
(),
config
().
defaults
[
"colorscheme"
][
"link_color"
])
@
skip
(
"Test not yet implemented"
)
# the test needs to be of the internal function _str_to_dict
def
test_config19
(
self
):
""" No priority color value. """
self
.
assertEqual
(
config
(
"test/data/ConfigTest4.conf"
).
priority_colors
(),
config
().
defaults
[
"colorscheme"
][
"priority_colors"
])
def
test_config20
(
self
):
""" No project color value. """
self
.
assertEqual
(
config
(
"test/data/ConfigTest5.conf"
).
project_color
(),
config
().
defaults
[
"colorscheme"
][
"project_color"
])
def
test_config21
(
self
):
""" No context color value. """
self
.
assertEqual
(
config
(
"test/data/ConfigTest5.conf"
).
context_color
(),
config
().
defaults
[
"colorscheme"
][
"context_color"
])
def
test_config22
(
self
):
""" No metadata color value. """
self
.
assertEqual
(
config
(
"test/data/ConfigTest5.conf"
).
metadata_color
(),
config
().
defaults
[
"colorscheme"
][
"metadata_color"
])
def
test_config23
(
self
):
""" No link color value. """
self
.
assertEqual
(
config
(
"test/data/ConfigTest5.conf"
).
link_color
(),
config
().
defaults
[
"colorscheme"
][
"link_color"
])
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
main
()
unittest
.
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment