Skip to content

Commit

Permalink
Raise value error via pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
asraza07 committed Jul 19, 2024
1 parent baed48a commit 7f01ed2
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions tests/dhcp_rate_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
import pytest
from unittest.mock import patch
from click.testing import CliRunner
from utilities_common.db import Db
from unittest import mock
Expand Down Expand Up @@ -271,19 +270,21 @@ def test_config_dhcp_rate_add_on_invalid_interface(self):
def test_config_dhcp_rate_add_del_with_value_error(self):
db = Db()
runner = CliRunner()
result = runner.invoke(config.config.commands["interface"].commands["dhcp-mitigation-rate"].commands["del"],
["Ethernet84", "300"], obj=db)
print(result.exit_code)
print(result.output)
assert result.output != 0
assert "Ethernet84 invalid or does not exist" in result.output
with pytest.raises(ValueError):
result = runner.invoke(config.config.commands["interface"].commands["dhcp-mitigation-rate"].commands["del"],
["Ethernet84", "300"], obj=db)
print(result.exit_code)
print(result.output)
assert result.output != 0
assert "Ethernet84 invalid or does not exist" in result.output

result = runner.invoke(config.config.commands["interface"].commands["dhcp-mitigation-rate"].commands["add"],
["Ethernet72", "65"], obj=db)
print(result.exit_code)
print(result.output)
assert result.output != 0
assert "Ethernet72 invalid or does not exist" in result.output
with pytest.raises(ValueError):
result = runner.invoke(config.config.commands["interface"].commands["dhcp-mitigation-rate"].commands["add"],
["Ethernet72", "65"], obj=db)
print(result.exit_code)
print(result.output)
assert result.output != 0
assert "Ethernet72 invalid or does not exist" in result.output

def test_show_dhcp_rate_limit(self):
runner = CliRunner()
Expand Down

0 comments on commit 7f01ed2

Please sign in to comment.