Beispiel #1
0
    def test_basic_search(self):
        data = {'text': 'Jonathan'}
        self.search.set_type(Search.TYPE_BASIC)

        #Name
        self.search.set_params(data)
        result = self.search.run()
        self.assertEquals(len(result), 2)

        #Not found
        self.search = Search()
        data = {'text': 'cualquiera'}
        self.search.set_params(data)
        result = self.search.run()
        self.assertEquals(len(result), 0)

        #Lastname
        self.search = Search()
        data = {'text': 'de la cruz'}
        self.search.set_params(data)
        result = self.search.run()
        self.assertEquals(len(result), 1)

        #Number
        self.search = Search()
        data = {'text': '96372543756'}
        self.search.set_params(data)
        result = self.search.run()
        self.assertEquals(len(result), 1)

        #Name and LastName
        self.search = Search()
        data = {'text': 'Jonathan perez'}
        self.search.set_params(data)
        result = self.search.run()
        self.assertEquals(len(result), 2)

        #ExactName and LastName
        self.search = Search()
        data = {'text': 'Jonathan perez'}
        self.search.set_mode(Search.MODE_SENSITIVE)
        self.search.set_params(data)
        result = self.search.run()
        self.assertEquals(len(result), 1)

        #ExactName and LastName
        self.search = Search()
        data = {'text': '96372543756 perez'}
        self.search.set_mode(Search.MODE_SENSITIVE)
        self.search.set_params(data)
        result = self.search.run()
        self.assertEquals(len(result), 0)
Beispiel #2
0
    def post(self, request, *args, **kwargs):
        data = {}
        self.set_attributes()

        search = Search()

        #Default: Insensitive
        if self._mode in 'true':
            search.set_mode(Search.MODE_SENSITIVE)

        #Default Simple
        if self._type == str(Search.TYPE_ADVANCE):
            # if self._order is not None:
            search.set_order_by(self._order)
            search.set_type(Search.TYPE_ADVANCE)
            data.update({'features': self._features})
            data.update({'advance': self._advance})
        else:
            search.set_paginate(self._paginate)
            data.update({'text': self._text})
        search.set_params(data)
        result = search.run()
        result = list(result)
        return self.render_json_response(result)
Beispiel #3
0
 def setUp(self):
     self.search = Search()
     self.insert_data_helper = InsertDataHelper()
     self.insert_test_data()