From 21c89427e18005f135fc37127dc4116ddb435c07 Mon Sep 17 00:00:00 2001 From: James Rosewell Date: Mon, 16 Nov 2026 11:43:30 +0000 Subject: [PATCH] Test that the two web examples end with their Find out more section The mixed cloud web example and the 51Did creator context demo each stop early when there is no key, and the mixed one also stops when the cloud service refuses the key. Neither wrote anything about where to go next on those paths, where their console siblings do and their pages do, so a person who never reaches the page saw no links at all. --- .../examples/tests/test_find_out_more.py | 41 +++++++++++++++++-- .../tests/test_creator_context_without_key.py | 7 +++- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/pipeline/fiftyone_pipeline_cloudrequestengine/examples/tests/test_find_out_more.py b/pipeline/fiftyone_pipeline_cloudrequestengine/examples/tests/test_find_out_more.py index 34195956..73140de9 100644 --- a/pipeline/fiftyone_pipeline_cloudrequestengine/examples/tests/test_find_out_more.py +++ b/pipeline/fiftyone_pipeline_cloudrequestengine/examples/tests/test_find_out_more.py @@ -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. @@ -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 diff --git a/pipeline/fiftyone_pipeline_did/tests/test_creator_context_without_key.py b/pipeline/fiftyone_pipeline_did/tests/test_creator_context_without_key.py index 52261b7a..3fb9e421 100644 --- a/pipeline/fiftyone_pipeline_did/tests/test_creator_context_without_key.py +++ b/pipeline/fiftyone_pipeline_did/tests/test_creator_context_without_key.py @@ -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 @@ -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__":