This is an automated email from the ASF dual-hosted git repository.

pabloem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/master by this push:
     new b1aaf44  Merge pull request #16118 from [BEAM-13362][Playground] 
python ci cd support options + yapf/linter fix
b1aaf44 is described below

commit b1aaf441c2370f78ae84b77aa8e59be4e00abf71
Author: daria.malkova <[email protected]>
AuthorDate: Mon Dec 6 07:59:26 2021 +0300

    Merge pull request #16118 from [BEAM-13362][Playground] python ci cd 
support options + yapf/linter fix
    
    * support loading tag with pipeline options suport
    
    * fix tests, add support empty tag
    
    * merge master conflicts resolving
    
    * Refactoring with pylint and yapf
---
 playground/infrastructure/cd_helper.py        |  43 +++++-----
 playground/infrastructure/ci_cd.py            |   1 +
 playground/infrastructure/ci_helper.py        |  11 ++-
 playground/infrastructure/config.py           |  13 +--
 playground/infrastructure/grpc_client.py      |   3 +-
 playground/infrastructure/helper.py           |  72 +++++++++-------
 playground/infrastructure/logger.py           |   2 +-
 playground/infrastructure/test_cd_helper.py   |  56 ++++++-------
 playground/infrastructure/test_ci_cd.py       |   4 +-
 playground/infrastructure/test_grpc_client.py |   2 +-
 playground/infrastructure/test_helper.py      | 116 +++++++++++++-------------
 11 files changed, 170 insertions(+), 153 deletions(-)

diff --git a/playground/infrastructure/cd_helper.py 
b/playground/infrastructure/cd_helper.py
index 3cea5db..5d51986 100644
--- a/playground/infrastructure/cd_helper.py
+++ b/playground/infrastructure/cd_helper.py
@@ -12,12 +12,14 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
+
 """
   Helper for CD step.
 
   It is used to save beam examples/katas/tests and their output on the GCS.
 """
 import asyncio
+import json
 import logging
 import os
 import shutil
@@ -38,7 +40,6 @@ class CDHelper:
 
   It is used to save beam examples/katas/tests and their output on the GCS.
   """
-
   def store_examples(self, examples: List[Example]):
     """
     Store beam examples and their output in the Google Cloud.
@@ -58,7 +59,7 @@ class CDHelper:
         examples: beam examples that should be run
     """
     await get_statuses(
-      examples)  # run examples code and wait until all are executed
+        examples)  # run examples code and wait until all are executed
     client = GRPCClient()
     tasks = [client.get_run_output(example.pipeline_id) for example in 
examples]
     outputs = await asyncio.gather(*tasks)
@@ -78,7 +79,7 @@ class CDHelper:
       file_names = self._write_to_local_fs(example)
       for cloud_file_name, local_file_name in file_names.items():
         self._upload_blob(
-          source_file=local_file_name, destination_blob_name=cloud_file_name)
+            source_file=local_file_name, destination_blob_name=cloud_file_name)
 
   def _write_to_local_fs(self, example: Example):
     """
