def test_dialogue_state_rule_exception(): with pytest.raises(ValueError): DialogueStateRule(dialogue_state="some-state", has_entities=[1, 2]) rule1 = DialogueStateRule(dialogue_state="some-state", has_entity="entity_1") assert rule1.entity_types == frozenset(("entity_1", )) rule2 = DialogueStateRule(dialogue_state="some-state", has_entities=["entity_2", "entity_3"]) assert rule2.entity_types == frozenset(( "entity_2", "entity_3", )) with pytest.raises(ValueError): DialogueStateRule( dialogue_state="some-state", has_entity="entity_1", has_entities=["entity_2", "entity_3"], ) with pytest.raises(NotImplementedError): assert rule1 == 1 with pytest.raises(NotImplementedError): assert rule1 != 1 assert repr(rule1) == "<DialogueStateRule 'some-state'>" with pytest.raises(NotImplementedError): assert DialogueStateRule.compare(rule1, 1)
def test_dialogue_state_rule_not_equal(): rule1 = DialogueStateRule(dialogue_state="some-state", domain="some-domain") rule2 = DialogueStateRule(dialogue_state="some-state-2", domain="some-domain") assert rule1 != rule2 rule2 = DialogueStateRule(dialogue_state="some-state") assert rule1 != rule2 rule2 = DialogueStateRule( dialogue_state="some-state", domain="some-domain", intent="some-intent" ) assert rule1 != rule2
def test_dialogue_state_rule_targeted_only(): request = create_request('some-domain', 'some-intent') rule1 = DialogueStateRule(dialogue_state='some-state', targeted_only=True) assert not rule1.apply(request) with pytest.raises(ValueError) as ex: DialogueStateRule(dialogue_state='some-state', domain='some-domain', targeted_only=True) msg = "For a dialogue state rule, if targeted_only is True, domain, intent, and has_entity" \ " must be omitted" assert msg in str(ex)
def test_dialogue_state_rule_not_equal(): rule1 = DialogueStateRule(dialogue_state='some-state', domain='some-domain') rule2 = DialogueStateRule(dialogue_state='some-state-2', domain='some-domain') assert rule1 != rule2 rule2 = DialogueStateRule(dialogue_state='some-state') assert rule1 != rule2 rule2 = DialogueStateRule(dialogue_state='some-state', domain='some-domain', intent='some-intent') assert rule1 != rule2
def test_dialogue_state_rule_unexpected_keyword(): with pytest.raises(TypeError) as ex: DialogueStateRule(dialogue_state="some-state", domain="some-domain", new_key="some-key") assert "DialogueStateRule() got an unexpected keyword argument 'new_key'" in str( ex.value)
def test_dialogue_state_rule_equal(): rule1 = DialogueStateRule(dialogue_state="some-state", domain="some-domain") rule2 = DialogueStateRule(dialogue_state="some-state", domain="some-domain") assert rule1 == rule2
def test_dialogue_state_rule_equal(): rule1 = DialogueStateRule(dialogue_state='some-state', domain='some-domain') rule2 = DialogueStateRule(dialogue_state='some-state', domain='some-domain') assert rule1 == rule2