Skip to content

Commit 0322ac7

Browse files
committed
Adding unit test cases for AuthCodeReceiver
1 parent 6622313 commit 0322ac7

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/test_authcode.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import unittest
2+
3+
from oauth2cli.authcode import AuthCodeReceiver
4+
5+
6+
class TestAuthCodeReceiver(unittest.TestCase):
7+
def test_setup_at_a_given_port_and_teardown(self):
8+
port = 12345 # Assuming this port is available
9+
with AuthCodeReceiver(port=port) as receiver:
10+
self.assertEqual(port, receiver.get_port())
11+
12+
def test_setup_at_a_ephemeral_port_and_teardown(self):
13+
port = 0
14+
with AuthCodeReceiver(port=port) as receiver:
15+
self.assertNotEqual(port, receiver.get_port())
16+
17+
def test_no_two_concurrent_receivers_can_listen_on_same_port(self):
18+
port = 12345 # Assuming this port is available
19+
with AuthCodeReceiver(port=port) as receiver:
20+
with self.assertRaises(OSError):
21+
with AuthCodeReceiver(port=port) as receiver2:
22+
pass
23+

0 commit comments

Comments
 (0)