Repository navigation
T351642: Discard canary events in Hashtags - #93
Conversation
jsnshrmn
left a comment
There was a problem hiding this comment.
does what it says on the tin; suggest sorting out ci for scripts dir tests separately, but this works for now.
| @@ -0,0 +1,18 @@ | |||
| import unittest | |||
|
|
|||
| from common import is_canary | |||
There was a problem hiding this comment.
I had to do some research, but it looks like if we add an empty __init__.py to the scripts/ directory, it will then be treated as a Python package and Django will look for the tests. However because the tests are ran from the root directory, it will think common is a top-level package when it's only part of scripts. The fix there seems to be to add a parent-relative import:
| from common import is_canary | |
| from .common import is_canary |
Then docker compose exec app python manage.py test (and CI) should run the test. I think however the other files in scripts/ need the same treatment to import locally, which doesn't look a huge change:
- collect_hashtags.py –
from common→from .common,import db→import .db - load_old_db.py –
from common→from .common
Should we go ahead and try that?
There was a problem hiding this comment.
Note again I'm not very experienced with Python so this may not be the right way to go about it. If there's any disagreement, I'm happy to defer to @jsnshrmn and sort out running the tests in a separate PR.
There was a problem hiding this comment.
The collector is started directly as python collect_hashtags.py, so Python doesn't treat it as part of a package, and from .common import ... only works inside a package so things would break if we did that :) getting the test working isn't a big change but might be worth following up with instead I think
There was a problem hiding this comment.
Agreed; let's merge for now and consider this a coverage concern for future ci work.
Discard canary events in Hashtags
Bug: T351642