summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2014-10-29 03:04:34 +0100
committermathieui <mathieui@mathieui.net>2014-10-29 03:07:40 +0100
commit70befec8cad1633baee30530e353bca5da9b8d32 (patch)
tree8ec073314fec3ad272f8ce29bb949212732885b8
parentc3aa6c029d67a9612ebabf84784a6571fa603e4c (diff)
downloadpoezio-70befec8cad1633baee30530e353bca5da9b8d32.tar.gz
poezio-70befec8cad1633baee30530e353bca5da9b8d32.tar.bz2
poezio-70befec8cad1633baee30530e353bca5da9b8d32.tar.xz
poezio-70befec8cad1633baee30530e353bca5da9b8d32.zip
Add some tests
- also fix that travis build
-rw-r--r--.travis.yml2
-rw-r--r--Makefile2
-rw-r--r--test/test_common.py23
-rw-r--r--test/test_theming.py26
4 files changed, 43 insertions, 10 deletions
diff --git a/.travis.yml b/.travis.yml
index 2c27b4a1..28bf3dd3 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,5 +3,5 @@ python:
- "3.4"
install:
- pip install -r requirements.txt
- - python setup.py build
+ - python setup.py build_ext --inplace
script: make test
diff --git a/Makefile b/Makefile
index 5b11efa6..7f5eb224 100644
--- a/Makefile
+++ b/Makefile
@@ -34,7 +34,7 @@ doc:
make -C doc/ html
test:
- py.test test/
+ py.test -v test/
pot:
xgettext src/*.py --from-code=utf-8 --keyword=_ -o locale/poezio.pot
diff --git a/test/test_common.py b/test/test_common.py
index 36680328..315318bd 100644
--- a/test/test_common.py
+++ b/test/test_common.py
@@ -2,16 +2,17 @@
Test the functions in the `common` module
"""
-import pytest
import sys
sys.path.append('src')
-from common import (datetime_tuple, get_utc_time, get_local_time, shell_split,
- find_argument_quoted, find_argument_unquoted,
- parse_str_to_secs, parse_secs_to_str)
import time
-from datetime import timedelta
+import pytest
import datetime
+from sleekxmpp import JID
+from datetime import timedelta
+from common import (datetime_tuple, get_utc_time, get_local_time, shell_split,
+ find_argument_quoted, find_argument_unquoted,
+ parse_str_to_secs, parse_secs_to_str, safeJID)
def test_datetime_tuple():
time.timezone = 0
@@ -39,8 +40,6 @@ def test_local_time():
time.altzone = -3600
assert get_local_time(d) == d - delta
-#def find_delayed_tag(message):
-
def test_shell_split():
assert shell_split('"sdf 1" "toto 2"') == ['sdf 1', 'toto 2']
assert shell_split('toto "titi"') == ['toto', 'titi']
@@ -69,4 +68,12 @@ def test_parse_str_to_secs():
assert parse_str_to_secs("1d3mfaiiiiil") == 0
def test_parse_secs_to_str():
- assert parse_secs_to_str(3601) == '1h1s'
+ assert parse_secs_to_str(3601) == '1h1s'
+ assert parse_secs_to_str(0) == '0s'
+
+ with pytest.raises(TypeError):
+ parse_secs_to_str('toto')
+
+def test_safeJID():
+ assert safeJID('toto@titi/tata') == JID('toto@titi/tata')
+ assert safeJID('é_è') == JID('')
diff --git a/test/test_theming.py b/test/test_theming.py
new file mode 100644
index 00000000..9cdb4829
--- /dev/null
+++ b/test/test_theming.py
@@ -0,0 +1,26 @@
+"""
+Test the functions in the `theming` module
+"""
+
+import sys
+import pytest
+sys.path.append('src')
+
+from theming import dump_tuple, read_tuple
+
+def test_read_tuple():
+ assert read_tuple('1,-1,u') == ((1, -1), 'u')
+ assert read_tuple('1,2') == ((1, 2), None)
+
+ with pytest.raises(IndexError):
+ read_tuple('1')
+
+ with pytest.raises(ValueError):
+ read_tuple('toto')
+
+def test_dump_tuple():
+ assert dump_tuple((1, 2)) == '1,2'
+ assert dump_tuple((1, )) == '1'
+ assert dump_tuple((1, 2, 'u')) == '1,2,u'
+
+