Exemplo n.º 1
0
    def test_core_status(self):
        '''
        Test to get the status for a given core or all cores
        if no core is specified
        '''
        error = ['solr.reload_core can only be called by "multi-core" minions']
        with patch.object(solr, '_check_for_cores',
                          side_effect=[False, True, True, True]):
            with patch.object(solr, '_get_none_or_value',
                              side_effect=[None, True]):
                with patch.object(solr, '_get_return_dict',
                                  return_value={'A': 'a'}):
                    with patch.object(solr, '_format_url',
                                      return_value='A'):
                        with patch.object(solr, '_http_request',
                                          return_value='A'):
                            with patch.dict(solr.__opts__,
                                            {'solr.cores':
                                             MagicMock(return_value='n')}):

                                self.assertIsNone(solr.core_status())

                                self.assertDictEqual(solr.core_status(),
                                                     {'A': 'a', 'errors': error,
                                                      'success': False})

                                self.assertEqual(solr.core_status(), 'A')
Exemplo n.º 2
0
    def test_core_status(self):
        '''
        Test to get the status for a given core or all cores
        if no core is specified
        '''
        error = ['solr.reload_core can only be called by "multi-core" minions']
        with patch.object(solr,
                          '_check_for_cores',
                          side_effect=[False, True, True, True]):
            with patch.object(solr,
                              '_get_none_or_value',
                              side_effect=[None, True]):
                with patch.object(solr,
                                  '_get_return_dict',
                                  return_value={'A': 'a'}):
                    with patch.object(solr, '_format_url', return_value='A'):
                        with patch.object(solr,
                                          '_http_request',
                                          return_value='A'):
                            with patch.dict(
                                    solr.__opts__,
                                {'solr.cores': MagicMock(return_value='n')}):

                                self.assertIsNone(solr.core_status())

                                self.assertDictEqual(solr.core_status(), {
                                    'A': 'a',
                                    'errors': error,
                                    'success': False
                                })

                                self.assertEqual(solr.core_status(), 'A')
Exemplo n.º 3
0
    def test_core_status(self):
        """
        Test to get the status for a given core or all cores
        if no core is specified
        """
        error = ['solr.reload_core can only be called by "multi-core" minions']
        with patch.object(solr,
                          "_check_for_cores",
                          side_effect=[False, True, True, True]):
            with patch.object(solr,
                              "_get_none_or_value",
                              side_effect=[None, True]):
                with patch.object(solr,
                                  "_get_return_dict",
                                  return_value={"A": "a"}):
                    with patch.object(solr, "_format_url", return_value="A"):
                        with patch.object(solr,
                                          "_http_request",
                                          return_value="A"):
                            with patch.dict(
                                    solr.__opts__,
                                {"solr.cores": MagicMock(return_value="n")},
                            ):
                                self.assertIsNone(solr.core_status())
                                self.assertDictEqual(
                                    solr.core_status(),
                                    {
                                        "A": "a",
                                        "errors": error,
                                        "success": False
                                    },
                                )

                                self.assertEqual(solr.core_status(), "A")