mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-08-08 22:36:48 +02:00
add tests for -F fixes
This commit is contained in:
1
tests/fixtures/debian10/sfdisk-F2.json
vendored
Normal file
1
tests/fixtures/debian10/sfdisk-F2.json
vendored
Normal file
@@ -0,0 +1 @@
|
||||
[{"disk":"/dev/sdc","free_disk_size":"1 GiB","free_bytes":1073741824,"free_sectors":2097152,"units":"sectors of 1 * 512 = 512 bytes","logical_sector_size":512,"physical_sector_size":512,"partitions":[{"start":4194304,"end":6291455,"sectors":2097152,"size":"1G"}]}]
|
6
tests/fixtures/debian10/sfdisk-F2.out
vendored
Normal file
6
tests/fixtures/debian10/sfdisk-F2.out
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
Unpartitioned space /dev/sdc: 1 GiB, 1073741824 bytes, 2097152 sectors
|
||||
Units: sectors of 1 * 512 = 512 bytes
|
||||
Sector size (logical/physical): 512 bytes / 512 bytes
|
||||
|
||||
Start End Sectors Size
|
||||
4194304 6291455 2097152 1G
|
1
tests/fixtures/debian10/sfdisk-l2.json
vendored
Normal file
1
tests/fixtures/debian10/sfdisk-l2.json
vendored
Normal file
@@ -0,0 +1 @@
|
||||
[{"disk":"/dev/sda","disk_size":"32 GiB","bytes":34359738368,"sectors":67108864,"disk_model":"QEMU HARDDISK","units":"sectors of 1 * 512 = 512 bytes","logical_sector_size":512,"physical_sector_size":512,"min_io_size":512,"optimal_io_size":512,"disk_label_type":"dos","disk_identifier":"0x4f1ce2bf","partitions":[{"device":"/dev/sda1","boot":true,"start":2048,"end":13260799,"sectors":13258752,"size":"6.3G","id":"83","type":"Linux"},{"device":"/dev/sda2","boot":false,"start":13262846,"end":67106815,"sectors":53843970,"size":"25.7G","id":"5","type":"Extended"},{"device":"/dev/sda5","boot":false,"start":13262848,"end":18331647,"sectors":5068800,"size":"2.4G","id":"83","type":"Linux"},{"device":"/dev/sda6","boot":false,"start":18333696,"end":20332543,"sectors":1998848,"size":"976M","id":"82","type":"Linux swap / Solaris"},{"device":"/dev/sda7","boot":false,"start":20334592,"end":21352447,"sectors":1017856,"size":"497M","id":"83","type":"Linux"},{"device":"/dev/sda8","boot":false,"start":21354496,"end":67106815,"sectors":45752320,"size":"21.8G","id":"83","type":"Linux"}]}]
|
15
tests/fixtures/debian10/sfdisk-l2.out
vendored
Normal file
15
tests/fixtures/debian10/sfdisk-l2.out
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
Disk /dev/sda: 32 GiB, 34359738368 bytes, 67108864 sectors
|
||||
Disk model: QEMU HARDDISK
|
||||
Units: sectors of 1 * 512 = 512 bytes
|
||||
Sector size (logical/physical): 512 bytes / 512 bytes
|
||||
I/O size (minimum/optimal): 512 bytes / 512 bytes
|
||||
Disklabel type: dos
|
||||
Disk identifier: 0x4f1ce2bf
|
||||
|
||||
Device Boot Start End Sectors Size Id Type
|
||||
/dev/sda1 * 2048 13260799 13258752 6.3G 83 Linux
|
||||
/dev/sda2 13262846 67106815 53843970 25.7G 5 Extended
|
||||
/dev/sda5 13262848 18331647 5068800 2.4G 83 Linux
|
||||
/dev/sda6 18333696 20332543 1998848 976M 82 Linux swap / Solaris
|
||||
/dev/sda7 20334592 21352447 1017856 497M 83 Linux
|
||||
/dev/sda8 21354496 67106815 45752320 21.8G 83 Linux
|
1
tests/fixtures/debian10/sfdisk-l3.json
vendored
Normal file
1
tests/fixtures/debian10/sfdisk-l3.json
vendored
Normal file
@@ -0,0 +1 @@
|
||||
[{"disk":"/dev/sda","disk_size":"238.5 GiB","bytes":256060514304,"sectors":500118192,"disk_model":"NT-256","units":"sectors of 1 * 512 = 512 bytes","logical_sector_size":512,"physical_sector_size":512,"min_io_size":512,"optimal_io_size":512,"disk_label_type":"gpt","disk_identifier":"50DEF501-A333-48D1-B1FC-C2F1CCFD5715","partitions":[{"device":"/dev/sda1","start":2048,"end":526335,"sectors":524288,"size":"256M","type":"Linux root (x86)"},{"device":"/dev/sda2","start":526336,"end":138545151,"sectors":138018816,"size":"65.8G","type":"Linux root (x86)"},{"device":"/dev/sda3","start":483684352,"end":500117503,"sectors":16433152,"size":"7.9G","type":"Linux swap"},{"device":"/dev/sda4","start":138545152,"end":483684351,"sectors":345139200,"size":"164.6G","type":"Linux filesystem"}]}]
|
13
tests/fixtures/debian10/sfdisk-l3.out
vendored
Normal file
13
tests/fixtures/debian10/sfdisk-l3.out
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
Disk /dev/sda: 238.5 GiB, 256060514304 bytes, 500118192 sectors
|
||||
Disk model: NT-256
|
||||
Units: sectors of 1 * 512 = 512 bytes
|
||||
Sector size (logical/physical): 512 bytes / 512 bytes
|
||||
I/O size (minimum/optimal): 512 bytes / 512 bytes
|
||||
Disklabel type: gpt
|
||||
Disk identifier: 50DEF501-A333-48D1-B1FC-C2F1CCFD5715
|
||||
|
||||
Device Start End Sectors Size Type
|
||||
/dev/sda1 2048 526335 524288 256M Linux root (x86)
|
||||
/dev/sda2 526336 138545151 138018816 65.8G Linux root (x86)
|
||||
/dev/sda3 483684352 500117503 16433152 7.9G Linux swap
|
||||
/dev/sda4 138545152 483684351 345139200 164.6G Linux filesystem
|
@@ -31,22 +31,26 @@ class MyTests(unittest.TestCase):
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/sfdisk-luS.out'), 'r', encoding='utf-8') as f:
|
||||
self.centos_7_7_sfdisk_luS = f.read()
|
||||
|
||||
|
||||
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-8/sfdisk-l.out'), 'r', encoding='utf-8') as f:
|
||||
self.centos_8_sfdisk_l = f.read()
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-8/sfdisk-F.out'), 'r', encoding='utf-8') as f:
|
||||
self.centos_8_sfdisk_F = f.read()
|
||||
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/debian10/sfdisk-l.out'), 'r', encoding='utf-8') as f:
|
||||
self.debian_10_sfdisk_l = f.read()
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/debian10/sfdisk-l2.out'), 'r', encoding='utf-8') as f:
|
||||
self.debian_10_sfdisk_l2 = f.read()
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/debian10/sfdisk-l3.out'), 'r', encoding='utf-8') as f:
|
||||
self.debian_10_sfdisk_l3 = f.read()
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/debian10/sfdisk-F.out'), 'r', encoding='utf-8') as f:
|
||||
self.debian_10_sfdisk_F = f.read()
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/debian10/sfdisk-F2.out'), 'r', encoding='utf-8') as f:
|
||||
self.debian_10_sfdisk_F2 = f.read()
|
||||
|
||||
|
||||
# output
|
||||
@@ -71,8 +75,6 @@ class MyTests(unittest.TestCase):
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/sfdisk-luS.json'), 'r', encoding='utf-8') as f:
|
||||
self.centos_7_7_sfdisk_luS_json = json.loads(f.read())
|
||||
|
||||
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-8/sfdisk-l.json'), 'r', encoding='utf-8') as f:
|
||||
self.centos_8_sfdisk_l_json = json.loads(f.read())
|
||||
|
||||
@@ -82,9 +84,19 @@ class MyTests(unittest.TestCase):
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/debian10/sfdisk-l.json'), 'r', encoding='utf-8') as f:
|
||||
self.debian_10_sfdisk_l_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/debian10/sfdisk-l2.json'), 'r', encoding='utf-8') as f:
|
||||
self.debian_10_sfdisk_l2_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/debian10/sfdisk-l3.json'), 'r', encoding='utf-8') as f:
|
||||
self.debian_10_sfdisk_l3_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/debian10/sfdisk-F.json'), 'r', encoding='utf-8') as f:
|
||||
self.debian_10_sfdisk_F_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/debian10/sfdisk-F2.json'), 'r', encoding='utf-8') as f:
|
||||
self.debian_10_sfdisk_F2_json = json.loads(f.read())
|
||||
|
||||
|
||||
def test_sfdisk_nodata(self):
|
||||
"""
|
||||
Test 'sfdisk' with no data
|
||||
@@ -133,7 +145,6 @@ class MyTests(unittest.TestCase):
|
||||
"""
|
||||
self.assertEqual(jc.parsers.sfdisk.parse(self.centos_7_7_sfdisk_luS, quiet=True), self.centos_7_7_sfdisk_luS_json)
|
||||
|
||||
|
||||
def test_sfdisk_l_centos_8(self):
|
||||
"""
|
||||
Test 'sfdisk -l' on Centos 8
|
||||
@@ -152,12 +163,30 @@ class MyTests(unittest.TestCase):
|
||||
"""
|
||||
self.assertEqual(jc.parsers.sfdisk.parse(self.debian_10_sfdisk_l, quiet=True), self.debian_10_sfdisk_l_json)
|
||||
|
||||
def test_sfdisk_l2_debian_10(self):
|
||||
"""
|
||||
Test 'sfdisk -l' on Debian 10 (second example)
|
||||
"""
|
||||
self.assertEqual(jc.parsers.sfdisk.parse(self.debian_10_sfdisk_l2, quiet=True), self.debian_10_sfdisk_l2_json)
|
||||
|
||||
def test_sfdisk_l3_debian_10(self):
|
||||
"""
|
||||
Test 'sfdisk -l' on Debian 10 (third example)
|
||||
"""
|
||||
self.assertEqual(jc.parsers.sfdisk.parse(self.debian_10_sfdisk_l3, quiet=True), self.debian_10_sfdisk_l3_json)
|
||||
|
||||
def test_sfdisk_F_debian10(self):
|
||||
"""
|
||||
Test 'sfdisk -F' on Debian 10
|
||||
"""
|
||||
self.assertEqual(jc.parsers.sfdisk.parse(self.debian_10_sfdisk_F, quiet=True), self.debian_10_sfdisk_F_json)
|
||||
|
||||
def test_sfdisk_F2_debian10(self):
|
||||
"""
|
||||
Test 'sfdisk -F' on Debian 10 (second example)
|
||||
"""
|
||||
self.assertEqual(jc.parsers.sfdisk.parse(self.debian_10_sfdisk_F2, quiet=True), self.debian_10_sfdisk_F2_json)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Reference in New Issue
Block a user