Skip to content

Commit

Permalink
Merge pull request #59 from chanzuckerberg/valenzuelaomar/fix-test-fi…
Browse files Browse the repository at this point in the history
…le-mutations

Fix mutations test
  • Loading branch information
valenzuelaomar authored Jun 21, 2024
2 parents 65c3bf1 + 509aa51 commit 1026670
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ services:
- PLATFORMICS_DATABASE_NAME=platformics
- DEFAULT_UPLOAD_BUCKET=local-bucket
- DEFAULT_UPLOAD_PROTOCOL=s3
- OUTPUT_S3_PREFIX=platformics
- BOTO_ENDPOINT_URL=http://motoserver.platformics:4000
- AWS_REGION=us-west-2
- AWS_ACCESS_KEY_ID=test
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ services:
- PLATFORMICS_DATABASE_NAME=platformics
- DEFAULT_UPLOAD_BUCKET=local-bucket
- DEFAULT_UPLOAD_PROTOCOL=s3
- OUTPUT_S3_PREFIX=platformics
- BOTO_ENDPOINT_URL=http://motoserver.platformics:4000
- AWS_REGION=us-west-2
- AWS_ACCESS_KEY_ID=test
Expand Down
2 changes: 1 addition & 1 deletion platformics/database/models/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def before_delete(mapper: Mapper, connection: Connection, target: File) -> None:
settings = File.get_settings()
s3_client = File.get_s3_client()

# If this file is managed by NextGen, see if it needs to be deleted from S3
# If this file is managed by platformics, see if it needs to be deleted from S3
if target.path.startswith(f"{settings.OUTPUT_S3_PREFIX}/") and target.protocol == FileAccessProtocol.s3:
# Is this the last File object pointing to this path?
files_pointing_to_same_path = connection.execute(
Expand Down
2 changes: 1 addition & 1 deletion test_app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ clean: ## Remove all codegen'd artifacts.
rm -rf cerbos
rm -rf support
rm -rf database
rm -f .moto_recording
rm -rf .moto_recording
rm -rf test_infra
$(docker_compose) --profile '*' down

Expand Down
1 change: 1 addition & 0 deletions test_app/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ services:
- PLATFORMICS_DATABASE_NAME=platformics
- DEFAULT_UPLOAD_BUCKET=local-bucket
- DEFAULT_UPLOAD_PROTOCOL=s3
- OUTPUT_S3_PREFIX=platformics
- BOTO_ENDPOINT_URL=http://motoserver.platformics:4000
- AWS_REGION=us-west-2
- AWS_ACCESS_KEY_ID=test
Expand Down
1 change: 0 additions & 1 deletion test_app/schema/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -342,5 +342,4 @@ classes:
range: string
required: true
annotations:
mutable: false
plural: ImmutableTypes
4 changes: 3 additions & 1 deletion test_app/tests/test_field_visibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ async def test_update_fields(
]
fields = [field["name"] for field in create_type["inputFields"]]
# We have a limited subset of mutable fields on SequencingRead
assert set(fields) == set(["nucleicAcid", "sampleId", "technology", "protocol", "deletedAt", "primerFileId", "collectionId"])
assert set(fields) == set(
["nucleicAcid", "sampleId", "technology", "protocol", "deletedAt", "primerFileId", "collectionId"]
)


# Make sure we only allow certain fields to be set at entity creation time.
Expand Down
8 changes: 4 additions & 4 deletions test_app/tests/test_file_mutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ async def test_create_file(
# Upload a fastq file to a mock bucket so we can create a file object from it
file_namespace = "local-bucket"
file_path = "test1.fastq"
file_path_local = "tests/fixtures/test1.fasta"
file_path_local = "tests/fixtures/test1.fastq"
file_size = os.stat(file_path_local).st_size
with open(file_path_local, "rb") as fp:
moto_client.put_object(Bucket=file_namespace, Key=file_path, Body=fp)
Expand All @@ -211,7 +211,7 @@ async def test_create_file(
path
size
}}
}}
"""
output = await gql_client.query(mutation, member_projects=[123], service_identity="workflows")
assert output["data"]["createFile"]["size"] == file_size
Expand All @@ -221,9 +221,9 @@ async def test_create_file(
@pytest.mark.parametrize(
"file_path,multiple_files_for_one_path,should_delete",
[
("nextgen/test1.fastq", False, True),
("platformics/test1.fastq", False, True),
("bla/test1.fastq", False, False),
("nextgen/test1.fastq", True, False),
("platformics/test1.fastq", True, False),
("bla/test1.fastq", True, False),
],
)
Expand Down

0 comments on commit 1026670

Please sign in to comment.