-
Notifications
You must be signed in to change notification settings - Fork 3
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
Refactor: models #148
Refactor: models #148
Conversation
bd34894
to
1f06f54
Compare
Although this will have minor merge conflicts with #144, I think this can be reviewed now and spot-checked after the rebase. |
@@ -45,34 +45,43 @@ def import_users(): | |||
with open(file_path) as file: | |||
data = json.load(file)["users"] | |||
for user in data: | |||
save_users(user, data[user][0], str(data[user][1])) | |||
save_users(user, data[user][0], data[user][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.
I like how this is cleaner than the previous str()
version.
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 do think it's a little funky to pass user
and then use user
as a key for data
- not super obvious what is going on here? data
is a dict, might be clearer to iterate over data.items()
to deal with the key/value tuple.
Also this JSON file is... the oldest remnant of the old school approach from our toy. Not that important to maintain / make clearer right now, probably just drop it entirely in the future?
ALSO I've updated this section for the remote data anyway! So no worries.
We decided today that we're going to assume the CSV file always has the eligibility types in it, and not worry about filling in default types etc. |
create associative table to support a many-to-many relationship. update init-db and drop-db.
lists in CSV import files are expected to be comma-separated. if the CSV delimiter is a comma, the list should be quoted.
update sample CSV file to demonstrate
ed056d0
to
5cdb415
Compare
Done rebasing on |
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.
So this is an interesting problem, and a possible solution...
If you run the tests using the VSCode interface, they should all pass. But then immediately run them again without touching anything else - many of the tests in test_verify.py
will fail.
This is because tests in db/test_setup.py
delete the database and it isn't being recreated elsewhere; the verify tests expect it to already exist. This is probably part of what we've been talking/thinking about in #131.
An immediate resolution could be to add a call to init-db
at the very end of the test_drop_db_command
test? Simple and kind of a hack, but it would at least make all the tests idempotent (a la #103).
A possible longer term solution could be to abstract that runner.invoke(args="init-db")
as a fixture (and the drop-db
) that can be injected/used across tests?
@@ -45,34 +45,43 @@ def import_users(): | |||
with open(file_path) as file: | |||
data = json.load(file)["users"] | |||
for user in data: | |||
save_users(user, data[user][0], str(data[user][1])) | |||
save_users(user, data[user][0], data[user][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.
I do think it's a little funky to pass user
and then use user
as a key for data
- not super obvious what is going on here? data
is a dict, might be clearer to iterate over data.items()
to deal with the key/value tuple.
Also this JSON file is... the oldest remnant of the old school approach from our toy. Not that important to maintain / make clearer right now, probably just drop it entirely in the future?
ALSO I've updated this section for the remote data anyway! So no worries.
Hmm that is interesting. Good catch 🙏 |
Co-authored-by: Kegan Maher <[email protected]>
🎉 |
Closes #122
This will need to be rebased onto #144.doneThis PR splits the eligibility type out from
User
into its own model calledEligibility
. There is a many-to-many relationship between these two.user
eligibility
user_eligibility
How to view the tables like that ^^
This PR also makes a few changes (improvements?) to the expected format of CSV data import files:
data/server.csv
Before
After
or
,
. (We used to expect them as Python-style lists that would be evaluted byast.literal_eval
.),
, then the list should be surrounded by the CSV quote character (specified byCSV_QUOTCHAR
setting).ast
module import since we don't need it anymoresub
,name
pair (i.e. aUser
). I think this better matches what you might see from a SQL query result.Wrote unit tests for the
init-db
anddrop-db
commands - theinit-db
test is hard-coded to the sample data.