Пример #1
0
 def test_schema_correct(self):
     assert SettingsTwoFour.schema == {
         'bar':
         fields.Integer(),
         'baz':
         fields.Dictionary(
             {
                 'inner_foo':
                 fields.UnicodeString(),
                 'inner_bar':
                 fields.Boolean(),
                 'inner_baz':
                 fields.List(fields.Integer()),
                 'inner_qux':
                 fields.Dictionary(
                     {
                         'most_inner_foo': fields.Boolean(),
                         'most_inner_bar': fields.UnicodeString(),
                     }, ),
             }, ),
         'qux':
         fields.Decimal(),
         'new':
         fields.ByteString(),
         'old':
         fields.UnicodeString(),
     }
Пример #2
0
 def test_schema_correct(self):
     assert SettingsFour.schema == {
         'baz': fields.List(fields.Float()),
         'qux': fields.Decimal(),
         'new': fields.ByteString(),
         'old': fields.UnicodeString(),
     }
Пример #3
0
 def test_schema_correct(self):
     assert SettingsTwoFourWithOverrides.schema == {
         'bar': fields.Integer(),
         'baz': fields.ByteString(),
         'qux': fields.Decimal(),
         'new': fields.ByteString(),
         'old': fields.UnicodeString(),
     }
Пример #4
0
 def test_schema_correct(self):
     assert SettingsOneTwoThreeWithOverridesExtended.schema == {
         'foo': fields.UnicodeString(),
         'bar': fields.Boolean(),
         'baz': fields.ByteString(),
         'qux': fields.Decimal(),
         'new': fields.ByteString(),
         'old': fields.UnicodeString(),
     }
Пример #5
0
class SettingsFour(SettingsThree):
    schema = {
        'qux': fields.Decimal(),
        'new': fields.ByteString(),
        'old': fields.UnicodeString(),
    }  # type: SettingsSchema

    defaults = {
        'qux': decimal.Decimal('1.234'),
        'old': 'Default old',
    }  # type: SettingsData
Пример #6
0
class SettingsOneTwoThreeWithOverridesExtended(SettingsOneTwoThreeWithOverrides
                                               ):
    schema = {
        'qux': fields.Decimal(),
        'new': fields.ByteString(),
        'old': fields.UnicodeString(),
    }  # type: SettingsSchema

    defaults = {
        'qux': decimal.Decimal('1.234'),
        'old': 'Default old',
    }  # type: SettingsData
Пример #7
0
        ),
    }

    defaults: settings.SettingsData = {
        'one': {
            'b': 'foo.bar:Class',
        },
        'three': [1, 5, 7],
    }


@fields.ClassConfigurationSchema.provider(fields.Dictionary(
    collections.OrderedDict((
        ('one', fields.UnicodeString()),
        ('two', fields.Boolean()),
        ('three', fields.Decimal()),
    )),
    description='This is the neatest documentation for a class',
))
class ClassConfigurationToTest:
    pass


@pytest.mark.parametrize(
    ('obj', 'annotations'),
    (
        (ClassHoldingSigsToTest.sig1, {'one': AnyStr, 'two': Optional[bool], 'return': None}),
        (ClassHoldingSigsToTest.sig1_35, {'one': AnyStr, 'two': Optional[bool], 'return': None}),
        (ClassHoldingSigsToTest.sig2, {'one': bool, 'two': Optional[AnyStr], 'args': int, 'return': List[int]}),
        (ClassHoldingSigsToTest.sig2_35, {'one': bool, 'two': Optional[AnyStr], 'args': int, 'return': List[int]}),
        (ClassHoldingSigsToTest.sig3, {