def test_multiple_field(self):
     mask = Mask('field1, field2, field3')
     assert_data(mask, {
         'field1': True,
         'field2': True,
         'field3': True,
     })
 def test_nested_fields(self):
     parsed = Mask('nested{field1,field2}')
     expected = {
         'nested': {
             'field1': True,
             'field2': True,
         }
     }
     assert parsed == expected
 def test_star(self):
     parsed = Mask('nested{field1,field2},*')
     expected = {
         'nested': {
             'field1': True,
             'field2': True,
         },
         '*': True,
     }
     assert_data(parsed, expected)
 def test_complex(self):
     parsed = Mask('field1, nested{field, sub{subfield}}, field2')
     expected = {
         'field1': True,
         'nested': {
             'field': True,
             'sub': {
                 'subfield': True,
             }
         },
         'field2': True,
     }
     assert_data(parsed, expected)
 def test_order(self):
     parsed = Mask('f_3, nested{f_1, f_2, f_3}, f_2, f_1')
     expected = OrderedDict([
         ('f_3', True),
         ('nested',
          OrderedDict([
              ('f_1', True),
              ('f_2', True),
              ('f_3', True),
          ])),
         ('f_2', True),
         ('f_1', True),
     ])
     assert parsed == expected
 def test_coma_before_bracket(self):
     with pytest.raises(mask.ParseError):
         Mask('field,{}')
 def test_consecutive_coma(self):
     with pytest.raises(mask.ParseError):
         Mask('field,,')
 def test_missing_closing_bracket(self):
     with pytest.raises(mask.ParseError):
         Mask('nested{')
 def test_support_dash(self):
     assert Mask('field-name') == {'field-name': True}
 def test_one_field(self):
     assert Mask('field_name') == {'field_name': True}
 def test_empty_mask(self):
     assert Mask('') == {}
 def parse(self, value):
     return Mask('{' + value + '}')
 def parse(self, value):
     return Mask(value)
 def test_support_underscore(self):
     assert Mask('field_name') == {'field_name': True}
 def test_coma_after_bracket(self):
     with pytest.raises(mask.ParseError):
         Mask('nested{,}')
 def test_unexpected_opening_bracket(self):
     with pytest.raises(mask.ParseError):
         Mask('{{field}}')
 def test_support_colons(self):
     assert Mask('field:name') == {'field:name': True}