Skip to content

Commit

Permalink
Create test_exceptions.py
Browse files Browse the repository at this point in the history
  • Loading branch information
oberbichler committed Jul 8, 2023
1 parent 16cd0d0 commit c7d5a08
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions tests/test_exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import pytest

from protosaurus import Context
from base64 import b64decode


if __name__ == "__main__":
pytest.main()


@pytest.fixture
def ctx():
return Context()


def test_invalid_proto(ctx):
with pytest.raises(RuntimeError):
ctx.add_proto('test',
"""
syntax = "proto3";
message test {
data;
}
""")

def test_invalid_message_type(ctx):
with pytest.raises(RuntimeError):
ctx.add_proto('test',
"""
syntax = "proto3";
message test {
bool data = 1;
}
""")

ctx.as_json('invalid type', b64decode('CAE='))

def test_invalid_data(ctx):
with pytest.raises(RuntimeError):
ctx.add_proto('test',
"""
syntax = "proto3";
message test {
bool data = 1;
}
""")

ctx.as_json('test', b'invalid data')

0 comments on commit c7d5a08

Please sign in to comment.