Skip to content

Commit 5ddb1fd

Browse files
committed
Fixed #480 - Add tests
Signed-off-by: Chin Yeung Li <[email protected]>
1 parent 3ebd81f commit 5ddb1fd

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

tests/test_transform.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
from testing_utils import get_test_loc
2121

2222
from attributecode.transform import check_duplicate_fields
23-
from attributecode.transform import read_json
2423
from attributecode.transform import transform_data
2524
from attributecode.transform import normalize_dict_data
2625
from attributecode.transform import strip_trailing_fields_csv
2726
from attributecode.transform import strip_trailing_fields_json
2827
from attributecode.transform import Transformer
28+
from attributecode.transform import read_csv_rows, read_excel, read_json
2929

3030

3131
class TransformTest(unittest.TestCase):
@@ -157,3 +157,19 @@ def test_strip_trailing_fields_json(self):
157157
expected = [OrderedDict([(u'about_resource', u'/this.c'), (u'name', u'this.c'), (u'version', u'0.11.0')])]
158158
result = strip_trailing_fields_json(test)
159159
assert result == expected
160+
161+
def test_read_excel(self):
162+
test_file = get_test_loc('test_transform/simple.xlsx')
163+
error, data = read_excel(test_file)
164+
assert not error
165+
expected = [OrderedDict([('about_resource', '/test.c'), ('name', 'test.c'), ('license_expression', 'mit')]),
166+
OrderedDict([('about_resource', '/test2.c'), ('name', 'test2.c'), ('license_expression', 'mit and apache-2.0')])]
167+
assert data == expected
168+
169+
def test_read_csv_rows(self):
170+
test_file = get_test_loc('test_transform/simple.csv')
171+
data = read_csv_rows(test_file)
172+
expected = [['about_resource', 'name', 'license_expression'],
173+
['/test.c', 'test.c', 'mit'],
174+
['/test2.c', 'test2.c', 'mit and apache-2.0']]
175+
assert list(data) == expected
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
about_resource,name,license_expression
2+
/test.c,test.c,mit
3+
/test2.c,test2.c,mit and apache-2.0
9.82 KB
Binary file not shown.

0 commit comments

Comments
 (0)