@@ -92,33 +93,33 @@ class CDHelper:
 
     """
     path_to_object_folder = os.path.join(
-      Config.TEMP_FOLDER,
-      example.pipeline_id,
-      Sdk.Name(example.sdk),
-      example.tag.name)
+        Config.TEMP_FOLDER,
+        example.pipeline_id,
+        Sdk.Name(example.sdk),
+        example.tag.name)
     Path(path_to_object_folder).mkdir(parents=True, exist_ok=True)
 
     file_names = {}
     code_path = self._get_gcs_object_name(
-      sdk=example.sdk,
-      base_folder_name=example.tag.name,
-      file_name=example.tag.name)
+        sdk=example.sdk,
+        base_folder_name=example.tag.name,
+        file_name=example.tag.name)
     output_path = self._get_gcs_object_name(
-      sdk=example.sdk,
-      base_folder_name=example.tag.name,
-      file_name=example.tag.name,
-      extension=PrecompiledExample.OUTPUT_EXTENSION)
+        sdk=example.sdk,
+        base_folder_name=example.tag.name,
+        file_name=example.tag.name,
+        extension=PrecompiledExample.OUTPUT_EXTENSION)
     meta_path = self._get_gcs_object_name(
-      sdk=example.sdk,
-      base_folder_name=example.tag.name,
-      file_name=PrecompiledExample.META_NAME,
-      extension=PrecompiledExample.META_EXTENSION)
+        sdk=example.sdk,
+        base_folder_name=example.tag.name,
+        file_name=PrecompiledExample.META_NAME,
+        extension=PrecompiledExample.META_EXTENSION)
     file_names[code_path] = example.code
     file_names[output_path] = example.output
-    file_names[meta_path] = str(example.tag._asdict())
+    file_names[meta_path] = json.dumps(example.tag._asdict())
     for file_name, file_content in file_names.items():
       local_file_path = os.path.join(
-        Config.TEMP_FOLDER, example.pipeline_id, file_name)
+          Config.TEMP_FOLDER, example.pipeline_id, file_name)
       with open(local_file_path, "w", encoding="utf-8") as file:
         file.write(file_content)
       # don't need content anymore, instead save the local path
@@ -146,7 +147,7 @@ class CDHelper:
     if extension is None:
       extension = Config.EXTENSIONS[Sdk.Name(sdk)]
     return os.path.join(
-      Sdk.Name(sdk), base_folder_name, f"{file_name}.{extension}")
+        Sdk.Name(sdk), base_folder_name, f"{file_name}.{extension}")
 
   def _upload_blob(self, source_file: str, destination_blob_name: str):
     """
diff --git a/playground/infrastructure/ci_cd.py 
b/playground/infrastructure/ci_cd.py
index f033b47..bff8eb3 100644
--- a/playground/infrastructure/ci_cd.py
+++ b/playground/infrastructure/ci_cd.py
@@ -12,6 +12,7 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
+
 """
 Module implements CI/CD steps for Beam Playground examples
 """
diff --git a/playground/infrastructure/ci_helper.py 
b/playground/infrastructure/ci_helper.py
index af2ed42..dc7be84 100644
--- a/playground/infrastructure/ci_helper.py
+++ b/playground/infrastructure/ci_helper.py
@@ -36,7 +36,6 @@ class CIHelper:
 
   It is used to find and verify correctness if beam examples/katas/tests.
   """
-
   async def verify_examples(self, examples: List[Example]):
     """
     Verify correctness of beam examples.
@@ -74,19 +73,19 @@ class CIHelper:
         logging.error("Example: %s has preparation error", example.pipeline_id)
       elif example.status == STATUS_ERROR:
         logging.error(
-          "Example: %s has error during setup run builder", example.pipeline_id
-        )
+            "Example: %s has error during setup run builder",
+            example.pipeline_id)
       elif example.status == STATUS_RUN_TIMEOUT:
         logging.error(
-          "Example: %s failed because of timeout", example.pipeline_id)
+            "Example: %s failed because of timeout", example.pipeline_id)
       elif example.status == STATUS_COMPILE_ERROR:
         err = await client.get_compile_output(example.pipeline_id)
         logging.error(
-          "Example: %s has compilation error: %s", example.pipeline_id, err)
+            "Example: %s has compilation error: %s", example.pipeline_id, err)
       elif example.status == STATUS_RUN_ERROR:
         err = await client.get_run_error(example.pipeline_id)
         logging.error(
-          "Example: %s has execution error: %s", example.pipeline_id, err)
+            "Example: %s has execution error: %s", example.pipeline_id, err)
       verify_failed = True
     if verify_failed:
       raise Exception("CI step failed due to errors in the examples")
