def search():
    if request.method == 'POST':
        filterJson = request.get_json()
        current_app.logger.info(filterJson)
        current_app.logger.info(filterJson['filter'])
        current_app.logger.info(type(filterJson['filter']))

        current_app.logger.info('getting items')
        try:
            courses = lr_service.get_courses(filterJson)
        except Exception as e:
            current_app.logger.exception(e, exc_info=True)
            raise
        current_app.logger.info('got items')
        return json.dumps(courses)

    return render_template('learningresource/search.html')
def search():
    if request.method == 'POST':
        filterJson = request.get_json()
        current_app.logger.info(filterJson)
        current_app.logger.info(filterJson['filter'])
        current_app.logger.info(type(filterJson['filter']))

        current_app.logger.info('getting items')
        try:
            courses = lr_service.get_courses(filterJson)
        except Exception as e:
            current_app.logger.exception(e, exc_info=True)
            raise
        current_app.logger.info('got items')
        return json.dumps(courses)

    return render_template('learningresource/search.html')
Exemplo n.º 3
0
 def test_get_courses__when_filtering__should_ignore_casing(self):
     actual_courses = sut_service.get_courses({'filter': 'IgiTal aWareNeS'})
     self.assertEqual(1, len(actual_courses))
     self.assertEqual("Digital awareness", actual_courses[0]['title'])
Exemplo n.º 4
0
 def test_get_courses__when_filter_contained_in_topics__should_return_those_courses(self):
     actual_courses = sut_service.get_courses({'filter': 'rship & Man'})
     self.assertEqual(1, len(actual_courses))
     self.assertEqual("Change leaders for senior management", actual_courses[0]['title'])
Exemplo n.º 5
0
 def test_get_courses__when_filter_contained_in_desc__should_return_those_courses(self):
     actual_courses = sut_service.get_courses({'filter': 'purpose of this'})
     self.assertEqual(1, len(actual_courses))
     self.assertEqual("The purpose of this e-learning", actual_courses[0]['desc'])
Exemplo n.º 6
0
 def test_get_courses__when_filter_contained_in_title__should_return_those_courses(self):
     actual_courses = sut_service.get_courses({'filter': 'with customers'})
     self.assertEqual(1, len(actual_courses))
     self.assertEqual("Communicating with customers", actual_courses[0]['title'])
Exemplo n.º 7
0
 def test_get_courses__when_filter_has_empty_value__should_return_all_courses(self):
     self.assertEqual(3, len(sut_service.get_courses({'filter': ''})))
Exemplo n.º 8
0
 def test_get_courses__when_filter_has_no_keys__should_return_all_courses(self):
     self.assertEqual(3, len(sut_service.get_courses({})))
Exemplo n.º 9
0
 def test_get_courses__when_filter_is_None__should_return_all_courses(self):
     self.assertEqual(3, len(sut_service.get_courses(None)))