1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-07-15 01:24:29 +02:00

update test templates

This commit is contained in:
Kelly Brazil
2022-11-01 17:01:21 -07:00
parent ac1bcd2918
commit de7a010f62
4 changed files with 40 additions and 28 deletions

View File

@ -2,7 +2,7 @@ import os
import unittest
import json
from typing import Dict
import jc.parsers.foo
from jc.parsers.foo import parse
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
@ -30,14 +30,17 @@ class MyTests(unittest.TestCase):
"""
Test 'foo' with no data
"""
self.assertEqual(jc.parsers.foo.parse('', quiet=True), [])
self.assertEqual(parse('', quiet=True), [])
def test_foo_centos_7_7(self):
"""
Test 'foo' on Centos 7.7
"""
self.assertEqual(jc.parsers.foo.parse(self.f_in['centos_7_7_foo'], quiet=True),
self.f_json['centos_7_7_foo'])
self.assertEqual(parse(
self.f_in['centos_7_7_foo'], quiet=True),
self.f_json['centos_7_7_foo']
)
if __name__ == '__main__':

View File

@ -2,7 +2,7 @@ import os
import json
import unittest
from typing import Dict
import jc.parsers.foo_s
from jc.parsers.foo_s import parse
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
@ -33,14 +33,17 @@ class MyTests(unittest.TestCase):
"""
Test 'foo' with no data
"""
self.assertEqual(list(jc.parsers.foo_s.parse([], quiet=True)), [])
self.assertEqual(list(parse([], quiet=True)), [])
def test_foo_s_centos_7_7(self):
"""
Test 'foo' on Centos 7.7
"""
self.assertEqual(list(jc.parsers.foo_s.parse(self.f_in['centos_7_7_foo'].splitlines(), quiet=True)),
self.f_json['centos_7_7_foo'])
self.assertEqual(
list(parse(self.f_in['centos_7_7_foo'].splitlines(), quiet=True)),
self.f_json['centos_7_7_foo']
)
if __name__ == '__main__':

View File

@ -2,7 +2,7 @@ import os
import unittest
import json
from typing import Dict
import jc.parsers.findmnt
from jc.parsers.findmnt import parse
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
@ -36,28 +36,34 @@ class MyTests(unittest.TestCase):
"""
Test 'findmnt' with no data
"""
self.assertEqual(jc.parsers.findmnt.parse('', quiet=True), [])
self.assertEqual(parse('', quiet=True), [])
def test_findmnt_centos_7_7(self):
"""
Test 'findmnt' on Centos 7.7
"""
self.assertEqual(jc.parsers.findmnt.parse(self.f_in['centos_7_7_findmnt'], quiet=True),
self.f_json['centos_7_7_findmnt'])
self.assertEqual(
parse(self.f_in['centos_7_7_findmnt'], quiet=True),
self.f_json['centos_7_7_findmnt']
)
def test_findmnt_a_centos_7_7(self):
"""
Test 'findmnt -a' on Centos 7.7
"""
self.assertEqual(jc.parsers.findmnt.parse(self.f_in['centos_7_7_findmnt_a'], quiet=True),
self.f_json['centos_7_7_findmnt_a'])
self.assertEqual(
parse(self.f_in['centos_7_7_findmnt_a'], quiet=True),
self.f_json['centos_7_7_findmnt_a']
)
def test_findmnt_l_centos_7_7(self):
"""
Test 'findmnt -l' on Centos 7.7
"""
self.assertEqual(jc.parsers.findmnt.parse(self.f_in['centos_7_7_findmnt_l'], quiet=True),
self.f_json['centos_7_7_findmnt_l'])
self.assertEqual(
parse(self.f_in['centos_7_7_findmnt_l'], quiet=True),
self.f_json['centos_7_7_findmnt_l']
)
if __name__ == '__main__':

View File

@ -11,7 +11,7 @@ class MyTests(unittest.TestCase):
self.assertEqual(jc.parsers.url.parse('', quiet=True), {})
def test_mailto(self):
def test_url_mailto(self):
"""
Test mailto URL
"""
@ -20,7 +20,7 @@ class MyTests(unittest.TestCase):
self.assertEqual(jc.parsers.url.parse(data, quiet=True), expected)
def test_ftp(self):
def test_url_ftp(self):
"""
Test ftp URL
"""
@ -29,7 +29,7 @@ class MyTests(unittest.TestCase):
self.assertEqual(jc.parsers.url.parse(data, quiet=True), expected)
def test_http_ipv4(self):
def test_url_http_ipv4(self):
"""
Test HTTP URL with encodable characters (ipv4 host)
"""
@ -38,7 +38,7 @@ class MyTests(unittest.TestCase):
self.assertEqual(jc.parsers.url.parse(data, quiet=True), expected)
def test_http_ipv6(self):
def test_url_http_ipv6(self):
"""
Test HTTP URL with encodable characters (ipv6 host)
"""
@ -47,7 +47,7 @@ class MyTests(unittest.TestCase):
self.assertEqual(jc.parsers.url.parse(data, quiet=True), expected)
def test_http_domain(self):
def test_url_http_domain(self):
"""
Test HTTP URL with encodable characters (domain name host)
"""
@ -56,7 +56,7 @@ class MyTests(unittest.TestCase):
self.assertEqual(jc.parsers.url.parse(data, quiet=True), expected)
def test_http_encoded(self):
def test_url_http_encoded(self):
"""
Test HTTP URL with encoded characters
"""
@ -65,7 +65,7 @@ class MyTests(unittest.TestCase):
self.assertEqual(jc.parsers.url.parse(data, quiet=True), expected)
def test_http_encodable_host_and_port(self):
def test_url_http_encodable_host_and_port(self):
"""
Test HTTP URL with encodable characters in the hostname and port
"""
@ -74,7 +74,7 @@ class MyTests(unittest.TestCase):
self.assertEqual(jc.parsers.url.parse(data, quiet=True), expected)
def test_http_encoded_host_and_port(self):
def test_url_http_encoded_host_and_port(self):
"""
Test HTTP URL with encoded characters in the hostname and port
"""
@ -83,7 +83,7 @@ class MyTests(unittest.TestCase):
self.assertEqual(jc.parsers.url.parse(data, quiet=True), expected)
def test_http_encoded_host_and_invalid_port(self):
def test_url_http_encoded_host_and_invalid_port(self):
"""
Test HTTP URL with encoded characters in the hostname and an invalid encoded port
"""
@ -92,7 +92,7 @@ class MyTests(unittest.TestCase):
self.assertEqual(jc.parsers.url.parse(data, quiet=True), expected)
def test_http_path_ends_in_slash(self):
def test_url_http_path_ends_in_slash(self):
"""
Test HTTP URL with a forward slash as the last part of the path
"""
@ -101,7 +101,7 @@ class MyTests(unittest.TestCase):
self.assertEqual(jc.parsers.url.parse(data, quiet=True), expected)
def test_http_path_only_slash(self):
def test_url_http_path_only_slash(self):
"""
Test HTTP URL with a forward slash as the last only part of the path
"""
@ -110,7 +110,7 @@ class MyTests(unittest.TestCase):
self.assertEqual(jc.parsers.url.parse(data, quiet=True), expected)
def test_http_path_no_end_slash(self):
def test_url_http_path_no_end_slash(self):
"""
Test HTTP URL with no forward slash at the end
"""