|
20 | 20 | from testing_utils import get_test_loc |
21 | 21 |
|
22 | 22 | from attributecode.transform import check_duplicate_fields |
23 | | -from attributecode.transform import read_json |
24 | 23 | from attributecode.transform import transform_data |
25 | 24 | from attributecode.transform import normalize_dict_data |
26 | 25 | from attributecode.transform import strip_trailing_fields_csv |
27 | 26 | from attributecode.transform import strip_trailing_fields_json |
28 | 27 | from attributecode.transform import Transformer |
| 28 | +from attributecode.transform import read_csv_rows, read_excel, read_json |
29 | 29 |
|
30 | 30 |
|
31 | 31 | class TransformTest(unittest.TestCase): |
@@ -157,3 +157,19 @@ def test_strip_trailing_fields_json(self): |
157 | 157 | expected = [OrderedDict([(u'about_resource', u'/this.c'), (u'name', u'this.c'), (u'version', u'0.11.0')])] |
158 | 158 | result = strip_trailing_fields_json(test) |
159 | 159 | 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 |
0 commit comments