diff --git a/playground/infrastructure/config.py 
b/playground/infrastructure/config.py
index 5df9895..c1c8e71 100644
--- a/playground/infrastructure/config.py
+++ b/playground/infrastructure/config.py
@@ -37,12 +37,12 @@ class Config:
   EXTENSIONS = {"SDK_JAVA": "java", "SDK_GO": "go", "SDK_PYTHON": "py"}
   NO_STORE = "no-store"
   ERROR_STATUSES = [
-    STATUS_VALIDATION_ERROR,
-    STATUS_ERROR,
-    STATUS_PREPARATION_ERROR,
-    STATUS_COMPILE_ERROR,
-    STATUS_RUN_TIMEOUT,
-    STATUS_RUN_ERROR
+      STATUS_VALIDATION_ERROR,
+      STATUS_ERROR,
+      STATUS_PREPARATION_ERROR,
+      STATUS_COMPILE_ERROR,
+      STATUS_RUN_TIMEOUT,
+      STATUS_RUN_ERROR
   ]
   BEAM_PLAYGROUND_TITLE = "Beam-playground:\n"
   BEAM_PLAYGROUND = "Beam-playground"
@@ -55,6 +55,7 @@ class TagFields:
   description: str = "description"
   multifile: str = "multifile"
   categories: str = "categories"
+  pipeline_options: str = "pipeline_options"
 
 
 @dataclass(frozen=True)
diff --git a/playground/infrastructure/grpc_client.py 
b/playground/infrastructure/grpc_client.py
index 61e02c2..9f2fd42 100644
--- a/playground/infrastructure/grpc_client.py
+++ b/playground/infrastructure/grpc_client.py
@@ -27,7 +27,6 @@ from config import Config
 
 class GRPCClient:
   """GRPCClient is gRPC client for sending a request to the backend."""
-
   def __init__(self):
     self._channel = grpc.aio.insecure_channel(Config.SERVER_ADDRESS)
     self._stub = api_pb2_grpc.PlaygroundServiceStub(self._channel)
@@ -47,7 +46,7 @@ class GRPCClient:
       sdks = api_pb2.Sdk.keys()
       sdks.remove(api_pb2.Sdk.Name(0))  # del SDK_UNSPECIFIED
       raise Exception(
-        f'Incorrect sdk: must be from this pool: {", ".join(sdks)}')
+          f'Incorrect sdk: must be from this pool: {", ".join(sdks)}')
     request = api_pb2.RunCodeRequest(code=code, sdk=sdk)
     response = await self._stub.RunCode(request)
     return response.pipeline_uuid
diff --git a/playground/infrastructure/helper.py 
b/playground/infrastructure/helper.py
index a8dcd37..19a203b 100644
--- a/playground/infrastructure/helper.py
+++ b/playground/infrastructure/helper.py
@@ -34,13 +34,14 @@ from config import Config, TagFields
 from grpc_client import GRPCClient
 
 Tag = namedtuple(
-  "Tag",
-  [
-    TagFields.name,
-    TagFields.description,
-    TagFields.multifile,
-    TagFields.categories
-  ])
+    "Tag",
+    [
+        TagFields.name,
+        TagFields.description,
+        TagFields.multifile,
+        TagFields.categories,
+        TagFields.pipeline_options
+    ])
 
 
 @dataclass
@@ -71,6 +72,7 @@ def find_examples(work_dir: str,
       categories:
           - category-1
           - category-2
+      pipeline_options: --inputFile=your_file --outputFile=your_output_file
   If some example contain beam tag with incorrect format raise an error.
 
   Args:
@@ -86,13 +88,12 @@ def find_examples(work_dir: str,
     for filename in files:
       filepath = os.path.join(root, filename)
       error_during_check_file = _check_file(
-        examples, filename, filepath, supported_categories)
+          examples, filename, filepath, supported_categories)
       has_error = has_error or error_during_check_file
   if has_error:
     raise ValueError(
-      "Some of the beam examples contain beam playground tag with "
-      "an incorrect format"
-    )
+        "Some of the beam examples contain beam playground tag with "
+        "an incorrect format")
   return examples
 
 
@@ -175,8 +176,8 @@ def _check_file(examples, filename, filepath, 
supported_categories):
     tag = get_tag(filepath)
     if tag:
       if _validate(tag, supported_categories) is False:
-        logging.error("%s contains beam playground tag with incorrect format",
-                      filepath)
+        logging.error(
+            "%s contains beam playground tag with incorrect format", filepath)
         has_error = True
       else:
         examples.append(_get_example(filepath, filename, tag))
