Add support for pydantic dataclasses (#406)
This commit is contained in:
@@ -1,6 +1,19 @@
|
||||
import pytest
|
||||
|
||||
from tests.output_betterproto.bool import Test
|
||||
from tests.output_betterproto_pydantic.bool import Test as TestPyd
|
||||
|
||||
|
||||
def test_value():
|
||||
message = Test()
|
||||
assert not message.value, "Boolean is False by default"
|
||||
|
||||
|
||||
def test_pydantic_no_value():
|
||||
with pytest.raises(ValueError):
|
||||
TestPyd()
|
||||
|
||||
|
||||
def test_pydantic_value():
|
||||
message = Test(value=False)
|
||||
assert not message.value
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import betterproto
|
||||
from tests.output_betterproto.oneof import Test
|
||||
from tests.output_betterproto_pydantic.oneof import Test as TestPyd
|
||||
from tests.util import get_test_case_json_data
|
||||
|
||||
|
||||
@@ -13,3 +14,8 @@ def test_which_name():
|
||||
message = Test()
|
||||
message.from_json(get_test_case_json_data("oneof", "oneof_name.json")[0].json)
|
||||
assert betterproto.which_one_of(message, "foo") == ("pitier", "Mr. T")
|
||||
|
||||
|
||||
def test_which_count_pyd():
|
||||
message = TestPyd(pitier="Mr. T", just_a_regular_field=2, bar_name="a_bar")
|
||||
assert betterproto.which_one_of(message, "foo") == ("pitier", "Mr. T")
|
||||
|
||||
Reference in New Issue
Block a user