1
0
mirror of https://github.com/wting/autojump synced 2024-10-27 20:34:07 +00:00
wting_autojump/tests/autojump_data_test.py
2016-04-19 12:49:00 +08:00

53 lines
1.0 KiB
Python

import os
import sys
sys.path.append(os.path.join(os.getcwd(), 'bin'))
from autojump_data import (
entriefy,
dictify,
parse_data,
Entry,
)
def test_entriefy():
assert list(entriefy({})) == []
data = {
"path1": 10,
"path2": 12
}
r = entriefy(data)
assert set(r) == set([Entry("path1", 10), Entry("path2", 12)])
def test_dictify():
assert dictify([]) == {}
entries = [Entry("path1", 10), Entry("path2", 12)]
assert dictify(entries) == {
"path1": 10,
"path2": 12
}
class TestParseData:
def test_valid_data_should_be_parsed(self):
data = [
"10.0\tpath_a",
"12.3\tpath_a/path_b"
]
assert parse_data(data) == {
"path_a": 10.0,
"path_a/path_b": 12.3
}
def test_invalid_data_should_be_ignored(self):
data = [
"10.0\tpath_a\tnada",
"12.3",
"10.0\tpath_a",
]
assert parse_data(data) == {
"path_a": 10.0
}