コード例 #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)
コード例 #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())