Open ndanielsen opened 9 years ago
For the json_engine:
Bonus, can you use the setup and teardown to create and delete test json files for testing the engine functionalities?
examples of classes for a recommendation engine and flask here:
i created the unit tests for the analyze/gender tests. This was super helpful because I found that the code I had written earlier was not actually removing punctuation, so it wasn't correctly counting all the gendered words. I wasn't able to do a test for the title because the Gutenberg site updated their security and I can't scarpe it anymore, but I did run separate tests just to make sure I am able to correctly pass book numbers to the json engine to get the json dicts.
I haven't written a class yet and that is the next thing I want to tackle.
During our session, we can briefly review how to write unit tests. Here's the python docs page for it : https://docs.python.org/2/library/unittest.html
Create a file called tests.py
Using your test data in for 'dr jenkyll' and frankenstein, create several tests that show that you are accurately extracting data from the html files.
Test 1: That you can accurately extract the title from an html file assertequals(title, "The Project Gutenberg E-text of Frankenstein, by Mary Wollstonecraft (Godwin) Shelley")
Other tests: Using a shorter amount of text that you can manually verify, write tests for all your functions in analyze/gender.
Extra credit:
Can you figure out how to create a BaseClass for unittests with a setup function so you don't have to repeat yourself and violate DRY.
Read up on creating unit tests, and install 'nose' and read up on it's use. http://docs.python-guide.org/en/latest/writing/tests/
Watch this video for a great rationale: https://www.youtube.com/watch?v=FxSsnHeWQBY