示例#1
0
    def test_get_settings(self):
        context = ExecutionContext(user=self.plugin_info['1']['user'],
                                   plugin=self.plugin_info['1']['plugin'])
        manager = PluginManager(context)

        # Should return the response from the view.
        response = manager.get_settings(
            self.plugin_info['1']['plugin'].hashkey)
        self.assertTrue(isinstance(response, dict))
示例#2
0
    def test_get_route(self):
        context = ExecutionContext(user=self.plugin_info['1']['user'],
                                   plugin=self.plugin_info['1']['plugin'])
        login_user(self.plugin_info['1']['user'])
        manager = PluginManager(context)
        response = manager.call_route_handler(
            self.plugin_info['1']['views']['test'].hashkey, "get", {}, None)
        logout_user()

        self.assertEqual(response.status_code, 200)
示例#3
0
    def test_404_plugin(self):

        simple = {'status': '404'}
        plugin_manager = PluginManager()
        plugin_manager.call_method(method='process', args=simple)

        for item in plugin_manager.plugins:
            if isinstance(item, CountHTTP404):
                self.assertEquals(1, item.counter_total)
                self.assertEquals(1, item.counter_404)
示例#4
0
    def test_plugin(self):
        # test the combined example from apache.org
        #self.combined_log_entry = '127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326 "http://www.example.com/start.html" "Mozilla/4.08 [en] (Win98; I ;Nav)"'
        simple = {'status': '200'}
        plugin_manager = PluginManager()
        plugin_manager.call_method(method='process', args=simple)

        for item in plugin_manager.plugins:
            if isinstance(item, CountHTTP200):
                self.assertEquals(1, item.counter_total)
                self.assertEquals(1, item.counter_200)
示例#5
0
    def test_add_remove(self):
        user = UserFactory()
        context = ExecutionContext(user=user,
                                   plugin=self.plugin_info['1']['plugin'])
        manager = PluginManager(context)

        # This should be 1 because we have just added a plugin for the user.
        plugin_key = self.plugin_info['1']['plugin'].hashkey
        manager.add(plugin_key)
        self.assertEqual(len(user.plugins), 1)

        manager.remove(plugin_key)
        self.assertEqual(len(user.plugins), 0)
示例#6
0
def main():
    plugin_manager = PluginManager()
    log_generator = LogLineGenerator()
    for log_line in log_generator.get_loglines():
        plugin_manager.call_method('process', args=log_line)
    plugin_manager.call_method('report')