Пример #1
0
def test_tracker_updates_records_with_missing_data(mock_formula_map,
                                                   updatable_criteria_csv):
    # all tests from the fixture don't have any kind of data
    tracker = CriteriaTracker(
        formula_map=mock_formula_map,
        record_path=str(updatable_criteria_csv),
        webservice_rest_time=timedelta(seconds=0.0),
    )
    tracker.load_records()

    # CSV has no criteria data initially
    for criteria_rec in tracker:
        assert criteria_rec.EngineerTraction == ''
        assert criteria_rec.FixRatio == ''
        assert criteria_rec.TotalAlerts == ''
        assert criteria_rec.LastUpdatedOn == ''
        assert criteria_rec.AllowSync is True

    tracker.update_records()
    del tracker

    # let's re read with a separate tracker
    # to ensure data was cached & correct
    separate_tracker = CriteriaTracker(record_path=str(updatable_criteria_csv))
    separate_tracker.load_records()

    for criteria_rec in separate_tracker:
        assert criteria_rec.EngineerTraction == EXPECTED_VALUE
        assert criteria_rec.FixRatio == EXPECTED_VALUE
        assert criteria_rec.TotalAlerts == 0
        assert criteria_rec.LastUpdatedOn == EXPECTED_LAST_UPDATE
        assert criteria_rec.AllowSync is True
Пример #2
0
    def handle(self, *args, **options):
        if options.get('individually'):
            return self._handle_individually(options)

        quant_period = options['quantifying_period']
        bug_cooldown = options['bug_cooldown']
        multiprocessed = options['multiprocessing']

        init_params = (None, quant_period, bug_cooldown)
        formula_map = {
            'EngineerTraction': EngineerTractionFormula(*init_params),
            'FixRatio': FixRatioFormula(*init_params),
        }

        tracker = CriteriaTracker(formula_map, multiprocessed=multiprocessed)
        tracker.load_records()
        start = time.time()
        tracker.update_records()
        duration = time.time() - start

        print(f'{self.INITIAL_PROMPT_MSG}', end='')

        for record in tracker:
            print(record)
        print(f"Took {duration:.1f} seconds")
Пример #3
0
def test_tracker_lets_web_service_rest(mock_formula_map,
                                       updatable_criteria_csv):
    tracker = CriteriaTracker(
        formula_map=mock_formula_map,
        record_path=str(updatable_criteria_csv),
        webservice_rest_time=timedelta(seconds=0.01),
    )
    tracker.load_records()

    with should_take_more_than(0.01):
        tracker.update_records()