Exemplo n.º 1
0
 def test_clean_search_input_1(self):
     '''
     User enters normal search input. Make sure it is passed correctly.
     '''
     search_input = 'ABCEEOQ'
     search_input = utils.clean_search_input(search_input)
     self.assertEqual(search_input, 'ABCEEOQ')
Exemplo n.º 2
0
 def test_clean_search_input_6(self):
     '''
     Allow 8 characters to be returned. Testing n parameter
     '''
     search_input = 'ABCEEOQZ'
     search_input = utils.clean_search_input(search_input, n=8)
     self.assertEqual(search_input, 'ABCEEOQZ')
Exemplo n.º 3
0
 def test_clean_search_input_6(self):
     '''
     Allow 8 characters to be returned. Testing n parameter
     '''
     search_input = 'ABCEEOQZ'
     search_input = utils.clean_search_input(search_input, n=8)
     self.assertEqual(search_input, 'ABCEEOQZ')
Exemplo n.º 4
0
 def test_clean_search_input_1(self):
     '''
     User enters normal search input. Make sure it is passed correctly.
     '''
     search_input = 'ABCEEOQ'
     search_input = utils.clean_search_input(search_input)
     self.assertEqual(search_input, 'ABCEEOQ')
Exemplo n.º 5
0
 def test_clean_search_input_5(self):
     '''
     Feeble attempt at SQL injection.
     Should be accounted for anyway, but also check here for redunancy.
     '''
     search_input = '\'\' limit 1;select * from top_secret_data;'
     search_input = utils.clean_search_input(search_input)
     self.assertEqual(search_input, 'EIILMST')
Exemplo n.º 6
0
 def test_clean_search_input_4(self):
     '''
     All kinds of random shit, upper and lower-case, disallowed characters, _'s, etc.
     Make sure, holisitcally, that function trims this down to what you want.
     '''
     search_input = '3fw $GRGR _*effwec n'
     search_input = utils.clean_search_input(search_input)
     self.assertEqual(search_input, 'FGGRRW_')
Exemplo n.º 7
0
 def test_clean_search_input_3(self):
     '''
     Lower case letters in search input.
     They should be capitalized, and remain in final result
     '''
     search_input = 'abceeoq'
     search_input = utils.clean_search_input(search_input)
     self.assertEqual(search_input, 'ABCEEOQ')
Exemplo n.º 8
0
 def test_clean_search_input_2(self):
     '''
     Search input is too long (n's default is 7 chars)
     Check that function returns truncated version
     '''
     search_input = 'ABCEEOQXXX'
     search_input = utils.clean_search_input(search_input)
     self.assertEqual(search_input, 'ABCEEOQ')
Exemplo n.º 9
0
 def test_clean_search_input_5(self):
     '''
     Feeble attempt at SQL injection.
     Should be accounted for anyway, but also check here for redunancy.
     '''
     search_input = '\'\' limit 1;select * from top_secret_data;'
     search_input = utils.clean_search_input(search_input)
     self.assertEqual(search_input, 'EIILMST')
Exemplo n.º 10
0
 def test_clean_search_input_4(self):
     '''
     All kinds of random shit, upper and lower-case, disallowed characters, _'s, etc.
     Make sure, holisitcally, that function trims this down to what you want.
     '''
     search_input = '3fw $GRGR _*effwec n'
     search_input = utils.clean_search_input(search_input)
     self.assertEqual(search_input, 'FGGRRW_')
Exemplo n.º 11
0
 def test_clean_search_input_3(self):
     '''
     Lower case letters in search input.
     They should be capitalized, and remain in final result
     '''
     search_input = 'abceeoq'
     search_input = utils.clean_search_input(search_input)
     self.assertEqual(search_input, 'ABCEEOQ')
Exemplo n.º 12
0
 def test_clean_search_input_2(self):
     '''
     Search input is too long (n's default is 7 chars)
     Check that function returns truncated version
     '''
     search_input = 'ABCEEOQXXX'
     search_input = utils.clean_search_input(search_input)
     self.assertEqual(search_input, 'ABCEEOQ')
Exemplo n.º 13
0
def get_matching_words(request):
    search_input = request.GET.get('search_input', '')
    word_matches = None
    if search_input != '':
        search_input = utils.clean_search_input(search_input)
        word_matches = utils.get_matching_words(search_input)
    search_input_form = forms.SearchInputForm()
    context = {
        'search_input': search_input,
        'word_matches': word_matches,
        'search_input_form': search_input_form,
        }
    return render(request, 'trainer/get_matching_words.html', context)