Esempio n. 1
0
    def test_search(self):
        """ Verify the method returns query results from the data store. """
        prefix = 'test'
        query = {
            'query': {
                'bool': {
                    'must': [
                        {
                            'wildcard': {
                                'course.name': prefix + '*'
                            }
                        }
                    ]
                }
            }
        }
        courses = []
        for i in range(3):
            courses.append(CourseFactory.create(name=prefix + str(i)))
            CourseFactory.create()

        courses.sort(key=lambda course: course.id.lower())
        self.refresh_index()

        expected = {
            'limit': 10,
            'offset': 0,
            'total': len(courses),
            'results': courses,
        }
        self.assertEqual(Course.search(query), expected)
Esempio n. 2
0
    def test_search(self):
        """ Verify the method returns query results from the data store. """
        prefix = 'test'
        query = {
            'query': {
                'bool': {
                    'must': [{
                        'wildcard': {
                            'course.name': prefix + '*'
                        }
                    }]
                }
            }
        }
        courses = []
        for i in range(3):
            courses.append(CourseFactory.create(name=prefix + str(i)))
            CourseFactory.create()

        courses.sort(key=lambda course: course.id.lower())
        self.refresh_index()

        expected = {
            'limit': 10,
            'offset': 0,
            'total': len(courses),
            'results': courses,
        }
        self.assertEqual(Course.search(query), expected)