def test_refresh_volumes(self):
        """Test for refresh_volumes method."""
        udf = self._create_udf()
        yield self.main.vm.add_udf(udf)

        share = self._create_share()
        yield self.main.vm.add_share(share)

        volumes = list(self.main.vm.get_volumes(all_volumes=True))

        def volumes_changed():
            """Fake volumes_changed."""
            self.main.event_q.push('VM_VOLUMES_CHANGED', volumes=volumes)

        self.patch(self.main.vm, 'refresh_volumes', volumes_changed)
        result = yield self.tool.refresh_volumes()

        str_volumes = []
        for volume in volumes:
            if isinstance(volume, volume_manager.UDF):
                str_vol = interaction_interfaces.get_udf_dict(volume)
            else:
                str_vol = interaction_interfaces.get_share_dict(volume)
            str_volumes.append(str_vol)
        self.assertEqual(result, str_volumes)
Exemplo n.º 2
0
 def handle_SYS_QUOTA_EXCEEDED(self, volume_id, free_bytes):
     """Handle the SYS_QUOTA_EXCEEDED event."""
     volume = self.vm.get_volume(str(volume_id))
     volume_dict = {}
     if isinstance(volume, UDF):
         volume_dict = get_udf_dict(volume)
         to_call = self.status_frontend.udf_quota_exceeded
     elif isinstance(volume, Root):
         volume_dict = get_share_dict(volume)
         to_call = self.status_frontend.root_quota_exceeded
     else:
         volume_dict = get_share_dict(volume)
         to_call = self.status_frontend.share_quota_exceeded
     volume_dict['free_bytes'] = str(free_bytes)
     to_call(volume_dict)
Exemplo n.º 3
0
 def emit_folder_delete_error(self, folder, error):
     """Emit the FolderCreateError signal"""
     udf_dict = get_udf_dict(folder)
     self.emit_signal('on_folder_delete_error', udf_dict, str(error))
Exemplo n.º 4
0
 def emit_folder_unsubscribed(self, folder):
     """Emit the FolderUnSubscribed signal"""
     udf_dict = get_udf_dict(folder)
     self.emit_signal('on_folder_unsubscribed', udf_dict)
Exemplo n.º 5
0
 def emit_folder_deleted(self, folder):
     """Emit the FolderCreated signal"""
     udf_dict = get_udf_dict(folder)
     self.emit_signal('on_folder_deleted', udf_dict)