예제 #1
0
    def create_view(self, es_client):
        """Create and return test view class instance

        Args:
            es_client (Elasticsearch): elasticsearch connection client
        Returns:
            ElasticAPIView: test view instance
        """
        view = ElasticAPIView()
        view.es_client = es_client
        view.es_model = DataDocType
        view.es_filter_backends = (ElasticSearchFilter, ElasticFieldsFilter,
                                   ElasticFieldsRangeFilter,
                                   ElasticOrderingFilter)
        return view
예제 #2
0
 def test_get_es_client(self, es_data_client):
     view = ElasticAPIView()
     view.es_client = es_data_client
     assert view.get_es_client() == es_data_client
예제 #3
0
 def test_get_es_client_with_wrong_es_client(self):
     view = ElasticAPIView()
     view.es_client = str
     with pytest.raises(ValueError):
         view.get_es_client()