-
-
Notifications
You must be signed in to change notification settings - Fork 22
add tests for tag slugging #121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
1. Corrected the expected results for the failing tags on lines 32-35 2. Changed the single-letter variable name and iterator name lines 41 - 44 (more PEP-8 compliant that way)
Codecov Report
@@ Coverage Diff @@
## master #121 +/- ##
==========================================
+ Coverage 76.02% 79.23% +3.21%
==========================================
Files 28 25 -3
Lines 392 342 -50
==========================================
- Hits 298 271 -27
+ Misses 94 71 -23
Continue to review full report at Codecov.
|
Going to link issue #72 here as well, since this PR does address some of those scenarios. |
@lpatmo - since I contributed to this as well, I'd feel better if you gave it a quick review. 😄 Thanks! |
Just took a look -- thank you for writing this and it looks good, @chris48s! Feel free to merge in! |
Its been a while since I looked at this, but I don't think this is finished. I'd like to at least add a validator to throw That said, there are still some open questions here: #121 (comment) I'd like to understand more about the use-case for slugs in this application first, but if you take #123 at face value, c320bc7 essentially formalises a bug, doesn't it? i.e: the tests pass because the code doesn't do what you want it to. That's the opposite of what you want from a test. Either way, lets understand what you're doing with the slugs first.. |
I refreshed the page and just saw your new comment! I took a stab at answering the questions in #121 (comment) just now. :) |
++ |
Yup - technically speaking, it does. So - we can re-write those tests to fail .. but then we need to decide what the expected behavior is...and write some slugification code (or iri_to_uri code) accordingly...or live with 4 continuously failing tests (which seems silly). We could also omit them altogether until we decide. |
- prevent generation of tag with non-unique slug - prevent generation of tag with name containing only invalid characters
OK then. Based on the further discussion, it seems like one of the things you want from slugging is to enforce uniqueness i.e: you shouldn't be able to create >>> tag = CustomTag(name='javascript')
>>> tag.save()
>>> tag.slug
'javascript'
>>> tag = CustomTag(name='Javascript')
>>> tag.save()
>>> tag.slug
'javascript_1'
>>> tag = CustomTag(name='JavaScript')
>>> tag.save()
>>> tag.slug
'javascript_2' That seems like it is not what you want, so in cdfe87a I have changed this so that:
and I've added tests to formalise that behaviour. On balance, that seems more like what you want. This does, of course, create at least one annoying edge case to work around: >>> from django.utils.text import slugify
>>> slugify('C')
'c'
>>> slugify('C++')
'c'
>>> slugify('C#')
'c' That's what I've don so far, but it looks like there is also some further validation needed beyond this. Lets carry on that discussion in #121 (comment)
My proposed solution is 49eca65 - we move those examples to a skipped test. This means:
btw, I'm slightly confused on the |
Apologies, @chris48s - missed this in the whole comment shuffle. YES - AFAK it was a typo, (I don't think Scots Gaelic has an Eszett-type character..and Google appears to agree with me.) so let's just move |
I've marked this PR as ready for review now. There are still quite a few unanswered questions about what should/shouldn't be allowed in a tag name/slug but I don't think we've reached a conclusion that results in clearly defined changes to this PR yet. My suggestion would be we review/merge this as it stands now and revisit following further discussion in issues. It may be that loads of this stuff ends up needing to change soon, but if nothing else this PR forces us to nail down some decisions about stuff that was previously not very well defined :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to merge this in, @chris48s! 🙏
refs #98
refs #116 (comment)
build will be failing for now.. see comments