Skip to content

Commit

Permalink
add kv_dup tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kellyjonbrazil committed Dec 22, 2023
1 parent cdd9a96 commit 8d4c920
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/test_kv_dup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import os
import unittest
import jc.parsers.kv_dup

THIS_DIR = os.path.dirname(os.path.abspath(__file__))


class MyTests(unittest.TestCase):

def test_kv_dup_nodata(self):
"""
Test the test kv file with no data
"""
self.assertEqual(jc.parsers.kv_dup.parse('', quiet=True), {})

def test_kv_dup_duplicate_keys(self):
"""
Test input that contains duplicate keys
"""
data = '''
duplicate_key: value1
another_key = foo
duplicate_key = value2
'''
expected = {"duplicate_key":["value1","value2"],"another_key":["foo"]}
self.assertEqual(jc.parsers.kv_dup.parse(data, quiet=True), expected)

def test_kv_dup_null_values(self):
"""
Test input that contains duplicate keys and null values
"""
data = '''
normal_key: "hello world"
no_val
some_vals = 1
some_vals
some_vals:3
'''
expected = {"normal_key":["hello world"],"no_val":[""],"some_vals":["1","","3"]}
self.assertEqual(jc.parsers.kv_dup.parse(data, quiet=True), expected)


if __name__ == '__main__':
unittest.main()

0 comments on commit 8d4c920

Please sign in to comment.