Esempio n. 1
0
 def test_get_all_calls_get_with_uri_and_params(self, mock_connection,
                                                mock_get_all_response):
     service = DeviceService(mock_connection)
     mock_connection.get.return_value = mock_get_all_response
     for _ in service.get_all(q="TEST-HOSTNAME"):
         break
     expected_params = DEFAULT_GET_DEVICES_PARAMS
     expected_params["q"] = "TEST-HOSTNAME"
     first_call = mock_connection.get.call_args_list[0]
     assert first_call[0][0] == COMPUTER_URI
     assert first_call[1]["params"] == DEFAULT_GET_DEVICES_PARAMS
Esempio n. 2
0
 def test_unicode_hostname_get_devices_calls_get_with_unicode_q_param(
         self, mock_connection, mock_get_all_response):
     unicode_hostname = u"您已经发现了秘密信息"
     service = DeviceService(mock_connection)
     mock_connection.get.return_value = mock_get_all_response
     for _ in service.get_all(q=unicode_hostname):
         break
     first_call = mock_connection.get.call_args_list[0]
     assert first_call[0][0] == COMPUTER_URI
     params = DEFAULT_GET_DEVICES_PARAMS
     params["q"] = unicode_hostname
     assert first_call[1]["params"] == params
Esempio n. 3
0
 def test_get_all_calls_get_expected_number_of_times(
         self, mock_connection, mock_get_all_response,
         mock_get_all_empty_response):
     py42.settings.items_per_page = 1
     service = DeviceService(mock_connection)
     mock_connection.get.side_effect = [
         mock_get_all_response,
         mock_get_all_response,
         mock_get_all_empty_response,
     ]
     for _ in service.get_all():
         pass
     py42.settings.items_per_page = 500
     assert mock_connection.get.call_count == 3