def test_target_all(self):
     self.action_get.return_value = ''
     actions.clear_unit_knownhost_cache([])
     self.action_set.assert_called_once_with({
         "units-updated": [
             {
                 'aservice/1': '10.0.0.1'
             },
             {
                 'aservice/2': '10.0.0.2'
             },
             {
                 'aservice/3': '10.0.0.3'
             },
             {
                 'aservice/4': '10.0.0.4'
             },
             {
                 'bservice/1': '10.0.1.1'
             },
             {
                 'bservice/2': '10.0.1.2'
             },
             {
                 'bservice/3': '10.0.1.3'
             },
         ]
     })
     # check both services were updated; that'll imply the other calls were
     # made.
     self.notify_ssh_keys_to_compute_units.assert_has_calls([
         mock.call(rid="r:1", unit="aservice/4"),
         mock.call(rid="r:2", unit="bservice/3")
     ])
 def test_target_service(self):
     self.action_get.return_value = 'bservice'
     actions.clear_unit_knownhost_cache([])
     self.action_set.assert_called_once_with({
         "units-updated": [
             {
                 'bservice/1': '10.0.1.1'
             },
             {
                 'bservice/2': '10.0.1.2'
             },
             {
                 'bservice/3': '10.0.1.3'
             },
         ]
     })
     self.clear_hostset_cache_for.assert_has_calls([
         mock.call('10.0.1.1'),
         mock.call('10.0.1.2'),
         mock.call('10.0.1.3')
     ])
     self.update_ssh_key.assert_has_calls([
         mock.call(rid="r:2", unit="bservice/1"),
         mock.call(rid="r:2", unit="bservice/2"),
         mock.call(rid="r:2", unit="bservice/3")
     ])
     self.notify_ssh_keys_to_compute_units.assert_has_calls(
         [mock.call(rid="r:2", unit="bservice/3")])
 def test_target_unit(self):
     self.action_get.return_value = 'aservice/2'
     actions.clear_unit_knownhost_cache([])
     self.action_set.assert_called_once_with(
         {"units-updated": [{
             'aservice/2': '10.0.0.2'
         }]})
     self.clear_hostset_cache_for.assert_called_once_with('10.0.0.2')
     self.update_ssh_key.assert_called_once_with(rid="r:1",
                                                 unit="aservice/2")
     self.notify_ssh_keys_to_compute_units.assert_called_once_with(
         rid="r:1", unit="aservice/4")