示例#1
0
 def test__prepare_search_filter(self, input, expected):
     query = 'food water'
     a = ActivityQuerySet()
     filter = a._prepare_search_filter(['descriptions', 'titles'], query)
     #should return a list of django filters, followed by the query used on the filter
     assert filter == [('activitysearchdata__search_description__search',
                        a._create_full_text_query(query)),
                       ('activitysearchdata__search_title__search',
                        a._create_full_text_query(query))]
示例#2
0
	def test__prepare_search_filter__wrong_field(self):
		with pytest.raises(Exception) as ex:
			'''should raise an exception when an invalid search_field (in this case 'spam') is used'''
			a = ActivityQuerySet()
			a._prepare_search_filter(['descriptions', 'spam'], 'food water')
		assert 'unsupported search_field' in str(ex.value)
示例#3
0
	def test__prepare_search_filter(self, input, expected):
		query = 'food water'
		a = ActivityQuerySet()
		filter = a._prepare_search_filter(['descriptions', 'titles'], query)
		#should return a list of django filters, followed by the query used on the filter
		assert filter == [('activitysearchdata__search_description__search', a._create_full_text_query(query)), ('activitysearchdata__search_title__search', a._create_full_text_query(query))]
示例#4
0
 def test__prepare_search_filter__wrong_field(self):
     with pytest.raises(Exception) as ex:
         '''should raise an exception when an invalid search_field (in this case 'spam') is used'''
         a = ActivityQuerySet()
         a._prepare_search_filter(['descriptions', 'spam'], 'food water')
     assert 'unsupported search_field' in str(ex.value)
示例#5
0
 def test___create_full_text_query(self, input, expected):
     assert ActivityQuerySet()._create_full_text_query(input) == expected