Exemplo n.º 1
0
    def test_ping(self):
        """
        Test to check on solr, makes sure solr can talk to the
        indexes.
        """
        with patch.object(solr, "_get_return_dict", return_value={"A": "a"}):
            with patch.object(solr, "_get_none_or_value", side_effect=[None, True]):
                with patch.object(solr, "_check_for_cores", side_effect=[True, False]):

                    tempdict = {
                        "success": "success",
                        "errors": "errors",
                        "warnings": "warnings",
                        "data": {"lucene": {"solr-spec-version": 1}},
                    }

                    with patch.dict(
                        solr.__opts__, {"solr.cores": MagicMock(return_value=["A"])}
                    ):
                        with patch.object(
                            solr, "_get_admin_info", return_value=tempdict
                        ):
                            with patch.object(
                                solr, "_update_return_dict", return_value={"A": "a"}
                            ):
                                self.assertDictEqual(solr.ping(), {"A": "a"})

                    with patch.object(solr, "_get_admin_info", return_value="A"):
                        self.assertEqual(solr.ping(), "A")
Exemplo n.º 2
0
    def test_ping(self):
        '''
        Test to check on solr, makes sure solr can talk to the
        indexes.
        '''
        with patch.object(solr, '_get_return_dict', return_value={'A': 'a'}):
            with patch.object(solr, '_get_none_or_value',
                              side_effect=[None, True]):
                with patch.object(solr, '_check_for_cores',
                                  side_effect=[True, False]):

                    tempdict = {'success': 'success', 'errors': 'errors',
                                'warnings': 'warnings',
                                'data': {'lucene': {'solr-spec-version': 1}}}

                    with patch.dict(solr.__opts__,
                                    {'solr.cores':
                                     MagicMock(return_value=['A'])}):
                        with patch.object(solr, '_get_admin_info',
                                          return_value=tempdict):
                            with patch.object(solr, '_update_return_dict',
                                              return_value={'A': 'a'}):
                                self.assertDictEqual(solr.ping(), {'A': 'a'})

                    with patch.object(solr, '_get_admin_info',
                                            return_value='A'):
                        self.assertEqual(solr.ping(), 'A')
Exemplo n.º 3
0
    def test_ping(self):
        '''
        Test to check on solr, makes sure solr can talk to the
        indexes.
        '''
        with patch.object(solr, '_get_return_dict', return_value={'A': 'a'}):
            with patch.object(solr, '_get_none_or_value',
                              side_effect=[None, True]):
                with patch.object(solr, '_check_for_cores',
                                  side_effect=[True, False]):

                    tempdict = {'success': 'success', 'errors': 'errors',
                                'warnings': 'warnings',
                                'data': {'lucene': {'solr-spec-version': 1}}}

                    with patch.dict(solr.__opts__,
                                    {'solr.cores':
                                     MagicMock(return_value=['A'])}):
                        with patch.object(solr, '_get_admin_info',
                                          return_value=tempdict):
                            with patch.object(solr, '_update_return_dict',
                                              return_value={'A': 'a'}):
                                self.assertDictEqual(solr.ping(), {'A': 'a'})

                    with patch.object(solr, '_get_admin_info',
                                      return_value='A'):
                        self.assertEqual(solr.ping(), 'A')