Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class SearchSystemTests(TestCase):
- def test_search_with_epmty_field(self):
- """
- search with empty field should output
- querry without any changes
- """
- #add user who "added" this data
- user = User.objects.create_user(id = 1,username = 'test', email = 'test@test.com', password = '123')
- # add new data
- data_set_1 = giveaways(login = 'first', passw = 'password', rating_lim = 0, poster_id = 1, domain = 'www.google.com')
- data_set_2 = giveaways(login = 'first', passw = 'password', rating_lim = 0, poster_id = 1, domain = 'www.yahoo.com')
- data_set_3 = giveaways(login = 'first', passw = 'password', rating_lim = 0, poster_id = 1, domain = 'www.yandex.ru')
- #save
- data_set_1.save()
- data_set_2.save()
- data_set_3.save()
- response = self.client.post('/', {'search': '', 'data_count': 1,'order_con': 0,'hide': False})
- self.assertQuerysetEqual(response.context['data_set'], ['<giveaways: www.google.com>','<giveaways: www.yahoo.com>',
- '<giveaways: www.yandex.ru>'])
- def test_search_with_no_match(self):
- """
- search with no mathes found should output
- empty querry
- """
- #add user who "added" this data
- user = User.objects.create_user(id = 1,username = 'test', email = 'test@test.com', password = '123')
- # add new data
- data_set_1 = giveaways(login = 'first', passw = 'password', rating_lim = 0, poster_id = 1, domain = 'www.google.com')
- data_set_2 = giveaways(login = 'first', passw = 'password', rating_lim = 0, poster_id = 1, domain = 'www.yahoo.com')
- data_set_3 = giveaways(login = 'first', passw = 'password', rating_lim = 0, poster_id = 1, domain = 'www.yandex.ru')
- #save
- data_set_1.save()
- data_set_2.save()
- data_set_3.save()
- response = self.client.post('/', {'search': 'asdwaads', 'data_count': 1,'order_con': 0,'hide': False})
- self.assertQuerysetEqual(response.context['data_set'], [])
- def test_search_with_one_match(self):
- """
- search with one match found should output
- querry with one elements
- """
- #add user who "added" this data
- user = User.objects.create_user(id = 1,username = 'test', email = 'test@test.com', password = '123')
- # add new data
- data_set_1 = giveaways(login = 'first', passw = 'password', rating_lim = 0, poster_id = 1, domain = 'www.google.com')
- data_set_2 = giveaways(login = 'first', passw = 'password', rating_lim = 0, poster_id = 1, domain = 'www.yahoo.com')
- data_set_3 = giveaways(login = 'first', passw = 'password', rating_lim = 0, poster_id = 1, domain = 'www.yandex.ru')
- #save
- data_set_1.save()
- data_set_2.save()
- data_set_3.save()
- response = self.client.post('/', {'search': 'dex', 'data_count': 1,'order_con': 0,'hide': False})
- self.assertQuerysetEqual(response.context['data_set'], ['<giveaways: www.yandex.ru>'])
- def test_search_with_multiple_matches(self):
- """
- search with multipl matches found should output
- querry with multiple elements
- """
- #add user who "added" this data
- user = User.objects.create_user(id = 1,username = 'test', email = 'test@test.com', password = '123')
- # add new data
- data_set_1 = giveaways(login = 'first', passw = 'password', rating_lim = 0, poster_id = 1, domain = 'www.google.com')
- data_set_2 = giveaways(login = 'first', passw = 'password', rating_lim = 0, poster_id = 1, domain = 'www.yahoo.com')
- data_set_3 = giveaways(login = 'first', passw = 'password', rating_lim = 0, poster_id = 1, domain = 'www.yandex.ru')
- #save
- data_set_1.save()
- data_set_2.save()
- data_set_3.save()
- response = self.client.post('/', {'search': 'oo', 'data_count': 1,'order_con': 0,'hide': False})
- self.assertQuerysetEqual(response.context['data_set'], ['<giveaways: www.google.com>','<giveaways: www.yahoo.com>'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement