Exemplo n.º 1
0
    def test_already_checked_today(self, message):
        now = datetime.now()
        store.set_last_version_check(now)
        store.set_update_available(None)

        check()

        assert store.get_last_version_check() == now
        assert store.get_update_available() is None
        assert not message.called
Exemplo n.º 2
0
    def test_update_available(self, message, current_version, latest_version):
        current_version.return_value = Version('1.8.0')
        latest_version.return_value = Version('1.9.0')
        two_days_ago = datetime.now() - timedelta(days=2)
        store.set_last_version_check(two_days_ago)
        store.set_update_available(None)

        check()

        assert store.get_last_version_check() > two_days_ago
        assert store.get_update_available() == Version('1.9.0')
        assert message.called
Exemplo n.º 3
0
    def test_update_found_previously_and_already_checked_today(
            self, message, current_version, latest_version):
        current_version.return_value = Version('1.8.0')
        latest_version.return_value = Version('1.10.0')
        now = datetime.now()
        store.set_last_version_check(now)
        store.set_update_available(Version('1.9.0'))

        check()

        assert store.get_last_version_check() == now
        assert store.get_update_available() == Version('1.9.0')
        assert message.called
Exemplo n.º 4
0
    def test_update_found_previously_and_just_updated(self, message,
                                                      current_version,
                                                      latest_version):
        current_version.return_value = Version('1.9.0')
        latest_version.return_value = Version('1.9.0')
        now = datetime.now()
        store.set_last_version_check(now)
        store.set_update_available(Version('1.9.0'))

        check()

        assert store.get_last_version_check() == now
        assert store.get_update_available() is None
        assert not message.called
Exemplo n.º 5
0
def start(argv, context: Context):
    with context:
        # setup friendly interrupt message
        signal.signal(signal.SIGINT, interrupt_handler)

        load_config()
        store.load()
        update_checker.check()

        args = _parse_args(argv)

        setattr(args, 'arg_string', ' '.join(argv[1:]))
        set_log_level(args)

        args.func(args)

        return 0