Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@
# *********************************************************************

"""
The mixed console ends with its "Find out more" section when it stops early,
as it does after a run. These run it to each early end, so they need no key
and no network.
The mixed console and the mixed web example each end with their "Find out
more" section when they stop early, as they do after a run. These run each
of them to each early end, so they need no key and no network.
"""

import pytest

from fiftyone_pipeline_examples.cloud.mixed import gettingstarted_console
from fiftyone_pipeline_examples.cloud.mixed.gettingstarted_web import app
from fiftyone_pipeline_examples.example_utils import ExampleUtils

# Every name a key is read from.
Expand Down Expand Up @@ -61,3 +64,35 @@ def refuse(*args, **kwargs):
gettingstarted_console.main(["a-resource-key"])

assert "Find out more:" in capsys.readouterr().out


def test_the_web_example_without_a_key(monkeypatch, capsys):
for name in KEY_SETTINGS:
monkeypatch.delenv(name, raising=False)

def started(*args, **kwargs):
raise AssertionError("The web server was started")

monkeypatch.setattr(app, "create_app", started)

app.main([])

printed = capsys.readouterr().out
assert "Find out more:" in printed
for _, url in app.FIND_OUT_MORE:
assert url in printed


def test_the_web_example_when_the_pipeline_cannot_be_built(monkeypatch,
capsys):
# Stands in for a key the cloud service refuses, or one that carries
# none of the properties the example shows.
def refuse(*args, **kwargs):
raise ValueError("The key carries none of the properties.")

monkeypatch.setattr(app, "create_pipeline", refuse)

with pytest.raises(SystemExit):
app.main(["a-resource-key"])

assert "Find out more:" in capsys.readouterr().out
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@

"""
The creator context demo, started with no resource key, ends without an
error and says which environment variable to set and where to create a key.
error, says which environment variable to set and where to create a key,
and ends with its "Find out more" section, which the page carries and a
person who never reaches the page would otherwise never see.
"""

import io
Expand Down Expand Up @@ -55,6 +57,9 @@ def test_says_where_to_create_a_resource_key(self):
said = printed.getvalue()
self.assertIn("_51DEGREES_RESOURCE_KEY", said)
self.assertRegex(said, CONFIGURE_LINK)
self.assertIn("Find out more:", said)
for _, url in server.FIND_OUT_MORE:
self.assertIn(url, said)


if __name__ == "__main__":
Expand Down
Loading