def test_getattr_for_resource(self): fs = KubeFileSystem(KubernetesClient()) path = '/default/pod' attr = fs.getattr(path) assert_that(attr['st_mode'], is_(stat.S_IFDIR | 0o555)) assert_that(attr['st_nlink'], is_(2)) assert_that(attr['st_size'], is_(0))
def test_getattr_for_resource(self): fs = KubeFileSystem(KubernetesClient()) path = '/default/pod' attr = fs.getattr(path) assert_that(attr['st_mode'], is_(stat.S_IFDIR | 0555)) assert_that(attr['st_nlink'], is_(2)) assert_that(attr['st_size'], is_(0))
def test_getattr_for_truncated_file(self): client = KubernetesClient() pod = client.get_pods()[0] fs = KubeFileSystem(client) path = '/default/pod/%s/json' % pod fs.truncate(path, 0) attr = fs.getattr(path) assert_that(attr['st_size'], is_(0))
def test_getattr_size_for_describe_action(self): client = KubernetesClient() pod = client.get_pods()[0] fs = KubeFileSystem(client) path = '/default/pod/%s/logs' % pod attr = fs.getattr(path) data = client.logs('default', pod) assert_that(attr['st_size'], is_(len(data)))
def test_getattr_size_for_yaml_action(self): client = KubernetesClient() pod = client.get_pods()[0] fs = KubeFileSystem(client) path = '/default/pod/%s/yaml' % pod attr = fs.getattr(path) data = client.get_object_in_format('default', 'pod', pod, 'yaml') assert_that(attr['st_size'], is_(len(data)))
def test_getattr_for_object(self): client = KubernetesClient() pod = client.get_pods()[0] fs = KubeFileSystem(client) path = '/default/pod/%s' % pod attr = fs.getattr(path) assert_that(attr['st_mode'], is_(stat.S_IFDIR | 0o555)) assert_that(attr['st_nlink'], is_(2)) assert_that(attr['st_size'], is_(0))
def test_getattr_for_object(self): client = KubernetesClient() pod = client.get_pods()[0] fs = KubeFileSystem(client) path = '/default/pod/%s' % pod attr = fs.getattr(path) assert_that(attr['st_mode'], is_(stat.S_IFDIR | 0555)) assert_that(attr['st_nlink'], is_(2)) assert_that(attr['st_size'], is_(0))
def test_getattr_for_action(self): client = KubernetesClient() pod = client.get_pods()[0] fs = KubeFileSystem(client) path = '/default/pod/%s/describe' % pod attr = fs.getattr(path) data = client.describe('default', 'pod', pod) assert_that(attr['st_mode'], is_(stat.S_IFREG | 0o444)) assert_that(attr['st_nlink'], is_(1)) assert_that(attr['st_size'], is_(len(data)))
def test_getattr_for_action(self): client = KubernetesClient() pod = client.get_pods()[0] fs = KubeFileSystem(client) path = '/default/pod/%s/describe' % pod attr = fs.getattr(path) data = client.describe('default', 'pod', pod) assert_that(attr['st_mode'], is_(stat.S_IFREG | 0444)) assert_that(attr['st_nlink'], is_(1)) assert_that(attr['st_size'], is_(len(data)))
def test_getattr_for_nonexistent_path(self): client = KubernetesClient() fs = KubeFileSystem(client) path = '/doesnt-exist' assert_that(calling(lambda: fs.getattr(path)), raises(FuseOSError))