jedcunningham commented on code in PR #45507:
URL: https://github.com/apache/airflow/pull/45507#discussion_r1913794560


##########
tests/cli/commands/remote_commands/test_dag_command.py:
##########
@@ -99,30 +98,43 @@ def test_reserialize(self, session):
         dag_version_after_command = session.query(DagVersion).all()
         assert len(dag_version_after_command)
 
-    @pytest.mark.skip("AIP-66: reserialize is not implemented yet")
-    def test_reserialize_should_support_subdir_argument(self, session):
+    def test_reserialize_should_support_bundle_name_argument(self, 
configure_testing_dag_bundle, session):
         # Run clear of serialized dags
         session.query(DagVersion).delete()
 
         # Assert no serialized Dags
         serialized_dags_after_clear = session.query(SerializedDagModel).all()
         assert len(serialized_dags_after_clear) == 0
 
-        # Serialize manually
-        dag_path = self.dagbag.dags["example_bash_operator"].fileloc
-        # Set default value of include_examples parameter to false
-        dagbag_default = list(DagBag.__init__.__defaults__)
-        dagbag_default[1] = False
-        with mock.patch(
-            
"airflow.cli.commands.remote_commands.dag_command.DagBag.__init__.__defaults__",
-            tuple(dagbag_default),
-        ):
-            dag_command.dag_reserialize(self.parser.parse_args(["dags", 
"reserialize", "--subdir", dag_path]))
+        path_to_parse = TEST_DAGS_FOLDER / "test_dag_with_no_tags.py"
+
+        with configure_testing_dag_bundle(path_to_parse):
+            dag_command.dag_reserialize(
+                self.parser.parse_args(["dags", "reserialize", 
"--bundle-name", "testing"])
+            )
 
         # Check serialized DAG are back
         serialized_dags_after_reserialize = 
session.query(SerializedDagModel).all()
         assert len(serialized_dags_after_reserialize) == 1  # Serialized DAG 
back
 
+    def test_reserialize_should_support_more_than_one_bundle(self, 
configure_testing_dag_bundle, session):
+        # Run clear of serialized dags
+        session.query(DagVersion).delete()
+
+        # Assert no serialized Dags
+        serialized_dags_after_clear = session.query(SerializedDagModel).all()
+        assert len(serialized_dags_after_clear) == 0
+
+        path_to_parse = TEST_DAGS_FOLDER / "test_dag_with_no_tags.py"
+
+        with configure_testing_dag_bundle(path_to_parse):
+            dag_command.dag_reserialize(self.parser.parse_args(["dags", 
"reserialize"]))
+
+        # Check serialized DAG are back
+        serialized_dags_after_reserialize = 
session.query(SerializedDagModel).all()
+        assert len(serialized_dags_after_reserialize) > 1
+        assert "test_dag_with_no_tags" in [dag.dag_id for dag in 
serialized_dags_after_reserialize]

Review Comment:
   ```suggestion
           serialized_dag_ids = [dag.dag_id for dag in 
serialized_dags_after_reserialize]
           assert "test_dag_with_no_tags" in serialized_dag_ids
           assert "example_bash_operator" in serialized_dag_ids
   ```
   
   Let's check a known example dag_id is in there too.



##########
tests/cli/commands/remote_commands/test_dag_command.py:
##########
@@ -99,30 +98,43 @@ def test_reserialize(self, session):
         dag_version_after_command = session.query(DagVersion).all()
         assert len(dag_version_after_command)
 
-    @pytest.mark.skip("AIP-66: reserialize is not implemented yet")
-    def test_reserialize_should_support_subdir_argument(self, session):
+    def test_reserialize_should_support_bundle_name_argument(self, 
configure_testing_dag_bundle, session):
         # Run clear of serialized dags
         session.query(DagVersion).delete()
 
         # Assert no serialized Dags
         serialized_dags_after_clear = session.query(SerializedDagModel).all()
         assert len(serialized_dags_after_clear) == 0
 
-        # Serialize manually
-        dag_path = self.dagbag.dags["example_bash_operator"].fileloc
-        # Set default value of include_examples parameter to false
-        dagbag_default = list(DagBag.__init__.__defaults__)
-        dagbag_default[1] = False
-        with mock.patch(
-            
"airflow.cli.commands.remote_commands.dag_command.DagBag.__init__.__defaults__",
-            tuple(dagbag_default),
-        ):
-            dag_command.dag_reserialize(self.parser.parse_args(["dags", 
"reserialize", "--subdir", dag_path]))
+        path_to_parse = TEST_DAGS_FOLDER / "test_dag_with_no_tags.py"
+
+        with configure_testing_dag_bundle(path_to_parse):
+            dag_command.dag_reserialize(
+                self.parser.parse_args(["dags", "reserialize", 
"--bundle-name", "testing"])
+            )
 
         # Check serialized DAG are back
         serialized_dags_after_reserialize = 
session.query(SerializedDagModel).all()
         assert len(serialized_dags_after_reserialize) == 1  # Serialized DAG 
back
 
+    def test_reserialize_should_support_more_than_one_bundle(self, 
configure_testing_dag_bundle, session):
+        # Run clear of serialized dags
+        session.query(DagVersion).delete()
+
+        # Assert no serialized Dags
+        serialized_dags_after_clear = session.query(SerializedDagModel).all()
+        assert len(serialized_dags_after_clear) == 0
+
+        path_to_parse = TEST_DAGS_FOLDER / "test_dag_with_no_tags.py"
+
+        with configure_testing_dag_bundle(path_to_parse):
+            dag_command.dag_reserialize(self.parser.parse_args(["dags", 
"reserialize"]))

Review Comment:
   Might be worth leaving a comment that examples DAGs are on. Took me a minute 
to figure out why it'd work.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to