mik-laj commented on a change in pull request #8535:
URL: https://github.com/apache/airflow/pull/8535#discussion_r419217277



##########
File path: tests/cli/commands/test_variable_command.py
##########
@@ -31,58 +34,38 @@ def setUpClass(cls):
         cls.dagbag = models.DagBag(include_examples=True)
         cls.parser = cli_parser.get_parser()
 
-    def test_variables(self):
-        # Checks if all subcommands are properly received
+    def setUp(self):
+        clear_db_variables()
+
+    def tearDown(self):
+        clear_db_variables()
+
+    def test_variables_set(self):
+        """Test variable_set command"""
+        variable_command.variables_set(self.parser.parse_args([
+            'variables', 'set', 'foo', 'bar']))
+        self.assertIsNotNone(Variable.get("foo"))
+        self.assertRaises(KeyError, Variable.get, "foo1")
+
+    @unittest.mock.patch('sys.stdout', new_callable=io.StringIO)
+    def test_variables_get(self, mock_stdout):
+        """"Test variable_get command"""
+        # Test conventional get call
         variable_command.variables_set(self.parser.parse_args([
             'variables', 'set', 'foo', '{"foo":"bar"}']))
         variable_command.variables_get(self.parser.parse_args([
             'variables', 'get', 'foo']))
         variable_command.variables_get(self.parser.parse_args([
             'variables', 'get', 'baz', '--default', 'bar']))
-        variable_command.variables_list(self.parser.parse_args([
-            'variables', 'list']))
-        variable_command.variables_delete(self.parser.parse_args([
-            'variables', 'delete', 'bar']))
-        variable_command.variables_import(self.parser.parse_args([
-            'variables', 'import', os.devnull]))
-        variable_command.variables_export(self.parser.parse_args([
-            'variables', 'export', os.devnull]))
-
-        variable_command.variables_set(self.parser.parse_args([
-            'variables', 'set', 'bar', 'original']))
-        # First export
-        variable_command.variables_export(self.parser.parse_args([
-            'variables', 'export', 'variables1.json']))
-
-        first_exp = open('variables1.json', 'r')
-
-        variable_command.variables_set(self.parser.parse_args([
-            'variables', 'set', 'bar', 'updated']))
-        variable_command.variables_set(self.parser.parse_args([
-            'variables', 'set', 'foo', '{"foo":"oops"}']))
-        variable_command.variables_delete(self.parser.parse_args([
-            'variables', 'delete', 'foo']))
-        # First import
-        variable_command.variables_import(self.parser.parse_args([
-            'variables', 'import', 'variables1.json']))
-
-        self.assertEqual('original', Variable.get('bar'))
-        self.assertEqual('{\n  "foo": "bar"\n}', Variable.get('foo'))
-        # Second export
-        variable_command.variables_export(self.parser.parse_args([
-            'variables', 'export', 'variables2.json']))
+        self.assertEqual(mock_stdout.getvalue(), 'bar\n')

Review comment:
       This assertion failing on master, because this PR introduced unrelated 
change: https://github.com/apache/airflow/pull/8640/files
   
   Here is my fix: https://github.com/apache/airflow/pull/8698
   Can you do the review?




----------------------------------------------------------------
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


Reply via email to