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

Remove randomness from AstroDB.create_unique_table_name #39

Merged

Conversation

AustinCullar
Copy link
Owner

This change will remove the randomness from AstroDB.create_unique_name. The new method for generating unique names involves the manipulation of a 3 character string consisting of capital letters.

The first table name will be named AAA. For each additional table, the name will be 'rolled forward' such that:

AAA -> BAA -> CAA -> DAA -> ... -> ZAA -> ABA -> BBA -> ... -> YZZ -> ZZZ

This will provide 26^3 (17576) possible names. It is unlikely for this limit to present a problem, since that would imply we have over 17k YouTube videos' worth of data in our database.

Additional work in this change:

  • Removed unused AstroDB.comment_table_exists method and associated test
  • Modified the existing test for AstroDB.create_unique_table_name to account for new functionality
    • Added 2 mock classes in the new tests/astro_mocks.py file
      • MockSqlite3Connection
      • MockSqlite3Cursor
    • Added a fixture mock_sqlite3_connect to utilize the above mock classes to mock the database
      • I should now have full control over the database with this fixture

    - Comment table names will now 'roll forward' as new ones are created
    - Restricted names to 3 characters, allowing for 26^3 (17576) possible names
- Removed unused AstroDB.comment_table_exists method and associated test
- Modified the existing test for AstroDB.create_unique_table_name to account for new functionality
    - Added 2 mock classes in the new tests/astro_mocks.py file
        - MockSqlite3Connection
        - MockSqlite3Cursor
    - Added a fixture mock_sqlite3_connect to utilize the above mock classes to mock the database
        - I should now have full control over the database with this fixture
@AustinCullar AustinCullar added enhancement New feature or request testing Adds new tests labels Oct 1, 2024
@AustinCullar AustinCullar self-assigned this Oct 1, 2024
@AustinCullar AustinCullar linked an issue Oct 1, 2024 that may be closed by this pull request
- Modify tests to account for new error handling
- Add fixture to mock database returning None to simulate record not found
- Add static method YouTubeDataAPI.valid_video_id to aid in error checking
@AustinCullar AustinCullar merged commit fba23c9 into main Oct 2, 2024
1 check passed
@AustinCullar AustinCullar deleted the 32-remove-randomness-from-astrodbcreate_unique_table_name branch October 2, 2024 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request testing Adds new tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove randomness from AstroDB.create_unique_table_name()
1 participant