@@ -56,9 +56,9 @@ def spec(self, logger: logging.Logger) -> Any:
5656
5757def run_test_job (
5858 connector : IConnector | type [IConnector ] | Callable [[], IConnector ],
59- verb : Literal ["read" , "check" , "discover" ],
60- test_scenario : ConnectorTestScenario ,
59+ verb : Literal ["spec" , "read" , "check" , "discover" ],
6160 * ,
61+ test_scenario : ConnectorTestScenario | None = None ,
6262 catalog : ConfiguredAirbyteCatalog | dict [str , Any ] | None = None ,
6363) -> entrypoint_wrapper .EntrypointOutput :
6464 """Run a test scenario from provided CLI args and return the result."""
@@ -81,9 +81,9 @@ def run_test_job(
8181 )
8282
8383 args : list [str ] = [verb ]
84- if test_scenario .config_path :
84+ if test_scenario and test_scenario .config_path :
8585 args += ["--config" , str (test_scenario .config_path )]
86- elif test_scenario .config_dict :
86+ elif test_scenario and test_scenario .config_dict :
8787 config_path = (
8888 Path (tempfile .gettempdir ()) / "airbyte-test" / f"temp_config_{ uuid .uuid4 ().hex } .json"
8989 )
@@ -103,7 +103,7 @@ def run_test_job(
103103 )
104104 catalog_path .parent .mkdir (parents = True , exist_ok = True )
105105 catalog_path .write_text (orjson .dumps (catalog ).decode ())
106- elif test_scenario .configured_catalog_path :
106+ elif test_scenario and test_scenario .configured_catalog_path :
107107 catalog_path = Path (test_scenario .configured_catalog_path )
108108
109109 if catalog_path :
@@ -112,12 +112,18 @@ def run_test_job(
112112 # This is a bit of a hack because the source needs the catalog early.
113113 # Because it *also* can fail, we have to redundantly wrap it in a try/except block.
114114
115+ expect_exception = False
116+ if test_scenario and test_scenario .expect_exception :
117+ # If the test scenario expects an exception, we need to set the
118+ # `expect_exception` flag to True.
119+ expect_exception = True
120+
115121 result : entrypoint_wrapper .EntrypointOutput = entrypoint_wrapper ._run_command ( # noqa: SLF001 # Non-public API
116122 source = connector_obj , # type: ignore [arg-type]
117123 args = args ,
118- expecting_exception = test_scenario . expect_exception ,
124+ expecting_exception = False if not test_scenario else expect_exception ,
119125 )
120- if result .errors and not test_scenario . expect_exception :
126+ if result .errors and not expect_exception :
121127 raise AssertionError (
122128 f"Expected no errors but got { len (result .errors )} : \n " + _errors_to_str (result )
123129 )
@@ -132,7 +138,7 @@ def run_test_job(
132138 + "\n " .join ([str (msg ) for msg in result .connection_status_messages ])
133139 + _errors_to_str (result )
134140 )
135- if test_scenario . expect_exception :
141+ if expect_exception :
136142 conn_status = result .connection_status_messages [0 ].connectionStatus
137143 assert conn_status , (
138144 "Expected CONNECTION_STATUS message to be present. Got: \n "
@@ -146,7 +152,7 @@ def run_test_job(
146152 return result
147153
148154 # For all other verbs, we assert check that an exception is raised (or not).
149- if test_scenario . expect_exception :
155+ if expect_exception :
150156 if not result .errors :
151157 raise AssertionError ("Expected exception but got none." )
152158
0 commit comments