Skip to content

Commit

Permalink
Written tests for searching torrents/channels
Browse files Browse the repository at this point in the history
  • Loading branch information
devos50 committed Jul 12, 2016
1 parent acfb204 commit 6123137
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
11 changes: 11 additions & 0 deletions Tribler/Test/Core/test_sqlitecachedbhandler_channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,14 @@ def test_on_remove_playlist_torrent(self):
self.assertEqual(len(self.cdb.getTorrentsFromPlaylist(1, ['Torrent.torrent_id'])), 1)
self.cdb.on_remove_playlist_torrent(1, 1, str2bin('AA8cTG7ZuPsyblbRE7CyxsrKUCg='), False)
self.assertEqual(len(self.cdb.getTorrentsFromPlaylist(1, ['Torrent.torrent_id'])), 0)

def test_search_local_channels(self):
"""
Testing whether the right results are returned when searching in the local database for channels
"""
results = self.cdb.search_in_local_channels_db("fancy")
self.assertEqual(len(results), 2)
self.assertNotEqual(results[0][-1], 0.0) # Relevance score of result should not be zero

results = self.cdb.search_in_local_channels_db("fdajlkerhui")
self.assertEqual(len(results), 0)
13 changes: 12 additions & 1 deletion Tribler/Test/Core/test_sqlitecachedbhandler_torrents.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def test_freeSpace(self):

@blocking_call_on_reactor_thread
def test_get_search_suggestions(self):
self.assertEqual(self.tdb.getSearchSuggestion(["content", "cont"]), ["Content 1"])
self.assertEqual(self.tdb.getSearchSuggestion(["content", "cont"]), ["content 1"])

@blocking_call_on_reactor_thread
def test_get_autocomplete_terms(self):
Expand Down Expand Up @@ -283,3 +283,14 @@ def test_search_names_sort(self):
results = self.tdb.searchNames(['content'], keys=columns)
self.assertEqual(len(results), 4848)
self.assertEqual(results[0][3], 493785)

@blocking_call_on_reactor_thread
def test_search_local_torrents(self):
"""
Test the search procedure in the local database when searching for torrents
"""
results = self.tdb.search_in_local_torrents_db('content', ['infohash'])
self.assertEqual(len(results), 4848)
self.assertNotEqual(results[0][-1], 0.0) # Relevance score of result should not be zero
results = self.tdb.search_in_local_torrents_db('fdsafasfds', ['infohash'])
self.assertEqual(len(results), 0)
Binary file modified Tribler/Test/data/bak_new_tribler.sdb.tar.gz
Binary file not shown.

0 comments on commit 6123137

Please sign in to comment.