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

Reimplement stores tests #22

Open
thclark opened this issue Oct 3, 2022 · 0 comments
Open

Reimplement stores tests #22

thclark opened this issue Oct 3, 2022 · 0 comments
Assignees
Labels
tech-debt Technical debt (tidy up, refactoring, restructuring, caused by laziness now) test Implement or update unit tests

Comments

@thclark
Copy link
Contributor

thclark commented Oct 3, 2022

Feature request

Current state

Stores were thoroughly tested before refactoring django-twined from another app. However, now, those tests are commented out and need to be brought up to scratch with the rest of the unit tests.

Also, stores require an integration test for various syncing purposes and we should use terraform to correctly hook up buckets for integration testing of the stores.

Note

I did a manual test of the stores, step-by-step evaluating what files appear and when, and when their metadata gets synced. The management command try_sync.py I used to do that is here:

from uuid import uuid4
from django.core.management.base import BaseCommand

from octue.resources import Datafile
from projects.tasks.trial import MyOnDemandTask
from icecream import ic


class Command(BaseCommand):
    """A management command to invoke on-demand and subscriber tasks manually
    Intended for use while experimenting in a live environment to see if it works
    """

    def handle(self, *args, **options):
        # An already existing file
        bucket_name = "test-lake-mast-timeseries"
        path = "77bff006-ca05-4384-a8a6-ff86e712d6ac.txt"
        datafile = Datafile(f"gs://{bucket_name}/{path}", id="77bff006-ca05-4384-a8a6-ff86e712d6ac")
        ic(datafile)
        ic(datafile.id)
        ic(datafile.labels)
        ic(datafile.tags)

        # Update metadata
        datafile.labels = ["stuff", "two"]
        datafile.update_metadata()

        ic(datafile.labels)
        ic(datafile.tags)
        ic(datafile.path_in_bucket)
        
        # A new file that shouldn't exist yet (we need to specify id, labels and tags then get metadata, all without creating a file

        creating_path = "whatever.txt"
        creating_id = str(uuid4())
        ic(creating_id)
        creating_df = Datafile(f"gs://{bucket_name}/{creating_path}", id=creating_id)
        ic(creating_df)
        # Now check - the creating_path should not be on gcs
        # Checked - correct
        ic(creating_df.metadata())
        # Now check - the creating_path should not be on gcs
        # Checked - correct
        creating_df.tags = {"a": "b"}
        ic(creating_df.metadata())
        # Now check - the creating_path should not be on gcs
        # Checked - correct
        creating_df.labels = ["a", "b"]
        ic(creating_df.metadata())
        # Now check - the creating_path should not be on gcs
        # Checked - correct
@thclark thclark self-assigned this Oct 3, 2022
@thclark thclark added tech-debt Technical debt (tidy up, refactoring, restructuring, caused by laziness now) test Implement or update unit tests labels Oct 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tech-debt Technical debt (tidy up, refactoring, restructuring, caused by laziness now) test Implement or update unit tests
Projects
Status: No status
Development

No branches or pull requests

1 participant