-
Notifications
You must be signed in to change notification settings - Fork 79
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
Packages/test performance #921
Conversation
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.
Looks good! I just have some formatting suggestions, but they aren't blockers.
OpenOversight/tests/conftest.py
Outdated
DEPARTMENT_TWO_NAME = "Chicago Police Department" | ||
DEPARTMENT_EMPTY_NAME = "Empty Police Department" |
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.
🔬 I think DEPARTMENT_NAME_XXXX
makes more sense as a naming motif.
DEPARTMENT_NAME
-> DEPARTMENT_NAME_SPRINGFIELD
DEPARTMENT_TWO_NAME
-> DEPARTMENT_NAME_CHICAGO
DEPARTMENT_EMPTY_NAME
-> DEPARTMENT_NAME_EMPTY
.
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.
Changed it slightly, hopefully make it a little more sense. But I want to make it clearer which department is considered the default one.
OpenOversight/tests/conftest.py
Outdated
DEPARTMENT_TWO_NAME = "Chicago Police Department" | ||
DEPARTMENT_EMPTY_NAME = "Empty Police Department" |
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.
When I see "empty" in the name, I presume it's an empty string.
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.
Good point. Changed it to DEPARTMENT_WITHOUT_OFFICERS
.
OpenOversight/tests/conftest.py
Outdated
@@ -310,15 +339,18 @@ def add_mockdata(session): | |||
|
|||
test_images = [ | |||
models.Image( | |||
filepath="/static/images/test_cop{}.png".format(x + 1), department_id=1 | |||
filepath="/static/images/test_cop{}.png".format(x + 1), |
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.
🔬 An f-string feels like a more intuitive way to write this, imo.
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.
Strongly agree, this is from old code. Changed this one. And maybe we can use https://github.com/ikamensh/flynt or something next to get rid of all of the .format
.
OpenOversight/tests/conftest.py
Outdated
for officer in officers_dept2[ | ||
: math.ceil(len(officers_dept2) * assignment_ratio) | ||
] |
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.
🔬 The syntax here doesn't feel incredibly intuitive.
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.
Tried to make it a little better, by extracting "the math" to a variable and adding a comment.
OpenOversight/tests/conftest.py
Outdated
DEPARTMENT_NAME = "Springfield Police Department" | ||
DEPARTMENT_TWO_NAME = "Chicago Police Department" | ||
DEPARTMENT_EMPTY_NAME = "Empty Police Department" |
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.
Since these are paired to specific short names, I think it may be valuable to put them in a dictionary.
DEPARTMENT_KEY_SPD = "SPD"
DEPARTMENT_KEY_CPD = "CPD"
DEPARTMENT_KEY_EPD = "EPD"
DEPARTMENTS = {
DEPARTMENT_KEY_SPD: "Springfield Police Department",
DEPARTMENT_KEY_CPD: "Empty Police Department",
DEPARTMENT_KEY_EPD: "Chicago Police Department"
}
You can use the key as the short name (lower or upper case, whateva) and the value as the long name.
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.
On second thought, tuples would work as well.
DEPARTMENT_SPD = ("SPD", "Springfield Police Department")
DEPARTMENT_CPD = ("CPD", "Chicago Police Department")
DEPARTMENT_EPD = ("EPD", "Empty Police Department")
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.
The department short name does not seem to matter much for tests (they are not used anywhere other than the initial creation) so I decided against giving each their own variable.
* Make sure adding mockdata is only run once. * Fix tests.
* Make sure adding mockdata is only run once. * Fix tests.
* Make sure adding mockdata is only run once. * Fix tests.
* Make sure adding mockdata is only run once. * Fix tests.
Status
Ready for review
Description of Changes
Changes proposed in this pull request:
Notes for Deployment
Changes tests only
Tests and linting
I have rebased my changes on current
develop
pytests pass in the development environment on my local machine
pre-commit
checks pass