alrolorojas commented on a change in pull request #6100: [AIRFLOW-5387] Fix 
show paused pagination bug
URL: https://github.com/apache/airflow/pull/6100#discussion_r325116240
 
 

 ##########
 File path: tests/www/test_utils.py
 ##########
 @@ -103,14 +105,45 @@ def test_params_search(self):
         self.assertEqual('search=bash_',
                          utils.get_params(search='bash_'))
 
-    def test_params_showPaused_true(self):
-        """Should detect True as default for showPaused"""
-        self.assertEqual('',
-                         utils.get_params(showPaused=True))
-
-    def test_params_showPaused_false(self):
-        self.assertEqual('showPaused=False',
-                         utils.get_params(showPaused=False))
+    @parameterized.expand([
+        (True, False, ''),
+        (False, True, ''),
+        (True, True, 'showPaused=True'),
+        (False, False, 'showPaused=False'),
+        (None, True, ''),
+        (None, False, ''),
+    ])
+    def test_params_showPaused(self, show_paused, hide_by_default, 
expected_result):
+        os.environ['AIRFLOW__WEBSERVER__HIDE_PAUSED_DAGS_BY_DEFAULT'] = 
str(hide_by_default)
+
+        try:
 
 Review comment:
   > Okay, but I mean why should self.assertEqual(expected_result, 
utils.get_params(showPaused=show_paused)) raise an error?
   Wouldn't..
   self.assertEqual(expected_result, utils.get_params(showPaused=show_paused))
   del os.environ['AIRFLOW__WEBSERVER__HIDE_PAUSED_DAGS_BY_DEFAULT']
   ..also work?
   
   @feluelle if for some reason `utils.get_params` method raises an exception, 
`del os.environ['AIRFLOW__WEBSERVER__HIDE_PAUSED_DAGS_BY_DEFAULT']` would not 
get executed leaving that environment variable enabled for other unit tests. 
That was a teardown that only applies to a single test.
   
   > Rather than setting the env var can you use the conf_vars context manager 
we use in other tests (check out ./tests/test_utils/config.py)
   
   @ashb I'm taking a look. Thanks for the pointer!

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to