def test_standbys_unset(self, is_ready): # Standbys helper returns None when no relation data is set. is_ready.return_value = True # No connection details present on relation, yet. self.assertEqual( client._standbys(self.log, self.relation, self.local_unit), []) self.assertFalse(is_ready.called)
def test_standbys_unready(self, is_ready): # Standbys helper returns None when relation app data is set but not yet ready. is_ready.return_value = False standbys = ["host=standby1", "host=standby2"] rd = {"master": "host=master", "standbys": "\n".join(standbys)} self.harness.update_relation_data(self.relation_id, self.remote_app_name, rd) self.assertEqual( client._standbys(self.log, self.relation, self.local_unit), []) self.assertTrue(is_ready.called) is_ready.assert_called_once_with( self.log, self.leadership_data, self.relation.data[self.local_unit], self.relation.data[self.remote_app], )
def test_standbys_legacy(self, is_ready): # Ensure we fall back to using unit relation data if the app relation data is unset. is_ready.return_value = True standbys = ["host=standby1", "host=standby2"] rd = {"master": "host=master", "standbys": "\n".join(standbys)} self.harness.update_relation_data(self.relation_id, self.remote_unit_names[1], rd) self.assertEqual( client._standbys(self.log, self.relation, self.local_unit), standbys) self.assertTrue(is_ready.called) is_ready.assert_called_once_with( self.log, self.leadership_data, self.relation.data[self.local_unit], self.relation.data[self.remote_units[1]], )