2024-01-07 12:03:33 +00:00
|
|
|
from unittest.mock import Mock, patch
|
2023-11-30 15:55:51 +00:00
|
|
|
|
2024-01-17 10:05:37 +00:00
|
|
|
from moto.server import main
|
2013-03-05 13:14:43 +00:00
|
|
|
|
|
|
|
|
2023-12-14 21:35:36 +00:00
|
|
|
def test_wrong_arguments() -> None:
|
2013-03-05 13:14:43 +00:00
|
|
|
try:
|
2024-01-17 10:05:37 +00:00
|
|
|
main(["test1", "test2", "test3"])
|
2013-03-05 13:14:43 +00:00
|
|
|
assert False, (
|
|
|
|
"main() when called with the incorrect number of args"
|
|
|
|
" should raise a system exit"
|
|
|
|
)
|
|
|
|
except SystemExit:
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2013-12-29 01:15:37 +00:00
|
|
|
@patch("moto.server.run_simple")
|
2024-01-07 12:03:33 +00:00
|
|
|
def test_right_arguments(run_simple: Mock) -> None: # type: ignore[misc]
|
2024-01-17 10:05:37 +00:00
|
|
|
main(["-r"])
|
2013-12-29 01:15:37 +00:00
|
|
|
func_call = run_simple.call_args[0]
|
2023-07-10 21:04:31 +00:00
|
|
|
assert func_call[0] == "127.0.0.1"
|
|
|
|
assert func_call[1] == 5000
|
2013-06-25 16:42:24 +00:00
|
|
|
|
|
|
|
|
2013-12-29 01:15:37 +00:00
|
|
|
@patch("moto.server.run_simple")
|
2024-01-07 12:03:33 +00:00
|
|
|
def test_port_argument(run_simple: Mock) -> None: # type: ignore[misc]
|
2024-01-17 10:05:37 +00:00
|
|
|
main(["--port", "8080"])
|
2013-12-29 01:15:37 +00:00
|
|
|
func_call = run_simple.call_args[0]
|
2023-07-10 21:04:31 +00:00
|
|
|
assert func_call[0] == "127.0.0.1"
|
|
|
|
assert func_call[1] == 8080
|