Skip to content

Commit

Permalink
Add more coverage for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kinow committed Nov 22, 2023
1 parent be3e2ec commit e812c3e
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,27 @@ def test_contains_dot_proto_in_middle_of_the_name(self):
.build()
assert os.path.getsize(tf) > 0


def test_to_file_with_missing_protobuf(self):
"""A test where the protobuf module is missing."""
with TemporaryDirectory() as tmpdir:
tf = os.path.join(tmpdir, 'diagram.png')
d = Diagram().from_file('test_data.issue_27.proto.configs_data_pb2')
d._proto_module = None
with pytest.raises(ValueError) as cm:
d.to_file(Path(tf))
assert str(cm.value) == 'Missing protobuf module!'


def test_to_file_with_protobuf_missing_file(self):
"""A test where the protobuf module is present but invalid (no file)."""
with TemporaryDirectory() as tmpdir:
tf = os.path.join(tmpdir, 'diagram.png')
d = Diagram().from_file('test_data.issue_27.proto.configs_data_pb2')
d._proto_module = {}
with pytest.raises(ValueError) as cm:
d.to_file(Path(tf))
assert str(cm.value) == 'Missing protobuf module!'



0 comments on commit e812c3e

Please sign in to comment.