

def test_recording_answer_for_different_rules(self):
    exp = exp_domain.Exploration.create_default_exploration('eid', 'title', 'category')
    exp_services.save_new_exploration('user_id', exp)
    rule = exp_domain.RuleSpec.from_dict({
        'rule_type': 'LessThan',
        'inputs': {
            'x': 5,
        },
    })
    rule_str = rule.stringify_classified_rule()
    state_name = exp.init_state_name
    event_services.AnswerSubmissionEventHandler.record('eid', 1, state_name, self.DEFAULT_RULESPEC_STR, 'answer1')
    event_services.AnswerSubmissionEventHandler.record('eid', 1, state_name, rule_str, 'answer2')
    default_rule_answer_log = stats_domain.StateRuleAnswerLog.get('eid', state_name, self.DEFAULT_RULESPEC_STR)
    self.assertEquals(default_rule_answer_log.answers, {
        'answer1': 1,
    })
    self.assertEquals(default_rule_answer_log.total_answer_count, 1)
    other_rule_answer_log = stats_domain.StateRuleAnswerLog.get('eid', state_name, rule_str)
    self.assertEquals(other_rule_answer_log.answers, {
        'answer2': 1,
    })
    self.assertEquals(other_rule_answer_log.total_answer_count, 1)

dataset/ETHPy150Open oppia/oppia/core/domain/stats_domain_test.py StateRuleAnswerLogUnitTests.test_recording_answer_for_different_rules/original