def test_callback_server를_이용한_인증_에러(self): while PyTistory._is_listening(): time.sleep(0.1) process = multiprocessing.Process(target=send_access_token_error) process.start() pytistory = PyTistory() pytistory.__TESTING__ = True self.assertRaises(TokenNotFoundError, pytistory.configure, client_id='some-client-id') process.join()
def test_callback_server를_이용한_인증(self): while PyTistory._is_listening(): time.sleep(0.1) process = multiprocessing.Process(target=send_access_token) process.start() pytistory = PyTistory() pytistory.__TESTING__ = True pytistory.configure(client_id='some-client-id') self.assertEqual(pytistory.access_token, 'some-access-token', 'Access Token 설정 실패') process.join()
def test_파일을_통한_인증_CLIENT_ID만(self, _1, _2): while PyTistory._is_listening(): time.sleep(0.1) process = multiprocessing.Process(target=send_access_token) process.start() pytistory = PyTistory() pytistory.__TESTING__ = True pytistory.configure() self.assertEqual(pytistory.access_token, 'some-access-token', 'Access Token 설정 실패') process.join()
def test_파일을_통한_인증_오류(self, _1, _2): pytistory = PyTistory() pytistory.__TESTING__ = True self.assertRaises(ConfigurationError, pytistory.configure, file_name='') self.assertRaises(ConfigurationError, pytistory.configure, file_name='asdf') _1.return_value = True with unittest.mock.patch( 'builtins.open', unittest.mock.mock_open(read_data="")): self.assertRaises(InvalidSectionError, pytistory.configure, file_name='asdf') with unittest.mock.patch( 'builtins.open', unittest.mock.mock_open(read_data="[pytistory]")): self.assertRaises(InvalidNameError, pytistory.configure, file_name='asdf')