<s> from tests . testing_framework . base_test_cases import BaseTestCase <EOL> from hamcrest import * <EOL> from flexmock import flexmock <EOL> from tests . testing_framework . db . environments import DBEnvironmentBuilder <EOL> from framework . db . url_manager import URLManager <EOL> class URLManagerTests ( BaseTestCase ) : <EOL> def before ( self ) : <EOL> environment_builder = DBEnvironmentBuilder ( ) <EOL> environment_builder . _create_core_mock ( ) <EOL> self . core_mock = environment_builder . core_mock <EOL> self . url_manager = URLManager ( self . core_mock ) <EOL> def test_IsFileURL ( self ) : <EOL> file_url = "<STR_LIT>" <EOL> non_file_url = "<STR_LIT>" <EOL> assert_that ( self . url_manager . IsFileURL ( file_url ) ) <EOL> assert_that ( self . url_manager . IsFileURL ( non_file_url ) , is_ ( False ) ) <EOL> def test_IsImageURL ( self ) : <EOL> image_url = "<STR_LIT>" <EOL> non_image_url = "<STR_LIT>" <EOL> assert_that ( self . url_manager . IsImageURL ( image_url ) ) <EOL> assert_that ( self . url_manager . IsImageURL ( non_image_url ) , is_ ( False ) ) <EOL> def test_GetURLsToVisit_filters_image_urls ( self ) : <EOL> url_list = [ "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" ] <EOL> assert_that ( self . url_manager . GetURLsToVisit ( url_list ) , has_length ( equal_to ( <NUM_LIT:3> ) ) ) <EOL> def test_IsURL ( self ) : <EOL> http = "<STR_LIT>" <EOL> ftp = "<STR_LIT>" <EOL> non_url = "<STR_LIT>" <EOL> assert_that ( self . url_manager . IsURL ( http ) ) <EOL> assert_that ( self . url_manager . IsURL ( ftp ) ) <EOL> assert_that ( self . url_manager . IsURL ( non_url ) , is_ ( False ) ) <EOL> def test_AddURLToDB_should_call_the_DB_instance_to_perform_the_work ( self ) : <EOL> urls = [ "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" ] <EOL> self . core_mock . IsInScopeURL = lambda url : url != "<STR_LIT>" <EOL> self . core_mock . DB = flexmock ( ) <EOL> self . core_mock . DB . DBHandler = flexmock ( ) <EOL> self . core_mock . DB . should_receive ( "<STR_LIT>" ) . times ( <NUM_LIT:5> ) <EOL> flexmock ( self . url_manager ) <EOL> self . url_manager . should_receive ( "<STR_LIT>" ) . and_return ( False ) <EOL> for url in urls : <EOL> self . url_manager . AddURL ( url ) </s>
