|
| 1 | +#!/usr/bin/env python |
| 2 | +# -*- coding: utf8 -*- |
| 3 | + |
| 4 | +# ============================================================================ |
| 5 | +# Copyright (c) 2014-2019 nexB Inc. http://www.nexb.com/ - All rights reserved. |
| 6 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | +# you may not use this file except in compliance with the License. |
| 8 | +# You may obtain a copy of the License at |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | +# ============================================================================ |
| 16 | + |
| 17 | +from __future__ import absolute_import |
| 18 | +from __future__ import print_function |
| 19 | +from __future__ import unicode_literals |
| 20 | + |
| 21 | +from collections import OrderedDict |
| 22 | +import unittest |
| 23 | + |
| 24 | +from testing_utils import get_temp_dir |
| 25 | +from testing_utils import get_test_loc |
| 26 | + |
| 27 | +from attributecode import ERROR |
| 28 | +from attributecode import INFO |
| 29 | +from attributecode import CRITICAL |
| 30 | +from attributecode import Error |
| 31 | +from attributecode import gen |
| 32 | +from attributecode.transform import read_csv_rows |
| 33 | +from attributecode.transform import transform_data |
| 34 | +from attributecode.transform import Transformer |
| 35 | + |
| 36 | + |
| 37 | +class TransformTest(unittest.TestCase): |
| 38 | + def test_transform_data(self): |
| 39 | + test_file = get_test_loc('test_transform/input.csv') |
| 40 | + configuration = get_test_loc('test_transform/configuration') |
| 41 | + rows = read_csv_rows(test_file) |
| 42 | + transformer = Transformer.from_file(configuration) |
| 43 | + col_name, data, err = transform_data(rows, transformer) |
| 44 | + expect = [u'about_resource', u'name'] |
| 45 | + assert col_name == expect |
0 commit comments