Skip to content

Commit 7c7fb7c

Browse files
committed
tests/test_generate_schema.py: Add unit test for json_full_path() (see #52)
1 parent 4560d15 commit 7c7fb7c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/test_generate_schema.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from bigquery_schema_generator.generate_schema import SchemaGenerator
2323
from bigquery_schema_generator.generate_schema import is_string_type
2424
from bigquery_schema_generator.generate_schema import convert_type
25+
from bigquery_schema_generator.generate_schema import json_full_path
2526
from .data_reader import DataReader
2627

2728

@@ -414,6 +415,15 @@ def test_run_with_invalid_input_throws_exception(self):
414415
with self.assertRaises(Exception):
415416
generator.run(input, output)
416417

418+
def test_json_full_path(self):
419+
self.assertEqual('port', json_full_path(None, 'port'))
420+
self.assertEqual('port', json_full_path("", 'port'))
421+
422+
# 'base_path' should never be '0', but if is do something reasonable.
423+
self.assertEqual('0.port', json_full_path(0, 'port'))
424+
425+
self.assertEqual('server.port', json_full_path('server', 'port'))
426+
417427

418428
class TestFromDataFile(unittest.TestCase):
419429
"""Read the test case data from TESTDATA_FILE and verify that the expected

0 commit comments

Comments
 (0)