Skip to content
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

Added admin FFQ code lookup #555

Merged
merged 6 commits into from
Dec 13, 2023

Conversation

colts661
Copy link
Contributor

No description provided.

"RETURNING interested_user_id"
)
iu_ids = [tup[0] for tup in cur.fetchall()]
t.commit()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can these state changes be rolled back either in tearDown or can the test be fully executed w/o commiting the transaction?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was hesitant to do so because:

  1. These operations are naive and does not conform to normal workflow such as when an ftp/ffq code will be created but directly inserting information related to this query. Running other operations will probably trigger lots of logic problems;
  2. Some tests were in-between the insertions for convenience, but I could reformat them to not be affected by one insertion;
  3. I tried to contain all insertion and deletion in the same test function so that running that function won't affect other workflows

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's standard practice in this codebase, and others under the biocore organization, to not leave lingering state changes in databases during testing. Short term, it might simplify a test. Long term, it makes reasoning about what's going on difficult as the state of the entity being tested is changing. It can also make repeat runs of the same tests, without repopulating the test database in between, impossible

There are a few different ways it's managed in this codebase depending on the situation, see e.g., repo/source.py. I'm not sure what strategy will be best here. It might be to use exact identifiers on population, and have tearDown remove from the corresponding tables which is practical but leaves room for missing a few things and possibly some maintenance burden. Best is if this can be done where a .rollback() can just be issued, but that is not possible in all scenarios

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the information! Yes I agree that we should try to place all database state changes in setUp and tearDown, so is it okay if the inserted values have logic errors? For example, if a side effect of inserting a ftp involves populating another table and this never happens. We could make sure to only use these values for the purpose of this query.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, exactly. If state is always reset, then it's fine to put garbage in to verify behavior.

Test execution is out-of-order, so any state changes which occur can have side effects on other tests. This can lead to difficult to debug/understand scenarios when bad data are intentionally placed into the database.

for tx_id, iu_id in tx_ids.items()
])
)
t.commit()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

tup[0]: tx_id
for tup, tx_id in zip(cur.fetchall(), tx_ids)
}
t.commit()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...I'll stop noting :)

email = "%" + email + "%"
with self._transaction.dict_cursor() as cur:
# Note: Use left join to differentiate email not found possibility
cur.execute(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very clean

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, impressive query

@cassidysymons
Copy link
Collaborator

Going to hold on merging this until the corresponding Interface PR is finalized. Great work @colts661 !

@cassidysymons cassidysymons merged commit 8d4c0bd into biocore:master Dec 13, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants