mirror of
https://github.com/internetarchive/warcprox.git
synced 2025-01-18 13:22:09 +01:00
Merge branch 'wip-postfetch-chain' into qa
* wip-postfetch-chain: fix plugin loading and add a rudimentary test case
This commit is contained in:
commit
d94715972d
@ -1395,6 +1395,23 @@ def test_controller_with_defaults():
|
|||||||
assert not wwt.writer_pool.default_warc_writer.record_builder.base32
|
assert not wwt.writer_pool.default_warc_writer.record_builder.base32
|
||||||
assert wwt.writer_pool.default_warc_writer.record_builder.digest_algorithm == 'sha1'
|
assert wwt.writer_pool.default_warc_writer.record_builder.digest_algorithm == 'sha1'
|
||||||
|
|
||||||
|
def test_load_plugin():
|
||||||
|
options = warcprox.Options()
|
||||||
|
options.plugins = ['warcprox.stats.RunningStats']
|
||||||
|
controller = warcprox.controller.WarcproxController(options)
|
||||||
|
assert isinstance(
|
||||||
|
controller._postfetch_chain[-1],
|
||||||
|
warcprox.ListenerPostfetchProcessor)
|
||||||
|
assert isinstance(
|
||||||
|
controller._postfetch_chain[-1].listener,
|
||||||
|
warcprox.stats.RunningStats)
|
||||||
|
assert isinstance(
|
||||||
|
controller._postfetch_chain[-2],
|
||||||
|
warcprox.ListenerPostfetchProcessor)
|
||||||
|
assert isinstance(
|
||||||
|
controller._postfetch_chain[-2].listener,
|
||||||
|
warcprox.stats.RunningStats)
|
||||||
|
|
||||||
def test_choose_a_port_for_me(warcprox_):
|
def test_choose_a_port_for_me(warcprox_):
|
||||||
options = warcprox.Options()
|
options = warcprox.Options()
|
||||||
options.port = 0
|
options.port = 0
|
||||||
|
@ -97,7 +97,7 @@ class Factory:
|
|||||||
(module_name, class_name) = qualname.rsplit('.', 1)
|
(module_name, class_name) = qualname.rsplit('.', 1)
|
||||||
module_ = importlib.import_module(module_name)
|
module_ = importlib.import_module(module_name)
|
||||||
class_ = getattr(module_, class_name)
|
class_ = getattr(module_, class_name)
|
||||||
listener = class_()
|
plugin = class_()
|
||||||
plugin.notify # make sure it has this method
|
plugin.notify # make sure it has this method
|
||||||
return plugin
|
return plugin
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user