Пример #1
0
 def test_special_cases(self):
     self.assertEqual(
         data_types.AnyValue('str'),
         data_types.get_typed_value(None, data_types.AnyValue('str')))
     self.assertEqual(
         data_types.RegexValue(r'^Sing(le)?$'),
         data_types.get_typed_value('does not matter',
                                    data_types.RegexValue(r'^Sing(le)?$')),
     )
     self.assertIsNone(data_types.get_typed_value('None',
                                                  'does not matter'))
     self.assertIsNone(data_types.get_typed_value('none',
                                                  'does not matter'))
     self.assertIsNone(data_types.get_typed_value('null',
                                                  'does not matter'))
     self.assertEqual(
         '[[some.substitution]]',
         data_types.get_typed_value(None, '[[some.substitution]]'))
     self.assertEqual(
         '[[another.1.substitution]]',
         data_types.get_typed_value('does not matter',
                                    '[[another.1.substitution]]'),
     )
     self.assertEqual(
         '[[ACTION_NAME.0.response.body.path]]',
         data_types.get_typed_value(None,
                                    '[[ACTION_NAME.response.body.path]]'),
     )
     self.assertEqual(
         '[[ANOTHER.2.response.body.path]]',
         data_types.get_typed_value(None,
                                    '[[ANOTHER.2.response.body.path]]'),
     )
     self.assertEqual(
         '[[{ESCAPED}.response.body.path]]',
         data_types.get_typed_value(None,
                                    '[[{ESCAPED}.response.body.path]]'),
     )
     self.assertEqual(
         'complex [[some.substitution]] expression [[another.1.substitution]] with '
         '[[ACTION_NAME.0.response.body.path]] many [[ANOTHER.2.response.body.path]] substitutions '
         '[[{ESCAPED}.response.body.path]]',
         data_types.get_typed_value(
             None,
             'complex [[some.substitution]] expression [[another.1.substitution]] with '
             '[[ACTION_NAME.response.body.path]] many [[ANOTHER.2.response.body.path]] substitutions '
             '[[{ESCAPED}.response.body.path]]',
         ))
Пример #2
0
 def test_regex_value(self):
     self.assertEqual(data_types.RegexValue(r'^Sing(le)?$'),
                      data_types.RegexValue(r'^Sing(le)?$'))
     self.assertEqual(data_types.RegexValue(r'^Sing(le)?$', True),
                      data_types.RegexValue(r'^Sing(le)?$', True))
     self.assertNotEqual(data_types.RegexValue(r'^Sing(le)?$'),
                         data_types.RegexValue(r'^Sing(le)?$', True))
     self.assertNotEqual(data_types.RegexValue(r'^Sing(le)?$'),
                         data_types.RegexValue(r'^Sing$'))
Пример #3
0
 def test_string(self):
     self.assertEqual(data_types.RegexValue(r'^Sing(le)?$'), 'Single')
     self.assertNotEqual(data_types.RegexValue(r'^Sing(le)?$', True),
                         'Single')
     self.assertEqual(data_types.RegexValue(r'^Sing(le)?$'), 'Sing')
     self.assertNotEqual(data_types.RegexValue(r'^Sing(le)?$', True),
                         'Sing')
     self.assertEqual(data_types.RegexValue(r'^Tang(le)?$'), 'Tangle')
     self.assertNotEqual(data_types.RegexValue(r'^Tang(le)?$', True),
                         'Tangle')
     self.assertEqual(data_types.RegexValue(r'^Tang(le)?$'), 'Tang')
     self.assertNotEqual(data_types.RegexValue(r'^Tang(le)?$', True),
                         'Tang')
Пример #4
0
 def test_copy(self):
     self.assertEqual(copy.copy(data_types.RegexValue(r'^Sing(le)?$')),
                      'Single')
     self.assertEqual(copy.deepcopy(data_types.RegexValue(r'^Sing(le)?$')),
                      'Sing')
Пример #5
0
 def test_not_string(self):
     self.assertNotEqual(data_types.RegexValue(r'^Sing(le)?$'), b'Single')
     self.assertNotEqual(data_types.RegexValue(r'^Sing(le)?$'), 15)
     self.assertNotEqual(data_types.RegexValue(r'^Sing(le)?$'), 7.81)
     self.assertNotEqual(data_types.RegexValue(r'^Sing(le)?$'), True)
     self.assertNotEqual(data_types.RegexValue(r'^Sing(le)?$'), None)