first of all thanks for your work on Luigi! Looks like a very useful framework.
I'm wondering what is the best way to unit test Tasks. Given the design choice to embed dependencies in the code of each Task, I assume constructor based dependency injection is not an option. I found the luigi.mock module, and Erik's post from 3 years ago [1] about patching output() and requires() using mock.patch.
Is this still the recommended approach? And can anyone point me to a real life example to help me wrap my head around how the different pieces work together?
Sorry if I'm asking an obvious question. Couldn't find much information on this in the docs or list archives.
Thanks,
Stephan
[1] https://groups.google.com/forum/#!msg/luigi-user/lYjunyRX4rY/GdbUVJGvkksJ
> To unsubscribe from this group and stop receiving emails from it, send an email to luigi-user+unsubscribe@googlegroups.com.
>> > an email to luigi-user+unsubscribe@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Luigi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to luigi-user+unsubscribe@googlegroups.com.
We extend the task under test and can then check the output without the need for path parameters. A simple example:
class TestCombine(CombineCSVFiles):
def requires(self):
return [TestResourceTask(filename="csv_combine_1.csv"),TestResourceTask("csv_combine_2.csv")]
def output(self):
return MockTarget("output")
TestResourceTask is just a helper task for reading test resources off disk.