<gh_stars>1-10
# coding: utf-8

"""
    OpenAPI Petstore

    This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\  # noqa: E501

    The version of the OpenAPI document: 1.0.0
    Generated by: https://openapi-generator.tech
"""


import sys
import unittest

import petstore_api
from petstore_api.model.date_with_validations import DateWithValidations
from petstore_api.model.date_time_with_validations import DateTimeWithValidations
from petstore_api.model.string_with_validation import StringWithValidation
from petstore_api.model.integer_enum_one_value import IntegerEnumOneValue
from petstore_api.model.integer_enum import IntegerEnum
from petstore_api.model.integer_enum_big import IntegerEnumBig
from petstore_api.model.integer_max10 import IntegerMax10
from petstore_api.model.integer_min15 import IntegerMin15
from petstore_api.model.nullable_string import NullableString
from petstore_api.schemas import AnyTypeSchema, Schema, NoneSchema, StrSchema, none_type, Singleton


class TestCombineNonObjectSchemas(unittest.TestCase):

    def test_valid_enum_plus_prim(self):
        class EnumPlusPrim(IntegerMax10, IntegerEnumOneValue):
            pass

        assert EnumPlusPrim._enum_value_to_name == {0: "POSITIVE_0"}

        # order of base classes does not matter
        class EnumPlusPrim(IntegerEnumOneValue, IntegerMax10):
            pass

        assert EnumPlusPrim._enum_value_to_name == {0: "POSITIVE_0"}

        # _enum_value_to_name only contains one key
        assert set(EnumPlusPrim._enum_value_to_name) == {0}
        # the value is the expected enum class
        enum_value_cls = EnumPlusPrim._enum_by_value[0]
        assert issubclass(enum_value_cls, EnumPlusPrim)
        assert issubclass(enum_value_cls, Singleton)
        assert issubclass(enum_value_cls, int)
        # the enum stored in that class is expected
        enum_value = enum_value_cls.POSITIVE_0
        assert isinstance(enum_value, EnumPlusPrim)
        assert isinstance(enum_value, Singleton)
        assert isinstance(enum_value, int)
        # we can access this enum from our class
        assert EnumPlusPrim.POSITIVE_0 == enum_value

        # invalid value throws an exception
        with self.assertRaises(petstore_api.ApiValueError):
            EnumPlusPrim(9)

        # valid value succeeds
        val = EnumPlusPrim(0)
        assert val == 0
        assert isinstance(val, EnumPlusPrim)
        assert isinstance(val, Singleton)
        assert isinstance(val, int)

    def test_valid_enum_plus_enum(self):
        class IntegerOneEnum(IntegerEnum, IntegerEnumOneValue):
            pass

        assert IntegerOneEnum._enum_value_to_name == {0: "POSITIVE_0"}

        # order of base classes does not matter
        class IntegerOneEnum(IntegerEnumOneValue, IntegerEnum):
            pass

        assert IntegerOneEnum._enum_value_to_name == {0: "POSITIVE_0"}

        # _enum_by_value only contains one key
        assert set(IntegerOneEnum._enum_by_value) == {0}
        # the value is the expected enum class
        enum_value_cls = IntegerOneEnum._enum_by_value[0]
        assert issubclass(enum_value_cls, IntegerOneEnum)
        assert issubclass(enum_value_cls, Singleton)
        assert issubclass(enum_value_cls, int)
        # the enum stored in that class is expected
        enum_value = enum_value_cls.POSITIVE_0
        assert isinstance(enum_value, IntegerOneEnum)
        assert isinstance(enum_value, Singleton)
        assert isinstance(enum_value, int)
        # we can access this enum from our class
        assert IntegerOneEnum.POSITIVE_0 == enum_value

        # accessing invalid enum throws an exception
        invalid_enums = ['POSITIVE_1', 'POSITIVE_2']
        for invalid_enum in invalid_enums:
            with self.assertRaises(petstore_api.ApiValueError):
                getattr(IntegerOneEnum, invalid_enum)


if __name__ == '__main__':
    unittest.main()

# coding: utf-8

"""
    OpenAPI Petstore

    This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\  # noqa: E501

    The version of the OpenAPI document: 1.0.0
    Generated by: https://openapi-generator.tech
"""


import sys
import unittest

