Add auto-generate dates for cloned graphics with slug without a date
Closed this issue · 1 comments
If you run the fab clone_graphic:SLUG,NEW-SLUG
command with a NEW-SLUG
without a date, it doesn't validate and return the NEW-SLUG
with that day's date. Since we've implemented this validation in the fab create_graphic
command and fab clone_graphic:SLUG
command, it's worth keeping it consistent and adding the validation in this case as well.
This looks like a one-line fix, but testing whether this fix works or not is somewhat "expensive". At the very least, it will result in a directory that you need to cleanup in your local version of the graphics repo and a Google Spreadsheet that needs to be deleted.
This seems like a good opportunity to add some tests to this project and to learn about unit testing and mocking.
We should use pytest to write a test for the failing behavior for clone_graphic
being sure to mock all the external APIs so we don't actually create files on the filesystem or Google Spreadsheets.
Next steps:
- Check out and step through the getting started section of the pytest docs
- Skim this article to get a better understanding of unit testing concepts. The examples use a different testing framework than the one we'll use, but it's still helpful.
- Read this article on using Python's
mock
package to avoid system calls. We'll be using mock to avoid actually calling things that alter the system or communicate with remote APIs.