def test_set_session(self, mock_session: Session, mock_random): # Arrange mock_random.return_value = 1 mock_session.return_value = mock_session mock_session.cookies = MagicMock() self.slave.ip_addr = "123.4567.8910" # Act self.slave.set_session(mock_session) cookie = mock_session.cookies.set_cookie.call_args[0][0].value # Assert assert self.slave.ip_addr in cookie
def test_attempt_master_connection(self, mock_session: Session, mock_resp: Response): # Arrange mock_session.return_value = mock_session mock_resp.status_code = 200 mock_session.get.return_value = mock_resp mock_session.cookies = MagicMock() # Act self.slave.attempt_master_connection(5678) # Assert assert self.slave.session == mock_session