Exemplo n.º 1
0
def make_model_and_disk():
    model = FilesystemModel(prober=None)
    disk = Disk.from_info(
        FakeStorageInfo(name='disk-name',
                        size=100 * (2**30),
                        free=50 * (2**30)))
    model._available_disks[disk.name] = disk
    return model, disk
Exemplo n.º 2
0
def make_disk(model, **kw):
    serial = 'serial%s' % len(model._actions)
    model._actions.append(Disk(
        m=model, serial=serial,
        info=FakeStorageInfo(size=100*(2**30)),
        **kw))
    disk = model._actions[-1]
    return disk
Exemplo n.º 3
0
 def make_view(self, partition=None):
     controller = mock.create_autospec(spec=FilesystemController)
     model = mock.create_autospec(spec=FilesystemModel)
     model.fs_by_name = FilesystemModel.fs_by_name
     disk = Disk.from_info(
         FakeStorageInfo(name='disk-name',
                         size=100 * (2**20),
                         free=50 * (2**20)))
     return PartitionView(model, controller, disk, partition)
Exemplo n.º 4
0
 def make_view(self, partition=None):
     controller = mock.create_autospec(spec=FilesystemController)
     model = mock.create_autospec(spec=FilesystemModel)
     model.fs_by_name = FilesystemModel.fs_by_name
     info = mock.create_autospec(spec=StorageInfo)
     info.name = 'disk-name'
     info.size = 100
     info.free = 50
     disk = Disk.from_info(info)
     return PartitionView(model, controller, disk, partition)
Exemplo n.º 5
0
 def test_one_disk(self):
     disk = Disk.from_info(
         FakeStorageInfo(name='disk-name',
                         size=100 * (2**20),
                         free=50 * (2**20),
                         serial="DISK-SERIAL"))
     view = self.make_view([disk])
     w = view_helpers.find_with_pred(
         view,
         lambda w: isinstance(w, urwid.Text) and "DISK-SERIAL" in w.text)
     self.assertIsNotNone(w, "could not find DISK-SERIAL in view")
Exemplo n.º 6
0
 def test_one_disk(self):
     model = mock.create_autospec(spec=FilesystemModel)
     disk = Disk(m=model,
                 serial="DISK-SERIAL",
                 info=FakeStorageInfo(size=100 * (2**20),
                                      free=50 * (2**20)))
     view = self.make_view(model, [disk])
     w = view_helpers.find_with_pred(
         view,
         lambda w: isinstance(w, urwid.Text) and "DISK-SERIAL" in w.text)
     self.assertIsNotNone(w, "could not find DISK-SERIAL in view")
Exemplo n.º 7
0
def make_disk(fs_model, **kw):
    if 'serial' not in kw:
        kw['serial'] = 'serial%s' % len(fs_model._actions)
    if 'path' not in kw:
        kw['path'] = '/dev/thing'
    size = kw.pop('size', 100*(2**30))
    fs_model._actions.append(Disk(
        m=fs_model, info=FakeStorageInfo(size=size),
        **kw))
    disk = fs_model._actions[-1]
    return disk
Exemplo n.º 8
0
 def make_view(self, partition=None):
     controller = mock.create_autospec(spec=FilesystemController)
     model = mock.create_autospec(spec=FilesystemModel)
     model.fs_by_name = FilesystemModel.fs_by_name
     disk = Disk.from_info(
         FakeStorageInfo(name='disk-name',
                         size=100 * (2**20),
                         free=50 * (2**20)))
     base_view = BaseView(urwid.Text(""))
     base_view.model = model
     base_view.controller = controller
     base_view.refresh_model_inputs = lambda: None
     stretchy = PartitionStretchy(base_view, disk, partition)
     base_view.show_stretchy_overlay(stretchy)
     return base_view, stretchy