Ejemplo n.º 1
0
 def test_can_add_slot(self):
     correct_j = {
         'name':
         'test',
         'description':
         'description',
         'slots': [{
             'name':
             'test',
             'createVersion':
             'True',
             'valueSelectionStrategy':
             'ORIGINAL_VALUE',
             'description':
             'description',
             'enumerationValues': [{
                 'value': 'AMAZON.STRING',
                 'synonyms': ['test', 'mytest']
             }],
             'checksum':
             'test_chk'
         }]
     }
     s = Slot()
     s.with_name('test') \
      .with_description('description') \
      .with_checksum('test_chk') \
      .with_create_version('True') \
      .with_enumeration_value(EnumerationValue(Value='AMAZON.STRING', Synonyms=['test', 'mytest']))
     i = Intent(Name='test', Description='description')
     i.with_slot(s)
     assert DictUtils.are_same(i.to_json(), correct_j)
Ejemplo n.º 2
0
    def test_minimal_json_is_correct(self):
        correct_j = """
{
   "name":"test",
   "valueSelectionStrategy":"ORIGINAL_VALUE",
   "description": "description",
   "createVersion": "True",
   "checksum": "test_chk",
   "enumerationValues":[
      {
         "value":"AMAZON.STRING",
         "synonyms":[
            "test",
            "mytest"
         ]
      }
   ]
}
"""
        s = Slot()
        s.with_name('test') \
         .with_description('description') \
         .with_checksum('test_chk') \
         .with_create_version('True') \
         .with_enumeration_value(EnumerationValue(Value='AMAZON.STRING', Synonyms=['test', 'mytest']))

        assert DictUtils.are_same(json.loads(correct_j), s.to_json())
Ejemplo n.º 3
0
def get_slot(name, version):
    sm = LexSlotManager()
    slot_type_j = sm.get_slot_type(Name=name, Version=version)
    slot_type = Slot.from_json(slot_type_j)
    print(slot_type)
Ejemplo n.º 4
0
from lex.fluent.slot import Slot
from lex.fluent.intent import Intent, IntentSlot
from lex import LexBotManager, LexIntentManager, LexSlotManager, LexPlayer


s = Slot(Name='testslot').with_value('AMAZON.NUMBER').apply()
sm = LexSlotManager()
slot_j = sm.get_slot_type(Name='testslot')
slot = Slot.from_json(slot_j)
slot.with_description('test description').apply()
slot_j = sm.get_slot_type(Name='testslot')
slot = Slot.from_json(slot_j)
print(slot.to_json())
# s = Slot(Name='test_timeslot').with_description('test_descript').apply()
Ejemplo n.º 5
0
 def test_can_pass_slot_to_intent_slot(self):
     s = Slot(Name='testslot', Description='testdescript')
     intent_slot = IntentSlot(Slot=s).with_slot_constraint('Required')
     assert intent_slot.description == 'testdescript'
     assert intent_slot.name == 'testslot'
     assert intent_slot.slot_constraint == 'Required'
Ejemplo n.º 6
0
 def test_can_set_name(self):
     s = Slot(Name='test')
     assert s.name == 'test'
Ejemplo n.º 7
0
 def test_can_initialize_create_version(self):
     s = Slot(CreateVersion=True)
     assert s.create_version
Ejemplo n.º 8
0
 def test_strategy_defaults_to_original_value(self):
     s = Slot()
     assert s.value_selection_strategy == 'ORIGINAL_VALUE'
Ejemplo n.º 9
0
 def test_create_version_defaults_to_false(self):
     s = Slot()
     assert not s.create_version
Ejemplo n.º 10
0
 def test_can_set_strategy(self):
     s = Slot(ValueSelectionStrategy='TOP_RESOLUTION')
     assert s.value_selection_strategy == 'TOP_RESOLUTION'
Ejemplo n.º 11
0
 def test_can_set_checksum(self):
     s = Slot(Checksum='checksum')
     assert s.checksum == 'checksum'
Ejemplo n.º 12
0
 def test_can_set_description(self):
     s = Slot(Name='test', Description='description')
     assert s.description == 'description'
Ejemplo n.º 13
0
from lex.fluent.slot import Slot
from lex.fluent.intent import Intent, IntentSlot
from lex import LexBotManager, LexIntentManager, LexSlotManager, LexPlayer

s = Slot(Name='testslot').with_value('AMAZON.NUMBER').apply()
s = Slot(Name='test_timeslot').with_description('test_descript').apply()
intslot = IntentSlot(Slot=s)
intslot.with_slot_constraint('Required').with_slot_type('AMAZON.Number')
i = Intent(Name='test_intent').with_slot(intslot).apply()
Ejemplo n.º 14
0
from lex.fluent.slot import Slot
s = Slot().with_name('testslot').get()
print(s.name)