I have a task in which i have a csv file having some sample data. The task is to convert the data inside the csv file into other formats like JSON, HTML, YAML etc after applying some data validation rules.
Now i am also supposed to write some unit tests for this in pytest or the unittest module in Python.
My question is how do i actually write the unit tests for this since i am converting them to different JSON/HTML files ? Should i prepare some sample files and then do a comparison with them in my unit tests.
I think only the data validation part in the task can be tested using unittest and not the creation of files in different formats right ?
Any ideas would be immensely helpful.
Thanks in advance.
You should do functional tests, so testing the whole pipeline from a csv file to the end result, but unit tests is about checking that individual steps work.
So for instance, can you read a csv file properly? Does it fail as expected when you don't provide a csv file? Are you able to check each validation unit? Are they failing when they should? Are they passing valid data? 
And of course, the result must be tested as well. Starting from a known internal representation, is the resulting json valid? Does it contain all the required data? Same for yaml, HTML. You should not test the formatting, but really what was output and if it's correct. 
You should always test that valid data passes and that incorrect doesn't at each step of your work flow.
Writing unit tests in Python