Ejemplo n.º 1
0
 def test_not_simple_get_key_value_sequence(self):
     rsp = list(generate_key_value_sequences("1  $(val1)$, 2 $(val2)$ ", "default42"))
     expected = [
         {'VALUE': 'val1', 'VALUE1': 'val1', 'KEY': '1'},
         {'VALUE': 'val2', 'VALUE1': 'val2', 'KEY': '2'},
     ]
     assert expected == rsp
Ejemplo n.º 2
0
 def test_syntax_error_bad_value(self):
     generator = generate_key_value_sequences(
         "key $(but bad value: no terminating dollar sign)", '')
     with self.assertRaises(KeyValueSyntaxError) as ctx:
         list(generator)
     self.assertEqual(
         '\'key $(but bad value: no terminating dollar sign)\' is an invalid key(-values) pattern',
         ctx.exception.message)
Ejemplo n.º 3
0
 def test_simple_get_key_value_sequence(self):
     rsp = list(generate_key_value_sequences("1", "default42"))
     expected = [
         {
             'VALUE': 'default42',
             'VALUE1': 'default42',
             'KEY': '1'
         },
     ]
     self.assertEqual(expected, rsp)
Ejemplo n.º 4
0
 def test_syntax_error_bad_value(self):
     generator = generate_key_value_sequences("key $(but bad value: no terminating dollar sign)", '')
     with pytest.raises(KeyValueSyntaxError) as ctx:
         list(generator)
     assert ctx.value.args[0] == "\'key $(but bad value: no terminating dollar sign)\' " \
                                     "is an invalid key(-values) pattern"
Ejemplo n.º 5
0
 def test_syntax_error_bad_empty_value_with_comma(self):
     generator = generate_key_value_sequences(',', '')
     with pytest.raises(KeyValueSyntaxError) as ctx:
         list(generator)
     assert ctx.value.args[0] == "At least one key must be present"
Ejemplo n.º 6
0
 def test_complex(self):
     rsp = list(generate_key_value_sequences('Unit [1-6] Port [0-46]$(80%!90%)$,Unit [1-6] Port 47$(80%!90%)$', ''))
     assert 288 == len(rsp)
 def test_simple_get_key_value_sequence(self):
     rsp = list(generate_key_value_sequences("1", "default42"))
     expected = [
         {'VALUE': 'default42', 'VALUE1': 'default42', 'KEY': '1'},
     ]
     assert expected == rsp
Ejemplo n.º 8
0
 def test_sytnax_error_bad_empty_value_with_comma(self):
     generator = generate_key_value_sequences(',', '')
     with self.assertRaises(KeyValueSyntaxError) as ctx:
         list(generator)
     self.assertEqual(ctx.exception.message,
                      "At least one key must be present")
 def test_syntax_error_bad_value(self):
     generator = generate_key_value_sequences("key $(but bad value: no terminating dollar sign)", '')
     with self.assertRaises(KeyValueSyntaxError) as ctx:
         list(generator)
     self.assertEqual('\'key $(but bad value: no terminating dollar sign)\' is an invalid key(-values) pattern',
                      ctx.exception.message)
 def test_sytnax_error_bad_empty_value_with_comma(self):
     generator = generate_key_value_sequences(',', '')
     with self.assertRaises(KeyValueSyntaxError) as ctx:
         list(generator)
     self.assertEqual(ctx.exception.message, "At least one key must be present")
 def test_sytnax_error_bad_empty_value(self):
     generator = generate_key_value_sequences('', '')
     with pytest.raises(KeyValueSyntaxError) as ctx:
         list(generator)
     assert ctx.value.message == "At least one key must be present"