Exemple #1
0
    def test_completion_rate_not_running(self):
        rule = ScannerQueryRule(state=NEW, task_count=10000)
        assert rule.completion_rate() is None

        rule.state = SCHEDULED
        assert rule.completion_rate() is None

        rule.state = ABORTING
        assert rule.completion_rate() is None

        rule.state = ABORTED
        assert rule.completion_rate() is None
Exemple #2
0
    def test_completion_rate(self, _get_completed_tasks_count_mock):
        rule = ScannerQueryRule(state=RUNNING, task_count=10000)

        _get_completed_tasks_count_mock.return_value = None
        assert rule.completion_rate() is None

        _get_completed_tasks_count_mock.return_value = 0
        assert rule.completion_rate() == '0.00%'

        _get_completed_tasks_count_mock.return_value = 1000
        assert rule.completion_rate() == '10.00%'

        _get_completed_tasks_count_mock.return_value = 3333
        assert rule.completion_rate() == '33.33%'

        _get_completed_tasks_count_mock.return_value = 10000
        assert rule.completion_rate() == '100.00%'

        rule.task_count = 0
        assert rule.completion_rate() is None