Closed ZacharyBohn closed 3 months ago
Hi Zachary,
Great job on making significant progress with the URL shortener project! Here are some detailed comments and suggestions to help improve your code further:
generate_short_url
function. They help in understanding the purpose and functionality of the code. Keep using these. service/url_shortener.py
Functionality:
Error Handling:
InvalidUrlException
is appropriately raised for invalid URLs. Consider providing a message within the exception to make debugging easier.
raise InvalidUrlException("The provided URL is not valid.")
Validation Regex:
Hash Function:
hash_url
function is straightforward. Consider adding a check to ensure output_length
is within reasonable bounds to avoid unexpected behavior.tests/test_url_shortener.py
Consider adding tests for different lengths of the shortened URL to verify the flexibility of your hashing function.
assertEqual
instead of assertEquals
(which is deprecated) is recommended.
self.assertEqual(short_url1, short_url2)
return
statements at the end of your test functions are unnecessary and can be omitted.tests.py
main.py
Great progress so far, Zachary! Keep up the good work and let me know if you have any questions or need further assistance.
Return Statements in Tests:
The return statements at the end of your test functions are unnecessary and can be omitted.
I find that since Python does not use curly braces to delimit function scopes, that a dangling return statement makes it a bit more readable. Though I do understand that this is not a common practice.
Description
Todo