def test_score_event_suggestion_rejected(store0, admin, settings): unit = store0.units.filter(suggestion__state__name="pending").first() suggestion = unit.suggestion_set.filter(state__name="pending").first() scoring = event_score.gather(LogEvent) scorer = scoring["suggestion_rejected"] assert scorer == scores.SuggestionRejectedScore event = LogEvent( unit, admin, datetime.now(), "example", suggestion) score = scorer(event) assert score.event == event assert score.unit == unit assert score.suggestion == suggestion assert ( score.score == (unit.source_wordcount * settings.POOTLE_SCORES["suggestion_reject"])) assert score.translated == 0 assert score.reviewed == unit.source_wordcount assert score.suggested == 0 assert ( score.get_score() == dict( score=score.score, translated=0, reviewed=unit.source_wordcount, suggested=0))
def test_score_event_suggestion_rejected(store0, admin, settings): unit = store0.units.filter(suggestion__state__name="pending").first() suggestion = unit.suggestion_set.filter(state__name="pending").first() scoring = event_score.gather(LogEvent) scorer = scoring["suggestion_rejected"] assert scorer == scores.SuggestionRejectedScore event = LogEvent( unit, admin, datetime.now(), "example", suggestion) score = scorer(event) assert score.event == event assert score.unit == unit assert score.suggestion == suggestion assert ( score.score == (unit.unit_source.source_wordcount * settings.POOTLE_SCORES["suggestion_reject"])) assert score.translated == 0 assert score.reviewed == unit.unit_source.source_wordcount assert score.suggested == 0 assert ( score.get_score() == dict( score=score.score, translated=0, reviewed=unit.unit_source.source_wordcount, suggested=0))
def test_score_event_target_updated(store0, admin, settings): unit = store0.units.first() scoring = event_score.gather(LogEvent) scorer = scoring["target_updated"] assert scorer == scores.TargetUpdatedScore event = LogEvent( unit, admin, datetime.now(), "example", None) score = scorer(event) assert score.event == event assert score.unit == unit assert ( score.score == (unit.source_wordcount * settings.POOTLE_SCORES["target_updated"])) assert score.translated == unit.source_wordcount assert score.reviewed == 0 assert score.suggested == 0 assert ( score.get_score() == dict( score=score.score, translated=unit.source_wordcount, reviewed=0, suggested=0))
def test_score_event_target_updated(store0, admin, settings): unit = store0.units.first() scoring = event_score.gather(LogEvent) scorer = scoring["target_updated"] assert scorer == scores.TargetUpdatedScore event = LogEvent( unit, admin, datetime.now(), "example", None) score = scorer(event) assert score.event == event assert score.unit == unit assert ( score.score == (unit.unit_source.source_wordcount * settings.POOTLE_SCORES["target_updated"])) assert score.translated == unit.unit_source.source_wordcount assert score.reviewed == 0 assert score.suggested == 0 assert ( score.get_score() == dict( score=score.score, translated=unit.unit_source.source_wordcount, reviewed=0, suggested=0))
def test_score_event_state_updated(store0, admin, settings): unit = store0.units.first() scoring = event_score.gather(LogEvent) scorer = scoring["state_updated"] assert scorer == scores.StateUpdatedScore sub = Submission.objects.create( unit=unit, submitter=admin, translation_project=unit.store.translation_project, creation_time=make_aware(timezone.now()), old_value=UNTRANSLATED, new_value=TRANSLATED) event = LogEvent( unit, admin, datetime.now(), "example", sub) score = scorer(event) assert score.event == event assert score.unit == unit assert score.submission == sub assert ( score.score == (unit.source_wordcount * settings.POOTLE_SCORES["state_translated"])) assert score.translated == unit.source_wordcount assert score.reviewed == 0 assert score.suggested == 0 assert ( score.get_score() == dict( score=score.score, translated=unit.source_wordcount, reviewed=0, suggested=0)) sub = Submission.objects.create( unit=unit, submitter=admin, translation_project=unit.store.translation_project, creation_time=make_aware(timezone.now()), old_value=FUZZY, new_value=TRANSLATED) event = LogEvent( unit, admin, datetime.now(), "example", sub) score = scorer(event) assert score.event == event assert score.unit == unit assert score.submission == sub assert ( score.score == (unit.source_wordcount * settings.POOTLE_SCORES["state_unfuzzy"])) assert score.translated == 0 assert score.reviewed == unit.source_wordcount assert score.suggested == 0 assert ( score.get_score() == dict( score=score.score, translated=0, reviewed=unit.source_wordcount, suggested=0)) sub = Submission.objects.create( unit=unit, submitter=admin, translation_project=unit.store.translation_project, creation_time=make_aware(timezone.now()), old_value=TRANSLATED, new_value=FUZZY) event = LogEvent( unit, admin, datetime.now(), "example", sub) score = scorer(event) assert score.event == event assert score.unit == unit assert score.submission == sub assert ( score.score == (unit.source_wordcount * settings.POOTLE_SCORES["state_fuzzy"])) assert score.translated == 0 assert score.reviewed == unit.source_wordcount assert score.suggested == 0 assert ( score.get_score() == dict( score=score.score, translated=0, reviewed=unit.source_wordcount, suggested=0))
def scoring(self): return event_score.gather(self.event_class)
def test_score_event_state_updated(store0, admin, settings): unit = store0.units.first() scoring = event_score.gather(LogEvent) scorer = scoring["state_updated"] assert scorer == scores.StateUpdatedScore sub = Submission.objects.create( unit=unit, submitter=admin, translation_project=unit.store.translation_project, creation_time=make_aware(timezone.now()), old_value=UNTRANSLATED, new_value=TRANSLATED) event = LogEvent( unit, admin, datetime.now(), "example", sub) score = scorer(event) assert score.event == event assert score.unit == unit assert score.submission == sub assert ( score.score == (unit.unit_source.source_wordcount * settings.POOTLE_SCORES["state_translated"])) assert score.translated == unit.unit_source.source_wordcount assert score.reviewed == 0 assert score.suggested == 0 assert ( score.get_score() == dict( score=score.score, translated=unit.unit_source.source_wordcount, reviewed=0, suggested=0)) sub = Submission.objects.create( unit=unit, submitter=admin, translation_project=unit.store.translation_project, creation_time=make_aware(timezone.now()), old_value=FUZZY, new_value=TRANSLATED) event = LogEvent( unit, admin, datetime.now(), "example", sub) score = scorer(event) assert score.event == event assert score.unit == unit assert score.submission == sub assert ( score.score == (unit.unit_source.source_wordcount * settings.POOTLE_SCORES["state_unfuzzy"])) assert score.translated == 0 assert score.reviewed == unit.unit_source.source_wordcount assert score.suggested == 0 assert ( score.get_score() == dict( score=score.score, translated=0, reviewed=unit.unit_source.source_wordcount, suggested=0)) sub = Submission.objects.create( unit=unit, submitter=admin, translation_project=unit.store.translation_project, creation_time=make_aware(timezone.now()), old_value=TRANSLATED, new_value=FUZZY) event = LogEvent( unit, admin, datetime.now(), "example", sub) score = scorer(event) assert score.event == event assert score.unit == unit assert score.submission == sub assert ( score.score == (unit.unit_source.source_wordcount * settings.POOTLE_SCORES["state_fuzzy"])) assert score.translated == 0 assert score.reviewed == unit.unit_source.source_wordcount assert score.suggested == 0 assert ( score.get_score() == dict( score=score.score, translated=0, reviewed=unit.unit_source.source_wordcount, suggested=0))