mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-07-05 00:49:03 +02:00
update lsblk tests
This commit is contained in:
2
tests/fixtures/centos-7.7/lsblk-allcols.json
vendored
2
tests/fixtures/centos-7.7/lsblk-allcols.json
vendored
@ -1 +1 @@
|
||||
[{"name": "sda", "maj_min": "8:0", "rm": false, "size": "20G", "ro": false, "type": "disk", "mountpoint": null, "kname": "sda", "fstype": null, "label": null, "uuid": null, "partlabel": null, "partuuid": null, "ra": 4096, "model": "VMware Virtual S", "serial": null, "state": "running", "owner": "root", "group": "disk", "mode": "brw-rw----", "alignment": 0, "min_io": 512, "opt_io": 0, "phy_sec": 512, "log_sec": 512, "rota": true, "sched": "deadline", "rq_size": 128, "disc_aln": 0, "disc_gran": "0B", "disc_max": "0B", "disc_zero": false, "wsame": "32M", "wwn": null, "rand": true, "pkname": null, "hctl": "0:0:0:0", "tran": "spi", "rev": "1.0", "vendor": "VMware,"}, {"name": "sda1", "maj_min": "8:1", "rm": false, "size": "1G", "ro": false, "type": "part", "mountpoint": "/boot", "kname": "sda1", "fstype": "xfs", "label": null, "uuid": "05d927bb-5875-49e3-ada1-7f46cb31c932", "partlabel": null, "partuuid": null, "ra": 4096, "model": null, "serial": null, "state": null, "owner": "root", "group": "disk", "mode": "brw-rw----", "alignment": 0, "min_io": 512, "opt_io": 0, "phy_sec": 512, "log_sec": 512, "rota": true, "sched": "deadline", "rq_size": 128, "disc_aln": 0, "disc_gran": "0B", "disc_max": "0B", "disc_zero": false, "wsame": "32M", "wwn": null, "rand": true, "pkname": "sda", "hctl": null, "tran": null, "rev": null, "vendor": null}, {"name": "sda2", "maj_min": "8:2", "rm": false, "size": "19G", "ro": false, "type": "part", "mountpoint": null, "kname": "sda2", "fstype": "LVM2_member", "label": null, "uuid": "3klkIj-w1qk-DkJi-0XBJ-y3o7-i2Ac-vHqWBM", "partlabel": null, "partuuid": null, "ra": 4096, "model": null, "serial": null, "state": null, "owner": "root", "group": "disk", "mode": "brw-rw----", "alignment": 0, "min_io": 512, "opt_io": 0, "phy_sec": 512, "log_sec": 512, "rota": true, "sched": "deadline", "rq_size": 128, "disc_aln": 0, "disc_gran": "0B", "disc_max": "0B", "disc_zero": false, "wsame": "32M", "wwn": null, "rand": true, "pkname": "sda", "hctl": null, "tran": null, "rev": null, "vendor": null}, {"name": "centos-root", "maj_min": "253:0", "rm": false, "size": "17G", "ro": false, "type": "lvm", "mountpoint": "/", "kname": "dm-0", "fstype": "xfs", "label": null, "uuid": "07d718ef-950c-4e5b-98e0-42a1147b77d9", "partlabel": null, "partuuid": null, "ra": 4096, "model": null, "serial": null, "state": "running", "owner": "root", "group": "disk", "mode": "brw-rw----", "alignment": 0, "min_io": 512, "opt_io": 0, "phy_sec": 512, "log_sec": 512, "rota": true, "sched": null, "rq_size": 128, "disc_aln": 0, "disc_gran": "0B", "disc_max": "0B", "disc_zero": false, "wsame": "32M", "wwn": null, "rand": false, "pkname": "sda2", "hctl": null, "tran": null, "rev": null, "vendor": null}, {"name": "centos-swap", "maj_min": "253:1", "rm": false, "size": "2G", "ro": false, "type": "lvm", "mountpoint": "[SWAP]", "kname": "dm-1", "fstype": "swap", "label": null, "uuid": "615eb89d-bcbf-46ad-80e3-c483ef5c931f", "partlabel": null, "partuuid": null, "ra": 4096, "model": null, "serial": null, "state": "running", "owner": "root", "group": "disk", "mode": "brw-rw----", "alignment": 0, "min_io": 512, "opt_io": 0, "phy_sec": 512, "log_sec": 512, "rota": true, "sched": null, "rq_size": 128, "disc_aln": 0, "disc_gran": "0B", "disc_max": "0B", "disc_zero": false, "wsame": "32M", "wwn": null, "rand": false, "pkname": "sda2", "hctl": null, "tran": null, "rev": null, "vendor": null}, {"name": "sr0", "maj_min": "11:0", "rm": true, "size": "1024M", "ro": false, "type": "rom", "mountpoint": null, "kname": "sr0", "fstype": null, "label": null, "uuid": null, "partlabel": null, "partuuid": null, "ra": 128, "model": "VMware IDE CDR10", "serial": "10000000000000000001", "state": "running", "owner": "root", "group": "cdrom", "mode": "brw-rw----", "alignment": 0, "min_io": 512, "opt_io": 0, "phy_sec": 512, "log_sec": 512, "rota": true, "sched": "deadline", "rq_size": 128, "disc_aln": 0, "disc_gran": "0B", "disc_max": "0B", "disc_zero": false, "wsame": "0B", "wwn": null, "rand": true, "pkname": null, "hctl": "2:0:0:0", "tran": "ata", "rev": "1.00", "vendor": "NECVMWar"}]
|
||||
[{"name":"sda","maj_min":"8:0","rm":false,"size":"20G","ro":false,"type":"disk","mountpoint":null,"kname":"sda","fstype":null,"label":null,"uuid":null,"partlabel":null,"partuuid":null,"ra":4096,"model":"VMware Virtual S","serial":null,"state":"running","owner":"root","group":"disk","mode":"brw-rw----","alignment":0,"min_io":512,"opt_io":0,"phy_sec":512,"log_sec":512,"rota":true,"sched":"deadline","rq_size":128,"disc_aln":0,"disc_gran":"0B","disc_max":"0B","disc_zero":false,"wsame":"32M","wwn":null,"rand":true,"pkname":null,"hctl":"0:0:0:0","tran":"spi","rev":"1.0","vendor":"VMware,","size_bytes":20000000000,"disc_gran_bytes":0,"disc_max_bytes":0,"wsame_bytes":32000000},{"name":"sda1","maj_min":"8:1","rm":false,"size":"1G","ro":false,"type":"part","mountpoint":"/boot","kname":"sda1","fstype":"xfs","label":null,"uuid":"05d927bb-5875-49e3-ada1-7f46cb31c932","partlabel":null,"partuuid":null,"ra":4096,"model":null,"serial":null,"state":null,"owner":"root","group":"disk","mode":"brw-rw----","alignment":0,"min_io":512,"opt_io":0,"phy_sec":512,"log_sec":512,"rota":true,"sched":"deadline","rq_size":128,"disc_aln":0,"disc_gran":"0B","disc_max":"0B","disc_zero":false,"wsame":"32M","wwn":null,"rand":true,"pkname":"sda","hctl":null,"tran":null,"rev":null,"vendor":null,"size_bytes":1000000000,"disc_gran_bytes":0,"disc_max_bytes":0,"wsame_bytes":32000000},{"name":"sda2","maj_min":"8:2","rm":false,"size":"19G","ro":false,"type":"part","mountpoint":null,"kname":"sda2","fstype":"LVM2_member","label":null,"uuid":"3klkIj-w1qk-DkJi-0XBJ-y3o7-i2Ac-vHqWBM","partlabel":null,"partuuid":null,"ra":4096,"model":null,"serial":null,"state":null,"owner":"root","group":"disk","mode":"brw-rw----","alignment":0,"min_io":512,"opt_io":0,"phy_sec":512,"log_sec":512,"rota":true,"sched":"deadline","rq_size":128,"disc_aln":0,"disc_gran":"0B","disc_max":"0B","disc_zero":false,"wsame":"32M","wwn":null,"rand":true,"pkname":"sda","hctl":null,"tran":null,"rev":null,"vendor":null,"size_bytes":19000000000,"disc_gran_bytes":0,"disc_max_bytes":0,"wsame_bytes":32000000},{"name":"centos-root","maj_min":"253:0","rm":false,"size":"17G","ro":false,"type":"lvm","mountpoint":"/","kname":"dm-0","fstype":"xfs","label":null,"uuid":"07d718ef-950c-4e5b-98e0-42a1147b77d9","partlabel":null,"partuuid":null,"ra":4096,"model":null,"serial":null,"state":"running","owner":"root","group":"disk","mode":"brw-rw----","alignment":0,"min_io":512,"opt_io":0,"phy_sec":512,"log_sec":512,"rota":true,"sched":null,"rq_size":128,"disc_aln":0,"disc_gran":"0B","disc_max":"0B","disc_zero":false,"wsame":"32M","wwn":null,"rand":false,"pkname":"sda2","hctl":null,"tran":null,"rev":null,"vendor":null,"size_bytes":17000000000,"disc_gran_bytes":0,"disc_max_bytes":0,"wsame_bytes":32000000},{"name":"centos-swap","maj_min":"253:1","rm":false,"size":"2G","ro":false,"type":"lvm","mountpoint":"[SWAP]","kname":"dm-1","fstype":"swap","label":null,"uuid":"615eb89d-bcbf-46ad-80e3-c483ef5c931f","partlabel":null,"partuuid":null,"ra":4096,"model":null,"serial":null,"state":"running","owner":"root","group":"disk","mode":"brw-rw----","alignment":0,"min_io":512,"opt_io":0,"phy_sec":512,"log_sec":512,"rota":true,"sched":null,"rq_size":128,"disc_aln":0,"disc_gran":"0B","disc_max":"0B","disc_zero":false,"wsame":"32M","wwn":null,"rand":false,"pkname":"sda2","hctl":null,"tran":null,"rev":null,"vendor":null,"size_bytes":2000000000,"disc_gran_bytes":0,"disc_max_bytes":0,"wsame_bytes":32000000},{"name":"sr0","maj_min":"11:0","rm":true,"size":"1024M","ro":false,"type":"rom","mountpoint":null,"kname":"sr0","fstype":null,"label":null,"uuid":null,"partlabel":null,"partuuid":null,"ra":128,"model":"VMware IDE CDR10","serial":"10000000000000000001","state":"running","owner":"root","group":"cdrom","mode":"brw-rw----","alignment":0,"min_io":512,"opt_io":0,"phy_sec":512,"log_sec":512,"rota":true,"sched":"deadline","rq_size":128,"disc_aln":0,"disc_gran":"0B","disc_max":"0B","disc_zero":false,"wsame":"0B","wwn":null,"rand":true,"pkname":null,"hctl":"2:0:0:0","tran":"ata","rev":"1.00","vendor":"NECVMWar","size_bytes":1024000000,"disc_gran_bytes":0,"disc_max_bytes":0,"wsame_bytes":0}]
|
||||
|
2
tests/fixtures/centos-7.7/lsblk.json
vendored
2
tests/fixtures/centos-7.7/lsblk.json
vendored
@ -1 +1 @@
|
||||
[{"name": "sda", "maj_min": "8:0", "rm": false, "size": "20G", "ro": false, "type": "disk", "mountpoint": null}, {"name": "sda1", "maj_min": "8:1", "rm": false, "size": "1G", "ro": false, "type": "part", "mountpoint": "/boot"}, {"name": "sda2", "maj_min": "8:2", "rm": false, "size": "19G", "ro": false, "type": "part", "mountpoint": null}, {"name": "centos-root", "maj_min": "253:0", "rm": false, "size": "17G", "ro": false, "type": "lvm", "mountpoint": "/"}, {"name": "centos-swap", "maj_min": "253:1", "rm": false, "size": "2G", "ro": false, "type": "lvm", "mountpoint": "[SWAP]"}, {"name": "sr0", "maj_min": "11:0", "rm": true, "size": "1024M", "ro": false, "type": "rom", "mountpoint": null}]
|
||||
[{"name":"sda","maj_min":"8:0","rm":false,"size":"20G","ro":false,"type":"disk","mountpoint":null,"size_bytes":20000000000},{"name":"sda1","maj_min":"8:1","rm":false,"size":"1G","ro":false,"type":"part","mountpoint":"/boot","size_bytes":1000000000},{"name":"sda2","maj_min":"8:2","rm":false,"size":"19G","ro":false,"type":"part","mountpoint":null,"size_bytes":19000000000},{"name":"centos-root","maj_min":"253:0","rm":false,"size":"17G","ro":false,"type":"lvm","mountpoint":"/","size_bytes":17000000000},{"name":"centos-swap","maj_min":"253:1","rm":false,"size":"2G","ro":false,"type":"lvm","mountpoint":"[SWAP]","size_bytes":2000000000},{"name":"sr0","maj_min":"11:0","rm":true,"size":"1024M","ro":false,"type":"rom","mountpoint":null,"size_bytes":1024000000}]
|
||||
|
File diff suppressed because one or more lines are too long
2
tests/fixtures/ubuntu-18.04/lsblk.json
vendored
2
tests/fixtures/ubuntu-18.04/lsblk.json
vendored
@ -1 +1 @@
|
||||
[{"name": "fd0", "maj_min": "2:0", "rm": true, "size": "1.4M", "ro": false, "type": "disk", "mountpoint": null}, {"name": "loop0", "maj_min": "7:0", "rm": false, "size": "54.5M", "ro": true, "type": "loop", "mountpoint": "/snap/core18/1223"}, {"name": "loop1", "maj_min": "7:1", "rm": false, "size": "11M", "ro": true, "type": "loop", "mountpoint": "/snap/slcli/383"}, {"name": "loop2", "maj_min": "7:2", "rm": false, "size": "88.7M", "ro": true, "type": "loop", "mountpoint": "/snap/core/7396"}, {"name": "loop3", "maj_min": "7:3", "rm": false, "size": "66.5M", "ro": true, "type": "loop", "mountpoint": "/snap/google-cloud-sdk/103"}, {"name": "loop4", "maj_min": "7:4", "rm": false, "size": "66.5M", "ro": true, "type": "loop", "mountpoint": "/snap/google-cloud-sdk/104"}, {"name": "loop5", "maj_min": "7:5", "rm": false, "size": "54.4M", "ro": true, "type": "loop", "mountpoint": "/snap/core18/1074"}, {"name": "loop7", "maj_min": "7:7", "rm": false, "size": "8.6M", "ro": true, "type": "loop", "mountpoint": "/snap/doctl/187"}, {"name": "loop8", "maj_min": "7:8", "rm": false, "size": "3.1M", "ro": true, "type": "loop", "mountpoint": "/snap/stress-ng/847"}, {"name": "loop9", "maj_min": "7:9", "rm": false, "size": "8.6M", "ro": true, "type": "loop", "mountpoint": "/snap/doctl/215"}, {"name": "loop10", "maj_min": "7:10", "rm": false, "size": "89.1M", "ro": true, "type": "loop", "mountpoint": "/snap/core/7917"}, {"name": "loop11", "maj_min": "7:11", "rm": false, "size": "3.2M", "ro": true, "type": "loop", "mountpoint": "/snap/stress-ng/924"}, {"name": "sda", "maj_min": "8:0", "rm": false, "size": "20G", "ro": false, "type": "disk", "mountpoint": null}, {"name": "sda1", "maj_min": "8:1", "rm": false, "size": "1M", "ro": false, "type": "part", "mountpoint": null}, {"name": "sda2", "maj_min": "8:2", "rm": false, "size": "20G", "ro": false, "type": "part", "mountpoint": "/"}, {"name": "sr0", "maj_min": "11:0", "rm": true, "size": "64.8M", "ro": false, "type": "rom", "mountpoint": null}, {"name": "sr1", "maj_min": "11:1", "rm": true, "size": "848M", "ro": false, "type": "rom", "mountpoint": null}]
|
||||
[{"name":"fd0","maj_min":"2:0","rm":true,"size":"1.4M","ro":false,"type":"disk","mountpoint":null,"size_bytes":1400000},{"name":"loop0","maj_min":"7:0","rm":false,"size":"54.5M","ro":true,"type":"loop","mountpoint":"/snap/core18/1223","size_bytes":54500000},{"name":"loop1","maj_min":"7:1","rm":false,"size":"11M","ro":true,"type":"loop","mountpoint":"/snap/slcli/383","size_bytes":11000000},{"name":"loop2","maj_min":"7:2","rm":false,"size":"88.7M","ro":true,"type":"loop","mountpoint":"/snap/core/7396","size_bytes":88700000},{"name":"loop3","maj_min":"7:3","rm":false,"size":"66.5M","ro":true,"type":"loop","mountpoint":"/snap/google-cloud-sdk/103","size_bytes":66500000},{"name":"loop4","maj_min":"7:4","rm":false,"size":"66.5M","ro":true,"type":"loop","mountpoint":"/snap/google-cloud-sdk/104","size_bytes":66500000},{"name":"loop5","maj_min":"7:5","rm":false,"size":"54.4M","ro":true,"type":"loop","mountpoint":"/snap/core18/1074","size_bytes":54400000},{"name":"loop7","maj_min":"7:7","rm":false,"size":"8.6M","ro":true,"type":"loop","mountpoint":"/snap/doctl/187","size_bytes":8600000},{"name":"loop8","maj_min":"7:8","rm":false,"size":"3.1M","ro":true,"type":"loop","mountpoint":"/snap/stress-ng/847","size_bytes":3100000},{"name":"loop9","maj_min":"7:9","rm":false,"size":"8.6M","ro":true,"type":"loop","mountpoint":"/snap/doctl/215","size_bytes":8600000},{"name":"loop10","maj_min":"7:10","rm":false,"size":"89.1M","ro":true,"type":"loop","mountpoint":"/snap/core/7917","size_bytes":89100000},{"name":"loop11","maj_min":"7:11","rm":false,"size":"3.2M","ro":true,"type":"loop","mountpoint":"/snap/stress-ng/924","size_bytes":3200000},{"name":"sda","maj_min":"8:0","rm":false,"size":"20G","ro":false,"type":"disk","mountpoint":null,"size_bytes":20000000000},{"name":"sda1","maj_min":"8:1","rm":false,"size":"1M","ro":false,"type":"part","mountpoint":null,"size_bytes":1000000},{"name":"sda2","maj_min":"8:2","rm":false,"size":"20G","ro":false,"type":"part","mountpoint":"/","size_bytes":20000000000},{"name":"sr0","maj_min":"11:0","rm":true,"size":"64.8M","ro":false,"type":"rom","mountpoint":null,"size_bytes":64800000},{"name":"sr1","maj_min":"11:1","rm":true,"size":"848M","ro":false,"type":"rom","mountpoint":null,"size_bytes":848000000}]
|
||||
|
@ -65,6 +65,24 @@ class MyTests(unittest.TestCase):
|
||||
"""
|
||||
self.assertEqual(jc.parsers.lsblk.parse(self.ubuntu_18_4_lsblk_allcols, quiet=True), self.ubuntu_18_4_lsblk_allcols_json)
|
||||
|
||||
def test_lsblk_multiple_mountpoints(self):
|
||||
"""
|
||||
Test 'lsblk' with multiple mountpoints
|
||||
"""
|
||||
data = '''NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
|
||||
sda 8:0 0 5368709120000 0 disk
|
||||
|-sda1 8:1 0 1048576 0 part
|
||||
|-sda2 8:2 0 1073741824 0 part /boot
|
||||
|-sda3 8:3 0 1073741824 0 part /boot/efi
|
||||
`-sda4 8:4 0 51536461824 0 part
|
||||
|-almalinux-root 253:0 0 36075208704 0 lvm /
|
||||
|-almalinux-docker 253:1 0 1073741824 0 lvm /opt/docker
|
||||
|-almalinux-home 253:2 0 5368709120 0 lvm /home
|
||||
`-almalinux-opt 253:3 0 9017753600 0 lvm /var/lib/kafka
|
||||
/opt
|
||||
sr0 11:0 1 1073741312 0 rom'''
|
||||
expected = [{"name":"sda","maj_min":"8:0","rm":False,"size":"5368709120000","ro":False,"type":"disk","mountpoints":[],"size_bytes":5368709120000},{"name":"sda1","maj_min":"8:1","rm":False,"size":"1048576","ro":False,"type":"part","mountpoints":[],"size_bytes":1048576},{"name":"sda2","maj_min":"8:2","rm":False,"size":"1073741824","ro":False,"type":"part","mountpoints":["/boot"],"size_bytes":1073741824},{"name":"sda3","maj_min":"8:3","rm":False,"size":"1073741824","ro":False,"type":"part","mountpoints":["/boot/efi"],"size_bytes":1073741824},{"name":"sda4","maj_min":"8:4","rm":False,"size":"51536461824","ro":False,"type":"part","mountpoints":[],"size_bytes":51536461824},{"name":"almalinux-root","maj_min":"253:0","rm":False,"size":"36075208704","ro":False,"type":"lvm","mountpoints":["/"],"size_bytes":36075208704},{"name":"almalinux-docker","maj_min":"253:1","rm":False,"size":"1073741824","ro":False,"type":"lvm","mountpoints":["/opt/docker"],"size_bytes":1073741824},{"name":"almalinux-home","maj_min":"253:2","rm":False,"size":"5368709120","ro":False,"type":"lvm","mountpoints":["/home"],"size_bytes":5368709120},{"name":"almalinux-opt","maj_min":"253:3","rm":False,"size":"9017753600","ro":False,"type":"lvm","mountpoints":["/var/lib/kafka","/opt"],"size_bytes":9017753600},{"name":"sr0","maj_min":"11:0","rm":True,"size":"1073741312","ro":False,"type":"rom","mountpoints":[],"size_bytes":1073741312}]
|
||||
self.assertEqual(jc.parsers.lsblk.parse(data, quiet=True), expected)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Reference in New Issue
Block a user