コード例 #1
0
 def test_valid_connection(self, mock_icat_login, mock_icat):
     client = ICATClient()
     mock_icat.assert_called_once()
     client.connect()
     mock_icat_login.assert_called_once()
     mock_icat_login.assert_called_once_with(auth='simple',
                                             credentials={'username': '******',
                                                          'password': '******'})
コード例 #2
0
 def test_query_without_conn(self, mock_search, mock_refresh, mock_connect, mock_set_attr, _):
     # Add side effect to raise exception with icat.refresh
     mock_refresh.side_effect = raise_icat_session_error
     client = ICATClient()
     client.execute_query('icat query')
     mock_refresh.assert_called_once()
     mock_set_attr.assert_called_once()
     mock_connect.assert_called_once()
     mock_search.assert_called_once_with('icat query')
コード例 #3
0
 def test_default_init(self, mock_icat):
     client = ICATClient()
     self.assertEqual(client.credentials.username, 'YOUR-ICAT-USERNAME')
     self.assertEqual(client.credentials.password, 'YOUR-PASSWORD')
     self.assertEqual(client.credentials.host, 'YOUR-ICAT-WSDL-URL')
     self.assertEqual(client.credentials.port, '')
     self.assertEqual(client.credentials.auth, 'simple')
     mock_icat.assert_called_once_with('YOUR-ICAT-WSDL-URL')
コード例 #4
0
 def test_failing_test_connection(self, mock_refresh, _):
     mock_refresh.side_effect = raise_icat_session_error
     client = ICATClient()
     # pylint:disable=protected-access
     self.assertRaisesRegex(ConnectionException, 'ICAT', client._test_connection)
コード例 #5
0
 def test_valid_test_connection(self, mock_refresh, _):
     client = ICATClient()
     # pylint:disable=protected-access
     self.assertTrue(client._test_connection())
     mock_refresh.assert_called_once()
コード例 #6
0
 def test_refresh(self, mock_autorefresh, _):
     client = ICATClient()
     client.refresh()
     mock_autorefresh.assert_called_once()
コード例 #7
0
 def test_disconnect(self, mock_logout, _):
     client = ICATClient()
     client.disconnect()
     mock_logout.assert_called_once()
コード例 #8
0
 def test_query_icat(self, mock_refresh, mock_search, _):
     client = ICATClient()
     client.execute_query('icat query')
     mock_refresh.assert_called_once()
     mock_search.assert_called_once_with('icat query')