def test_set_is_polling(self): ''' Test to prevent the slaves from polling the master for updates. ''' tempdict = {'success': 'success', 'errors': 'errors', 'warnings': 'warnings', 'data': 'data'} err = 'solr.set_is_polling can only be called by "slave" minions' with patch.object(solr, '_get_return_dict', return_value={'A': 'a'}): with patch.object(solr, '_is_master', side_effect=[True, False, False]): with patch.object(solr, '_get_none_or_value', side_effect=[None, None, True]): with patch.object(solr, '_check_for_cores', side_effect=[True, False]): self.assertIsNone(solr.set_is_polling('p')) with patch.dict(solr.__opts__, {'solr.cores': MagicMock(return_value='A')}): with patch.object(solr, '_update_return_dict', return_value=tempdict): self.assertDictEqual(solr.set_is_polling('p'), {'A': 'a', 'errors': [err], 'success': False}) with patch.object(solr, '_replication_request', return_value='A'): self.assertEqual(solr.set_is_polling('p'), 'A')
def test_set_is_polling(self): """ Test to prevent the slaves from polling the master for updates. """ tempdict = { "success": "success", "errors": "errors", "warnings": "warnings", "data": "data", } err = 'solr.set_is_polling can only be called by "slave" minions' with patch.object(solr, "_get_return_dict", return_value={"A": "a"}): with patch.object(solr, "_is_master", side_effect=[True, False, False]): with patch.object(solr, "_get_none_or_value", side_effect=[None, None, True]): with patch.object(solr, "_check_for_cores", side_effect=[True, False]): self.assertIsNone(solr.set_is_polling("p")) with patch.dict( solr.__opts__, {"solr.cores": MagicMock(return_value="A")}): with patch.object(solr, "_update_return_dict", return_value=tempdict): self.assertDictEqual( solr.set_is_polling("p"), { "A": "a", "errors": [err], "success": False }, ) with patch.object(solr, "_replication_request", return_value="A"): self.assertEqual(solr.set_is_polling("p"), "A")