-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
79 additions
and
2 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
tests/assets/plugins/blockifiers/blockifier_with_secrets.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from typing import Optional, Type | ||
|
||
from steamship import Block, File | ||
from steamship.invocable import Config, InvocableResponse, create_handler | ||
from steamship.invocable.plugin_service import PluginRequest | ||
from steamship.plugin.blockifier.blockifier import Blockifier | ||
from steamship.plugin.inputs.raw_data_plugin_input import RawDataPluginInput | ||
from steamship.plugin.outputs.block_and_tag_plugin_output import BlockAndTagPluginOutput | ||
|
||
# Note 1: this aligns with the same document in the internal Engine test. | ||
# Note 2: This should be duplicated from the test_importer because of the way our test system will | ||
# bundle this into an invocable deployment package (importing won't work!) | ||
HANDLE = "test-blockifier-plugin-v1" | ||
TEST_H1 = "A Poem" | ||
TEST_S1 = "Roses are red." | ||
TEST_S2 = "Violets are blue." | ||
TEST_S3 = "Sugar is sweet, and I love you." | ||
TEST_DOC = f"# {TEST_H1}\n\n{TEST_S1} {TEST_S2}\n\n{TEST_S3}\n" | ||
|
||
|
||
class DummyBlockifierPlugin(Blockifier): | ||
class DummyBlockifierConfig(Config): | ||
secret: Optional[str] = "" | ||
|
||
config: DummyBlockifierConfig | ||
|
||
@classmethod | ||
def config_cls(cls) -> Type[Config]: | ||
return cls.DummyBlockifierConfig | ||
|
||
def run( | ||
self, request: PluginRequest[RawDataPluginInput] | ||
) -> InvocableResponse[BlockAndTagPluginOutput]: | ||
return InvocableResponse( | ||
data=BlockAndTagPluginOutput( | ||
file=File( | ||
blocks=[ | ||
Block( | ||
text=self.config.secret, | ||
), | ||
] | ||
) | ||
) | ||
) | ||
|
||
|
||
handler = create_handler(DummyBlockifierPlugin) |
22 changes: 22 additions & 0 deletions
22
tests/steamship_tests/plugin/integration/test_e2e_blockifier_with_secrets.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from steamship_tests import PLUGINS_PATH | ||
from steamship_tests.utils.deployables import deploy_plugin | ||
from steamship_tests.utils.fixtures import get_steamship_client | ||
|
||
from steamship import File | ||
|
||
|
||
def test_e2e_blockifier_plugin(): | ||
client = get_steamship_client() | ||
blockifier_path = PLUGINS_PATH / "blockifiers" / "blockifier_with_secrets.py" | ||
with deploy_plugin(client, blockifier_path, "blockifier", secrets_toml='secret="FOO"') as ( | ||
plugin, | ||
version, | ||
instance, | ||
): | ||
file = File.create(client=client, content="This is a test.") | ||
assert len(file.refresh().blocks) == 0 | ||
file.blockify(plugin_instance=instance.handle).wait() | ||
file.refresh() | ||
assert len(file.blocks) == 1 | ||
assert file.blocks[0].text == "FOO" | ||
file.delete() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters