def test_doc_examples(): env = { 'df_li': df.DiskFree_LI(context_wrap(DF_LI_DOC)), 'df_al': df.DiskFree_AL(context_wrap(DF_AL_DOC)), 'df_alP': df.DiskFree_ALP(context_wrap(DF_ALP_DOC)), } failed, total = doctest.testmod(df, globs=env) assert failed == 0
def test_df_alP(): df_list = df.DiskFree_ALP(context_wrap(DF_ALP)) assert len(df_list) == 9 assert len(df_list.mounts) == 9 assert len(df_list.filesystems) == 7 assert '/' in df_list.mounts r = df.Record(filesystem='/dev/mapper/vg_lxcrhel6sat56-lv_root', total='98571884', used='4244032', available='89313940', capacity='5%', mounted_on='/') assert df_list.get_mount('/') == r assert '/dev/mapper/vg_lxcrhel6sat56-lv_root' in df_list.filesystems assert len( df_list.get_filesystem('/dev/mapper/vg_lxcrhel6sat56-lv_root')) == 1 assert df_list.get_filesystem( '/dev/mapper/vg_lxcrhel6sat56-lv_root')[0] == r assert len(df_list.get_filesystem('tmpfs')) == 3 assert df_list.get_mount('/sys').filesystem == 'sysfs' assert df_list.get_mount('/proc').total == '0' assert df_list.get_mount('/dev').used == '0' assert df_list.get_mount('/run').available == '5997356' assert df_list.get_mount('/sys/fs/cgroup').capacity == '0%' assert df_list.get_mount( '/').filesystem == '/dev/mapper/vg_lxcrhel6sat56-lv_root' assert df_list.get_mount('/').capacity == '5%' # Test get_path # Root mount point works: assert df_list.get_dir('/') == df_list.get_mount('/') # Mount point underneath root works: assert df_list.get_dir('/dev') == df_list.get_mount('/dev') # Directory underneath sub-mount: assert df_list.get_dir('/dev/v4l') == df_list.get_mount('/dev') # Directory with / suffix: assert df_list.get_dir('/dev/v4l/') == df_list.get_mount('/dev') # File path also works: assert df_list.get_dir( '/dev/v4l/adapter0/control0.cfg') == df_list.get_mount('/dev') # Relative path returns None assert df_list.get_dir('dev/sys') is None # Invalid path returns None assert df_list.get_dir('"') is None