@@ -216,7 +217,7 @@ def _get_example(filepath: str, filename: str, tag: dict) 
-> Example:
     content = parsed_file.read()
 
   return Example(
-    name, "", sdk, filepath, content, "", STATUS_UNSPECIFIED, Tag(**tag))
+      name, "", sdk, filepath, content, "", STATUS_UNSPECIFIED, Tag(**tag))
 
 
 def _validate(tag: dict, supported_categories: List[str]) -> bool:
@@ -236,39 +237,52 @@ def _validate(tag: dict, supported_categories: List[str]) 
-> bool:
   """
   valid = True
   for field in fields(TagFields):
-    if tag.get(field.default) is None:
+    if field.default not in tag:
       logging.error(
-        "tag doesn't contain %s field: %s \n"
-        "Please, check that this field exists in the beam playground tag."
-        "If you are sure that this field exists in the tag"
-        " check the format of indenting.", field.default, tag.__str__())
+          "tag doesn't contain %s field: %s \n"
+          "Please, check that this field exists in the beam playground tag."
+          "If you are sure that this field exists in the tag"
+          " check the format of indenting.",
+          field.default,
+          tag.__str__())
+      valid = False
+
+    name = tag.get(TagFields.NAME)
+    if name == "":
+      logging.error(
+          "tag's field name is incorrect: %s \nname can not be empty.",
+          tag.__str__())
       valid = False
 
   multifile = tag.get(TagFields.multifile)
   if (multifile is not None) and (str(multifile).lower() not in ["true",
                                                                  "false"]):
     logging.error(
-      "tag's field multifile is incorrect: %s \n"
-      "multifile variable should be boolean format, but tag contains: %s"
-      , tag.__str__(), str(multifile))
+        "tag's field multifile is incorrect: %s \n"
+        "multifile variable should be boolean format, but tag contains: %s",
+        tag.__str__(),
+        str(multifile))
     valid = False
 
   categories = tag.get(TagFields.categories)
   if categories is not None:
     if not isinstance(categories, list):
       logging.error(
-        "tag's field categories is incorrect: %s \n"
-        "categories variable should be list format, but tag contains: %s"
-        , tag.__str__(), str(type(categories)))
+          "tag's field categories is incorrect: %s \n"
+          "categories variable should be list format, but tag contains: %s",
+          tag.__str__(),
+          str(type(categories)))
       valid = False
     else:
       for category in categories:
         if category not in supported_categories:
           logging.error(
-            "tag contains unsupported category: %s \n"
-            "If you are sure that %s category should be placed in "
-            "Beam Playground, you can add it to the "
-            "`playground/categories.yaml` file", category, category)
+              "tag contains unsupported category: %s \n"
+              "If you are sure that %s category should be placed in "
+              "Beam Playground, you can add it to the "
+              "`playground/categories.yaml` file",
+              category,
+              category)
           valid = False
   return valid
 
diff --git a/playground/infrastructure/logger.py 
b/playground/infrastructure/logger.py
index 6ee2f37..0ba665c 100644
--- a/playground/infrastructure/logger.py
+++ b/playground/infrastructure/logger.py
@@ -33,7 +33,7 @@ def setup_logger():
   log = logging.getLogger()
   log.setLevel(logging.INFO)
   formatter = logging.Formatter(
-    '[%(asctime)s] %(levelname)s [%(name)s.%(funcName)s:%(lineno)d] 
%(message)s'
+      '[%(asctime)s] %(levelname)s [%(name)s.%(funcName)s:%(lineno)d] 
%(message)s'
   )
 
   stdout_handler = logging.StreamHandler(sys.stdout)
diff --git a/playground/infrastructure/test_cd_helper.py 
b/playground/infrastructure/test_cd_helper.py
index fb1f937..831da17 100644
--- a/playground/infrastructure/test_cd_helper.py
+++ b/playground/infrastructure/test_cd_helper.py
@@ -50,10 +50,10 @@ def test__get_gcs_object_name():
   expected_result = "SDK_JAVA/base_folder/file.java"
   expected_result_with_extension = "SDK_JAVA/base_folder/file.output"
   assert CDHelper()._get_gcs_object_name(
-    SDK_JAVA, "base_folder", "file") == expected_result
+      SDK_JAVA, "base_folder", "file") == expected_result
   assert CDHelper()._get_gcs_object_name(
-    SDK_JAVA, "base_folder", "file",
-    "output") == expected_result_with_extension
+      SDK_JAVA, "base_folder", "file",
+      "output") == expected_result_with_extension
 
 
 def test__write_to_local_fs(delete_temp_folder):
@@ -63,24 +63,24 @@ def test__write_to_local_fs(delete_temp_folder):
       delete_temp_folder: python fixture to clean up temp folder after method 
execution
   """
   object_meta = {
-    "name": "name",
-    "description": "description",
-    "multifile": False,
-    "categories": ["category-1", "category-2"]
+      "name": "name",
+      "description": "description",
+      "multifile": False,
+      "categories": ["category-1", "category-2"]
   }
   example = Example(
-    "name",
-    "pipeline_id",
-    SDK_JAVA,
-    "filepath",
-    "code_of_example",
-    "output_of_example",
-    STATUS_UNSPECIFIED,
-    Tag(**object_meta))
+      "name",
+      "pipeline_id",
+      SDK_JAVA,
+      "filepath",
+      "code_of_example",
+      "output_of_example",
+      STATUS_UNSPECIFIED,
+      Tag(**object_meta))
   expected_result = {
-    "SDK_JAVA/name/name.java": "temp/pipeline_id/SDK_JAVA/name/name.java",
-    "SDK_JAVA/name/name.output": "temp/pipeline_id/SDK_JAVA/name/name.output",
-    "SDK_JAVA/name/meta.info": "temp/pipeline_id/SDK_JAVA/name/meta.info"
+      "SDK_JAVA/name/name.java": "temp/pipeline_id/SDK_JAVA/name/name.java",
+      "SDK_JAVA/name/name.output": 
"temp/pipeline_id/SDK_JAVA/name/name.output",
+      "SDK_JAVA/name/meta.info": "temp/pipeline_id/SDK_JAVA/name/meta.info"
   }
   assert CDHelper()._write_to_local_fs(example) == expected_result
 
