Ejemplo n.º 1
0
def test_action():
    action = Action("Testing")
    assert action.type == "Testing"
    assert repr(action)
    assert "%" not in repr(action)

    actions = Action.get_actions()
    assert len(actions) == 1
    assert list(actions.values())[0] is action
    assert Action.get_current_action() is action

    # Will test .get_percent()
    details = action.export()
    assert details["action_type"] == "Testing"
    assert details["progress"] == 0.0
    assert isinstance(details["uid"], str)

    # Test progress property setter
    action.progress = 100.0
    details = action.export()
    assert details["progress"] == 100.0

    Action.finish_action()
    actions = Action.get_actions()
    assert len(actions) == 0
    assert Action.get_current_action() is None
Ejemplo n.º 2
0
 def get_tooltip(self):
     actions = Action.get_actions()
     if actions is None or len(actions) == 0:
         return self.get_default_tooltip()
     # Display only the first action for now
     # TODO Get all actions ? or just file action
     action = actions.itervalues().next()
     if action is None:
         return self.get_default_tooltip()
     if isinstance(action, FileAction):
         if action.get_percent() is not None:
             return ("%s - %s - %s - %d%%" %
                                 (self.get_default_tooltip(),
                                 action.type, action.filename,
                                 action.get_percent()))
         else:
             return ("%s - %s - %s" % (self.get_default_tooltip(),
                                 action.type, action.filename))
     elif action.get_percent() is not None:
         return ("%s - %s - %d%%" % (self.get_default_tooltip(),
                                 action.type,
                                 action.get_percent()))
     else:
         return ("%s - %s" % (self.get_default_tooltip(),
                                 action.type))
Ejemplo n.º 3
0
    def get_tooltip(self):
        actions = Action.get_actions()
        if not actions:
            return self.default_tooltip

        # Display only the first action for now
        for action in actions.itervalues():
            if action and not action.type.startswith('_'):
                break
        else:
            return self.default_tooltip

        if isinstance(action, FileAction):
            if action.get_percent() is not None:
                return '%s - %s - %s - %d%%' % (
                    self.default_tooltip,
                    action.type, action.filename,
                    action.get_percent(),
                )
            return '%s - %s - %s' % (
                self.default_tooltip,
                action.type, action.filename,
            )
        elif action.get_percent() is not None:
            return '%s - %s - %d%%' % (
                self.default_tooltip,
                action.type,
                action.get_percent(),
            )

        return '%s - %s' % (
            self.default_tooltip,
            action.type,
        )
Ejemplo n.º 4
0
def test_action():
    action = Action("Testing")
    assert action.type == "Testing"
    assert repr(action)
    assert "%" not in repr(action)

    actions = Action.get_actions()
    assert len(actions) == 1
    assert list(actions.values())[0] == action
    assert Action.get_current_action() == action

    # Will test .get_percent()
    details = action.export()
    assert details["last_transfer"] == "Testing"
    assert details["progress"] == 0.0
    assert isinstance(details["uid"], str)

    Action.finish_action()
    actions = Action.get_actions()
    assert len(actions) == 0
    assert Action.get_current_action() is None
Ejemplo n.º 5
0
 def get_tooltip(self):
     actions = Action.get_actions()
     if actions is None or len(actions) == 0:
         return self.get_default_tooltip()
     # Display only the first action for now
     # TODO Get all actions ? or just file action
     action = actions.itervalues().next()
     if action is None:
         return self.get_default_tooltip()
     if isinstance(action, FileAction):
         if action.get_percent() is not None:
             return ("%s - %s - %s - %d%%" %
                     (self.get_default_tooltip(), action.type,
                      action.filename, action.get_percent()))
         else:
             return (
                 "%s - %s - %s" %
                 (self.get_default_tooltip(), action.type, action.filename))
     elif action.get_percent() is not None:
         return ("%s - %s - %d%%" % (self.get_default_tooltip(),
                                     action.type, action.get_percent()))
     else:
         return ("%s - %s" % (self.get_default_tooltip(), action.type))
Ejemplo n.º 6
0
    def get_tooltip(self):
        actions = Action.get_actions()
        if not actions:
            return self.default_tooltip

        # Display only the first action for now
        for action in actions.itervalues():
            if action and not action.type.startswith('_'):
                break
        else:
            return self.default_tooltip

        if isinstance(action, FileAction):
            if action.get_percent() is not None:
                return '%s - %s - %s - %d%%' % (
                    self.default_tooltip,
                    action.type,
                    action.filename,
                    action.get_percent(),
                )
            return '%s - %s - %s' % (
                self.default_tooltip,
                action.type,
                action.filename,
            )
        elif action.get_percent() is not None:
            return '%s - %s - %d%%' % (
                self.default_tooltip,
                action.type,
                action.get_percent(),
            )

        return '%s - %s' % (
            self.default_tooltip,
            action.type,
        )