Skip to content

Commit

Permalink
added new test
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerzupan committed Nov 21, 2024
1 parent a802031 commit a35522a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
21 changes: 0 additions & 21 deletions tests/test_remote.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import logging
import os
from unittest.mock import Mock

import pytest

from block_cascade import GcpEnvironmentConfig, GcpMachineConfig, GcpResource
from block_cascade import remote
from block_cascade.utils import PREFECT_VERSION
from tests.test_config import gcp_resource

if PREFECT_VERSION == 2:
from prefect.context import FlowRunContext, TaskRunContext

Expand Down Expand Up @@ -48,24 +45,6 @@ def addition(a: int, b: int) -> int:
assert result == 3


def test_remote_local_override():
"""Test the remote decorator with the local executor using the no_resource_on_local flag."""
machine_config = GcpMachineConfig(type="n1-standard-4")
gcp_resource = GcpResource(
chief=machine_config,
environment=GcpEnvironmentConfig(
storage_location=GCP_STORAGE_LOCATION, project=GCP_PROJECT
),
)
@remote(resource=gcp_resource, no_resource_on_local=True)
def addition(a: int, b: int) -> int:
return a + b

result = addition(1, 2)

assert result == 3


def test_remote_no_sugar():
"""Test using the decorator with syntactic sugar."""

Expand Down
24 changes: 24 additions & 0 deletions tests/test_remote_no_prefect.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from block_cascade import GcpEnvironmentConfig, GcpMachineConfig, GcpResource
from block_cascade import remote

GCP_PROJECT = "test-project"
GCP_STORAGE_LOCATION = f"gs://{GCP_PROJECT}-cascade/"


def test_remote_local_override():
"""Test the remote decorator with the local executor using the no_resource_on_local flag."""
machine_config = GcpMachineConfig(type="n1-standard-4")
gcp_resource = GcpResource(
chief=machine_config,
environment=GcpEnvironmentConfig(
storage_location=GCP_STORAGE_LOCATION, project=GCP_PROJECT
),
)

@remote(resource=gcp_resource, no_resource_on_local=True)
def multiply(a: int, b: int) -> int:
return a * b

result = multiply(1, 2)

assert result == 2

0 comments on commit a35522a

Please sign in to comment.