31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
# Copyright (C) 2020 by eichhornchen, ÿnérant
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
import sys
|
|
import unittest
|
|
|
|
from squinnondation.squinnondation import Squinnondation
|
|
|
|
|
|
class TestSquinnondation(unittest.TestCase):
|
|
def test_arguments(self) -> None:
|
|
"""
|
|
Parse arguments and check errors.
|
|
"""
|
|
squinnondation = Squinnondation()
|
|
|
|
# No parameter was given
|
|
self.assertRaises(SystemExit, squinnondation.parse_arguments)
|
|
|
|
# Wrong port
|
|
sys.argv = ["squinnondation", "localhost", "42"]
|
|
self.assertRaises(ValueError, squinnondation.parse_arguments)
|
|
|
|
# Esnure that the parsing is correct
|
|
sys.argv = ["squinnondation", "localhost", "4242", "--client_address", "localhost", "--client_port", "2500"]
|
|
squinnondation.parse_arguments()
|
|
self.assertEqual(squinnondation.bind_address, "localhost")
|
|
self.assertEqual(squinnondation.bind_port, 4242)
|
|
self.assertEqual(squinnondation.args.client_address, "localhost")
|
|
self.assertEqual(squinnondation.args.client_port, 2500)
|