Exemple #1
0
 def test_should_execute_crawler_successfully_posting_to_service(self):
     """
     
     """
     try:
         Executor('tests/dependecies.json', 'tests/executor_config.json').execute()
         pass
     except Exception as ex:
         self.assertTrue(False)
         pass 
     pass
Exemple #2
0
 def test_should_raise_exception_for_missing_dependencies(self):
     """
     Should raise an exception for missing dependencies
     """
     try:
         Executor('tests/dependecies_missing.json', 'tests/executor_config.json').execute()
         pass
     except Exception as ex:
         self.assertTrue(str(ex).__contains__('is required. This crawler cannot run'))
         pass 
     pass
Exemple #3
0
 def test_should_raise_exception_for_none_crawler_result_obj(self):
     """
     
     """
     try:
         Executor('tests/dependecies_none_crawler_result_obj.json', 'tests/executor_config.json').execute()
         pass
     except Exception as ex:
         self.assertTrue(str(ex).__eq__('Crawling result cannot be null'))
         pass 
     pass
Exemple #4
0
 def test_should_raise_exception_for_missing_crawling_args(self):
     """
     Should raise exception given a missing "Crawling Args" parameter (empty or none)
     """
     try:
         Executor('tests/dependecies_configuration_missing_param.json', 'crawling_args').execute()
         pass
     except Exception as ex:
         self.assertTrue(str(ex).__eq__('The param "crawler_args" must be provided'))
         pass 
     pass
Exemple #5
0
 def test_should_raise_exception_for_missing_msg_queue_target_topic(self):
     """
     Should raise exception given a missing "Target Topic" parameter (empty or none)
     """
     try:
         Executor('tests/dependecies_configuration_missing_param.json', 'msg_queue_target_topic').execute()
         pass
     except Exception as ex:
         self.assertTrue(str(ex).__eq__('The param "msg_queue_target_topic" must be provided'))
         pass 
     pass
Exemple #6
0
 def test_should_raise_exception_for_empty_dep_path_params(self):
     """
     Should raise an exception for empty "dependecies_file_path" param
     """
     try:
         Executor('', 'crawler_obj')
         pass
     except Exception as ex:
         self.assertTrue(
             str(ex).__eq__(
                 'Path to dependencies and configuration files is required')
         )
         pass
     pass
Exemple #7
0
 def test_should_init_class_successfully(self):
     """
     Should successfully initialize the crawler class 
     """
     try:
         Executor('tests/dependecies.json', 'tests/executor_config.json')
         pass
     except Exception as ex:
         self.assertTrue(
             str(ex).__eq__(
                 'Path to dependencies and configuration files is required')
         )
         pass
     pass
Exemple #8
0
    def test_should_raise_exception_through_custom_class(self):
        """
        
        """
        try:
            obj: Executor = Executor('tests/dependecies.json', 'crawler_obj')
            obj.check_concrete_obj_is_none(None, type(str).__class__.__name__)

            self.assertTrue(True)
            pass
        except AttributeError:
            self.assertTrue(True)
        except Exception:
            self.assertTrue(False)
        pass
Exemple #9
0
    def test_should_not_raise_exception(self):
        """
        
        """
        try:
            obj: Executor = Executor('tests/dependecies.json', 'crawler_obj')
            obj.check_concrete_obj_is_none('str_obj',
                                           type(str).__class__.__name__)

            self.assertTrue(True)
            pass
        except Exception as ex:
            self.assertTrue(
                str(ex).__eq__(
                    'Path to dependencies and configuration files is required')
            )
            pass
        pass