Rich Lane | 62a5649 | 2013-05-10 15:28:04 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # Copyright 2013, Big Switch Networks, Inc. |
| 3 | # |
| 4 | # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with |
| 5 | # the following special exception: |
| 6 | # |
| 7 | # LOXI Exception |
| 8 | # |
| 9 | # As a special exception to the terms of the EPL, you may distribute libraries |
| 10 | # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided |
| 11 | # that copyright and licensing notices generated by LoxiGen are not altered or removed |
| 12 | # from the LoxiGen Libraries and the notice provided below is (i) included in |
| 13 | # the LoxiGen Libraries, if distributed in source code form and (ii) included in any |
| 14 | # documentation for the LoxiGen Libraries, if distributed in binary form. |
| 15 | # |
| 16 | # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler." |
| 17 | # |
| 18 | # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain |
| 19 | # a copy of the EPL at: |
| 20 | # |
| 21 | # http://www.eclipse.org/legal/epl-v10.html |
| 22 | # |
| 23 | # Unless required by applicable law or agreed to in writing, software |
| 24 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 25 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 26 | # EPL for the specific language governing permissions and limitations |
| 27 | # under the EPL. |
| 28 | |
Rich Lane | 569338c | 2013-06-17 15:51:24 -0700 | [diff] [blame] | 29 | import sys |
| 30 | import os |
Rich Lane | 62a5649 | 2013-05-10 15:28:04 -0700 | [diff] [blame] | 31 | import unittest |
Rich Lane | 569338c | 2013-06-17 15:51:24 -0700 | [diff] [blame] | 32 | |
| 33 | root_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..') |
| 34 | sys.path.insert(0, root_dir) |
| 35 | |
Rich Lane | 62a5649 | 2013-05-10 15:28:04 -0700 | [diff] [blame] | 36 | import test_data |
| 37 | |
| 38 | class DataFileTests(unittest.TestCase): |
| 39 | def test_example(self): |
| 40 | self.assertTrue('./example.data' in test_data.list_files()) |
| 41 | data = test_data.read('example.data') |
| 42 | self.assertEquals(sorted(['section1', 'section2', 'binary']), sorted(data.keys())) |
Rich Lane | a0ee636 | 2013-05-16 16:35:35 -0700 | [diff] [blame] | 43 | self.assertEquals(' abc def\nghi', data['section1']) |
Rich Lane | 62a5649 | 2013-05-10 15:28:04 -0700 | [diff] [blame] | 44 | self.assertEquals('123\n456\n789', data['section2']) |
| 45 | self.assertEquals('\x00\x01\x02\x03\x04\x05\x06\x07\x77\x66\x55\x44\x33\x22\x11\x00', |
| 46 | data['binary']) |
| 47 | |
| 48 | # Just make sure all included data files parse without exceptions |
| 49 | def test_all(self): |
| 50 | for name in test_data.list_files(): |
| 51 | test_data.read(name) |
| 52 | |
| 53 | if __name__ == '__main__': |
| 54 | unittest.main() |