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

Modify factories of opportunity attachment staging / foreign tables to be able to load files directly to the DB #3266

Closed
2 tasks
chouinar opened this issue Dec 17, 2024 · 0 comments · Fixed by #3370
Assignees

Comments

@chouinar
Copy link
Collaborator

chouinar commented Dec 17, 2024

Summary

We want the factories for the opportunity attachment tables to be pre-populated with files stored in the columns when we generate them from our factories

An example program that does a bit of this manually with actual files (not a requirement):

def test_thing(db_session, enable_factory_create):
    # Reading a file and writing to the database
    # We should be able to do something like this in our factories
    # Potentially with raw text / byte streams instead
    with open("my_file", "rb") as outfile:
        opp = OpportunityFactory.create(my_attachment=outfile.read())
    opp_id = opp.opportunity_id
    # Force the next query to be from the DB for testing purposes
    db_session.commit()
    db_session.expire_all()
    db_opp = db_session.query(Opportunity).filter(Opportunity.opportunity_id == opp_id).one_or_none()
    # Attaching opportunity
    with open("out_file.txt", "wb") as outfile:
        outfile.write(db_opp.my_attachment)

Acceptance criteria

  • Factories work to create dummy "files" in the staging and foreign DB tables
  • The contents of the files don't really matter, feel free to generate the bytes on the fly. It's fine to turn a text string into bytes, so long as it can later be made into a file.
@chouinar chouinar moved this from Icebox to Todo in Simpler.Grants.gov Product Backlog Dec 19, 2024
@babebe babebe self-assigned this Dec 19, 2024
@babebe babebe moved this from Todo to In Progress in Simpler.Grants.gov Product Backlog Dec 19, 2024
@babebe babebe moved this from In Progress to In Review in Simpler.Grants.gov Product Backlog Dec 26, 2024
@babebe babebe linked a pull request Jan 2, 2025 that will close this issue
babebe added a commit that referenced this issue Jan 7, 2025
## Summary
Fixes #{[3266](#3266)}

### Time to review: __10 mins__

## Changes proposed
> Added class method to staging and foreign Opportunity Factory
> Added test

---------

Co-authored-by: nava-platform-bot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging a pull request may close this issue.

2 participants