Skip to content

Commit

Permalink
Add test for single member enums
Browse files Browse the repository at this point in the history
  • Loading branch information
chiragjn committed Oct 28, 2024
1 parent de72b87 commit 74ae761
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,28 @@ def test_enum_ref_property(self):
self.assertEqual(d5.__fields_set__, {'value', 'str_value'})
self.assertEqual(d5.to_json(), '{"value": 1, "str_value": null}')

def test_enum_string_single_member(self):
enum_test = petstore_api.EnumTest(
enum_string_required="lower",
enum_string_single_member="abc",
enum_integer_single_member=100,
)
self.assertEqual(enum_test.enum_string_single_member, "abc")
self.assertEqual(enum_test.enum_integer_single_member, 100)
with self.assertRaises(ValueError) as e:
enum_test = petstore_api.EnumTest(
enum_string_required="lower",
enum_string_single_member="ab",
)
self.assertTrue("must be one of enum values ('abc')" in str(e))

with self.assertRaises(ValueError) as e:
enum_test = petstore_api.EnumTest(
enum_string_required="lower",
enum_integer_single_member=10,
)
self.assertTrue("must be one of enum values (100)" in str(e))

def test_valdiator(self):
# test regular expression
a = petstore_api.FormatTest(number=123.45, byte=bytes("string", 'utf-8'), date="2013-09-17", password="testing09876")
Expand Down Expand Up @@ -414,7 +436,6 @@ def test_object_id(self):
pet_ap4 = petstore_api.Pet.from_dict(pet_ap.to_dict())
self.assertNotEqual(id(pet_ap3), id(pet_ap4))


def test_additional_properties(self):
pet_ap = petstore_api.Pet(name="test name", photo_urls=["string"])
pet_ap.id = 1
Expand Down

0 comments on commit 74ae761

Please sign in to comment.