@@ -92,18 +92,18 @@ def test__save_to_cloud_storage(mocker):
       mocker: mocker fixture from pytest-mocker
   """
   upload_blob_mock = mocker.patch(
-    "cd_helper.CDHelper._upload_blob", return_value=upload_blob)
+      "cd_helper.CDHelper._upload_blob", return_value=upload_blob)
   write_to_os_mock = mocker.patch(
-    "cd_helper.CDHelper._write_to_local_fs", return_value={"": ""})
+      "cd_helper.CDHelper._write_to_local_fs", return_value={"": ""})
   example = Example(
-    "name",
-    "pipeline_id",
-    SDK_JAVA,
-    "filepath",
-    "code_of_example",
-    "output_of_example",
-    STATUS_UNSPECIFIED,
-    None)
+      "name",
+      "pipeline_id",
+      SDK_JAVA,
+      "filepath",
+      "code_of_example",
+      "output_of_example",
+      STATUS_UNSPECIFIED,
+      None)
 
   CDHelper()._save_to_cloud_storage([example])
   write_to_os_mock.assert_called_with(example)
diff --git a/playground/infrastructure/test_ci_cd.py 
b/playground/infrastructure/test_ci_cd.py
index d8fab12..a70035f 100644
--- a/playground/infrastructure/test_ci_cd.py
+++ b/playground/infrastructure/test_ci_cd.py
@@ -34,7 +34,7 @@ def test_ci_step(
   ci_step()
 
   mock_os_getenv.assert_has_calls(
-    [mock.call("BEAM_ROOT_DIR"), mock.call("BEAM_EXAMPLE_CATEGORIES")])
+      [mock.call("BEAM_ROOT_DIR"), mock.call("BEAM_EXAMPLE_CATEGORIES")])
   mock_get_supported_categories.assert_called_once_with("MOCK_VALUE")
   mock_find_examples.assert_called_once_with("MOCK_VALUE", [])
   mock_verify_examples.assert_called_once_with([])
@@ -56,7 +56,7 @@ def test_cd_step(
   cd_step()
 
   mock_os_getenv.assert_has_calls(
-    [mock.call("BEAM_ROOT_DIR"), mock.call("BEAM_EXAMPLE_CATEGORIES")])
+      [mock.call("BEAM_ROOT_DIR"), mock.call("BEAM_EXAMPLE_CATEGORIES")])
   mock_get_supported_categories.assert_called_once_with("MOCK_VALUE")
   mock_find_examples.assert_called_once_with("MOCK_VALUE", [])
   mock_store_examples.assert_called_once_with([])
diff --git a/playground/infrastructure/test_grpc_client.py 
b/playground/infrastructure/test_grpc_client.py
index 53ba227..bc40105 100644
--- a/playground/infrastructure/test_grpc_client.py
+++ b/playground/infrastructure/test_grpc_client.py
@@ -54,7 +54,7 @@ def mock_get_run_output(mocker):
 def mock_get_compile_output(mocker):
   async_mock = AsyncMock(return_value="MOCK_COMPILE_OUTPUT")
   mocker.patch(
-    "grpc_client.GRPCClient.get_compile_output", side_effect=async_mock)
+      "grpc_client.GRPCClient.get_compile_output", side_effect=async_mock)
   return async_mock
 
 
diff --git a/playground/infrastructure/test_helper.py 
b/playground/infrastructure/test_helper.py
index c1ccb59..a556f8a 100644
--- a/playground/infrastructure/test_helper.py
+++ b/playground/infrastructure/test_helper.py
@@ -30,7 +30,7 @@ from helper import find_examples, Example, _get_example, 
_get_name, _get_sdk, \
 @mock.patch("helper._check_file")
 @mock.patch("helper.os.walk")
 def test_find_examples_with_valid_tag(mock_os_walk, mock_check_file):
-  mock_os_walk.return_value = [("/root", (), ("file.java",))]
+  mock_os_walk.return_value = [("/root", (), ("file.java", ))]
   mock_check_file.return_value = False
 
   result = find_examples("", [])
@@ -45,7 +45,7 @@ def test_find_examples_with_valid_tag(mock_os_walk, 
mock_check_file):
 @mock.patch("helper._check_file")
 @mock.patch("helper.os.walk")
 def test_find_examples_with_invalid_tag(mock_os_walk, mock_check_file):
-  mock_os_walk.return_value = [("/root", (), ("file.java",))]
+  mock_os_walk.return_value = [("/root", (), ("file.java", ))]
   mock_check_file.return_value = True
 
   with pytest.raises(
@@ -66,13 +66,13 @@ def test_find_examples_with_invalid_tag(mock_os_walk, 
mock_check_file):
 @mock.patch("helper._update_example_status")
 async def test_get_statuses(mock_update_example_status, mock_grpc_client):
   example = Example(
-    "file",
-    "pipeline_id",
-    SDK_UNSPECIFIED,
-    "root/file.extension",
-    "code",
-    "output",
-    STATUS_UNSPECIFIED, {"name": "Name"})
+      "file",
+      "pipeline_id",
+      SDK_UNSPECIFIED,
+      "root/file.extension",
+      "code",
+      "output",
+      STATUS_UNSPECIFIED, {"name": "Name"})
   client = None
 
   mock_grpc_client.return_value = client
@@ -83,9 +83,9 @@ async def test_get_statuses(mock_update_example_status, 
mock_grpc_client):
 
 
 @mock.patch(
-  "builtins.open",
-  mock_open(
-    read_data="...\n# Beam-playground:\n#     name: Name\n\nimport ..."))
+    "builtins.open",
+    mock_open(
+        read_data="...\n# Beam-playground:\n#     name: Name\n\nimport ..."))
 def test_get_tag_when_tag_is_exists():
   result = get_tag("")
 
@@ -106,14 +106,14 @@ def test__check_file_with_correct_tag(
     mock_get_tag, mock_validate, mock_get_example):
   tag = {"name": "Name"}
   example = Example(
-    "filename",
-    "",
-    SDK_UNSPECIFIED,
-    "/root/filename.java",
-    "data",
-    "",
-    STATUS_UNSPECIFIED,
-    Tag("Name", "Description", False, []))
+      "filename",
+      "",
+      SDK_UNSPECIFIED,
+      "/root/filename.java",
+      "data",
+      "",
+      STATUS_UNSPECIFIED,
+      Tag("Name", "Description", False, [], '--option option'))
   examples = []
 
   mock_get_tag.return_value = tag
@@ -128,7 +128,7 @@ def test__check_file_with_correct_tag(
   mock_get_tag.assert_called_once_with("/root/filename.java")
   mock_validate.assert_called_once_with(tag, [])
   mock_get_example.assert_called_once_with(
-    "/root/filename.java", "filename.java", tag)
+      "/root/filename.java", "filename.java", tag)
 
 
 @mock.patch("helper._validate")
@@ -164,24 +164,25 @@ def test__get_example(mock_get_name, mock_get_sdk):
   mock_get_sdk.return_value = SDK_UNSPECIFIED
 
   result = _get_example(
-    "/root/filepath.extension",
-    "filepath.extension",
-    {
-      "name": "Name",
-      "description": "Description",
-      "multifile": "False",
-      "categories": [""]
-    })
+      "/root/filepath.extension",
+      "filepath.extension",
+      {
+          "name": "Name",
+          "description": "Description",
+          "multifile": "False",
+          "categories": [""],
+          "pipeline_options": "--option option"
+      })
 
   assert result == Example(
-    "filepath",
-    "",
-    SDK_UNSPECIFIED,
-    "/root/filepath.extension",
-    "data",
-    "",
-    STATUS_UNSPECIFIED,
-    Tag("Name", "Description", "False", [""]))
+      "filepath",
+      "",
+      SDK_UNSPECIFIED,
+      "/root/filepath.extension",
+      "data",
+      "",
+      STATUS_UNSPECIFIED,
+      Tag("Name", "Description", "False", [""], "--option option"))
   mock_get_name.assert_called_once_with("filepath.extension")
   mock_get_sdk.assert_called_once_with("filepath.extension")
 
@@ -213,30 +214,31 @@ def test__validate_without_categories_field():
 
 def test__validate_without_incorrect_categories_field():
   tag = {
-    "name": "Name",
-    "description": "Description",
-    "multifile": "true",
-    "categories": "Categories"
+      "name": "Name",
+      "description": "Description",
+      "multifile": "true",
+      "categories": "Categories"
   }
   assert _validate(tag, []) is False
 
 
 def test__validate_with_not_supported_category():
   tag = {
-    "name": "Name",
-    "description": "Description",
-    "multifile": "true",
-    "categories": ["category1"]
+      "name": "Name",
+      "description": "Description",
+      "multifile": "true",
+      "categories": ["category1"]
   }
   assert _validate(tag, ["category"]) is False
 
 
 def test__validate_with_all_fields():
   tag = {
-    "name": "Name",
-    "description": "Description",
-    "multifile": "true",
-    "categories": ["category"]
+      "name": "Name",
+      "description": "Description",
+      "multifile": "true",
+      "categories": ["category"],
+      "pipeline_options": "--option option"
   }
   assert _validate(tag, ["category"]) is True
 
@@ -264,17 +266,17 @@ def test__get_sdk_with_unsupported_extension():
 async def test__update_example_status(
     mock_grpc_client_run_code, mock_grpc_client_check_status):
   example = Example(
-    "file",
-    "pipeline_id",
-    SDK_UNSPECIFIED,
-    "root/file.extension",
-    "code",
-    "output",
-    STATUS_UNSPECIFIED, {"name": "Name"})
+      "file",
+      "pipeline_id",
+      SDK_UNSPECIFIED,
+      "root/file.extension",
+      "code",
+      "output",
+      STATUS_UNSPECIFIED, {"name": "Name"})
 
   mock_grpc_client_run_code.return_value = "pipeline_id"
   mock_grpc_client_check_status.side_effect = [
-    STATUS_VALIDATING, STATUS_FINISHED
+      STATUS_VALIDATING, STATUS_FINISHED
   ]
 
   await _update_example_status(example, GRPCClient())

Reply via email to