Пример #1
0
 def test_complex(self):
     parsed = mask.parse('field1, nested{field, sub{subfield}}, field2')
     expected = [
         'field1',
         mask.Nested('nested',
                     ['field', mask.Nested('sub', ['subfield'])]), 'field2'
     ]
     self.assertEqual(parsed, expected)
Пример #2
0
 def test_complex(self):
     parsed = mask.parse('field1, nested{field, sub{subfield}}, field2')
     expected = [
         'field1',
         mask.Nested('nested', [
             'field',
             mask.Nested('sub', ['subfield'])
         ]),
         'field2'
     ]
     self.assertEqual(parsed, expected)
Пример #3
0
 def test_one_field(self):
     self.assertEqual(mask.parse('field_name'), ['field_name'])
Пример #4
0
 def test_empty_mask(self):
     self.assertEqual(mask.parse(''), [])
Пример #5
0
 def test_empty_mask(self):
     self.assertEqual(mask.parse(''), [])
Пример #6
0
 def parse(self, value):
     return mask.parse(value)
Пример #7
0
 def test_coma_after_bracket(self):
     with self.assertRaises(mask.ParseError):
         mask.parse('nested{,}')
Пример #8
0
 def test_consecutive_coma(self):
     with self.assertRaises(mask.ParseError):
         mask.parse('field,,')
Пример #9
0
 def test_consecutive_coma(self):
     with self.assertRaises(mask.ParseError):
         mask.parse('field,,')
Пример #10
0
 def test_missing_closing_bracket(self):
     with self.assertRaises(mask.ParseError):
         mask.parse('nested{')
Пример #11
0
 def test_star(self):
     parsed = mask.parse('nested{field1,field2},*')
     expected = [mask.Nested('nested', ['field1', 'field2']), '*']
     self.assertEqual(parsed, expected)
Пример #12
0
 def test_nested_fields(self):
     parsed = mask.parse('nested{field1,field2}')
     expected = [mask.Nested('nested', ['field1', 'field2'])]
     self.assertEqual(parsed, expected)
Пример #13
0
 def test_multiple_field(self):
     parsed = mask.parse('field1, field2,field3')
     self.assertEqual(parsed, ['field1', 'field2', 'field3'])
Пример #14
0
 def test_one_field(self):
     self.assertEqual(mask.parse('field_name'), ['field_name'])
Пример #15
0
 def test_multiple_field(self):
     parsed = mask.parse('field1, field2,field3')
     self.assertEqual(parsed, ['field1', 'field2', 'field3'])
Пример #16
0
 def test_coma_before_bracket(self):
     with self.assertRaises(mask.ParseError):
         mask.parse('field,{}')
Пример #17
0
 def test_nested_fields(self):
     parsed = mask.parse('nested{field1,field2}')
     expected = [mask.Nested('nested', ['field1', 'field2'])]
     self.assertEqual(parsed, expected)
Пример #18
0
 def test_coma_after_bracket(self):
     with self.assertRaises(mask.ParseError):
         mask.parse('nested{,}')
Пример #19
0
 def test_missing_closing_bracket(self):
     with self.assertRaises(mask.ParseError):
         mask.parse('nested{')
Пример #20
0
 def test_unexpected_closing_bracket(self):
     with self.assertRaises(mask.ParseError):
         mask.parse('{field}}')
Пример #21
0
 def test_coma_before_bracket(self):
     with self.assertRaises(mask.ParseError):
         mask.parse('field,{}')
Пример #22
0
 def parse(self, value):
     return mask.parse(value)
Пример #23
0
 def test_unexpected_closing_bracket(self):
     with self.assertRaises(mask.ParseError):
         mask.parse('{field}}')
Пример #24
0
 def parse(self, value):
     return mask.parse('{' + value + '}')
Пример #25
0
 def parse(self, value):
     return mask.parse('{' + value + '}')
Пример #26
0
 def test_star(self):
     parsed = mask.parse('nested{field1,field2},*')
     expected = [mask.Nested('nested', ['field1', 'field2']), '*']
     self.assertEqual(parsed, expected)