import petstore_api
from petstore_api.model.date_with_validations import DateWithValidations
from petstore_api.model.date_time_with_validations import DateTimeWithValidations
from petstore_api.model.string_with_validation import StringWithValidation
from petstore_api.model.integer_enum_one_value import IntegerEnumOneValue
from petstore_api.model.integer_enum import IntegerEnum
from petstore_api.model.integer_enum_big import IntegerEnumBig
from petstore_api.model.integer_max10 import IntegerMax10
from petstore_api.model.integer_min15 import IntegerMin15
from petstore_api.model.nullable_string import NullableString
from petstore_api.schemas import AnyTypeSchema, Schema, NoneSchema, StrSchema, none_type, Singleton


class TestCombineNonObjectSchemas(unittest.TestCase):

    def test_valid_enum_plus_prim(self):
        class EnumPlusPrim(IntegerMax10, IntegerEnumOneValue):
            pass

        assert EnumPlusPrim._enum_value_to_name == {0: "POSITIVE_0"}

        # order of base classes does not matter
        class EnumPlusPrim(IntegerEnumOneValue, IntegerMax10):
            pass

        assert EnumPlusPrim._enum_value_to_name == {0: "POSITIVE_0"}

        # _enum_value_to_name only contains one key
        assert set(EnumPlusPrim._enum_value_to_name) == {0}
        # the value is the expected enum class
        enum_value_cls = EnumPlusPrim._enum_by_value[0]
        assert issubclass(enum_value_cls, EnumPlusPrim)
        assert issubclass(enum_value_cls, Singleton)
        assert issubclass(enum_value_cls, int)
        # the enum stored in that class is expected
        enum_value = enum_value_cls.POSITIVE_0
        assert isinstance(enum_value, EnumPlusPrim)
        assert isinstance(enum_value, Singleton)
        assert isinstance(enum_value, int)
        # we can access this enum from our class
        assert EnumPlusPrim.POSITIVE_0 == enum_value

        # invalid value throws an exception
        with self.assertRaises(petstore_api.ApiValueError):
            EnumPlusPrim(9)

        # valid value succeeds
        val = EnumPlusPrim(0)
        assert val == 0
        assert isinstance(val, EnumPlusPrim)
        assert isinstance(val, Singleton)
        assert isinstance(val, int)

    def test_valid_enum_plus_enum(self):
        class IntegerOneEnum(IntegerEnum, IntegerEnumOneValue):
            pass

        assert IntegerOneEnum._enum_value_to_name == {0: "POSITIVE_0"}

        # order of base classes does not matter
        class IntegerOneEnum(IntegerEnumOneValue, IntegerEnum):
            pass

        assert IntegerOneEnum._enum_value_to_name == {0: "POSITIVE_0"}

        # _enum_by_value only contains one key
        assert set(IntegerOneEnum._enum_by_value) == {0}
        # the value is the expected enum class
        enum_value_cls = IntegerOneEnum._enum_by_value[0]
        assert issubclass(enum_value_cls, IntegerOneEnum)
        assert issubclass(enum_value_cls, Singleton)
        assert issubclass(enum_value_cls, int)
        # the enum stored in that class is expected
        enum_value = enum_value_cls.POSITIVE_0
        assert isinstance(enum_value, IntegerOneEnum)
        assert isinstance(enum_value, Singleton)
        assert isinstance(enum_value, int)
        # we can access this enum from our class
        assert IntegerOneEnum.POSITIVE_0 == enum_value

        # accessing invalid enum throws an exception
        invalid_enums = ['POSITIVE_1', 'POSITIVE_2']
        for invalid_enum in invalid_enums:
            with self.assertRaises(petstore_api.ApiValueError):
                getattr(IntegerOneEnum, invalid_enum)


if __name__ == '__main__':
    unittest.main()
# coding: utf-8 OpenAPI Petstore      This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\  # noqa: E501      The version of the OpenAPI document: 1.0.0     Generated by: https://openapi-generator.tech # order of base classes does not matter # _enum_value_to_name only contains one key # the value is the expected enum class # the enum stored in that class is expected # we can access this enum from our class # invalid value throws an exception # valid value succeeds # order of base classes does not matter # _enum_by_value only contains one key # the value is the expected enum class # the enum stored in that class is expected # we can access this enum from our class # accessing invalid enum throws an exception