old_contents: # Copyright 2019 Red Hat, Inc.
  #
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  #
  #     http://www.apache.org/licenses/LICENSE-2.0
  #
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # 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.
  """
  Tests of the stratis CLI.
  """
  
  import argparse
  import sys
  import time
  import unittest
  
  from testlib.utils import exec_command, process_exists
  from testlib.stratis import StratisCli, clean_up
  
  DISKS = []
  
  
  class StratisCertify(unittest.TestCase):
      """
      Unit tests for Stratis
      """
  
      def setUp(self):
          """
          Setup for an individual test.
          * Register a cleanup action, to be run if the test fails.
          * Ensure that stratisd is running via systemd.
          * Use the running stratisd instance to destroy any existing
          Stratis filesystems, pools, etc.
          :return: None
          """
          self.addCleanup(clean_up)
  
          if process_exists("stratisd") is None:
              exec_command(["systemctl", "start", "stratisd"])
              time.sleep(20)
  
          StratisCli.destroy_all()
          assert StratisCli.pool_list() == []
  
  
  if __name__ == "__main__":
      ARGUMENT_PARSER = argparse.ArgumentParser()
      ARGUMENT_PARSER.add_argument(
          "--disk", action="append", dest="DISKS", help="disks to use", required=True
      )
      PARSED_ARGS, OTHER_ARGS = ARGUMENT_PARSER.parse_known_args()
      DISKS = PARSED_ARGS.DISKS
      print("Using block device(s) for tests: %s" % DISKS)
      unittest.main(argv=sys.argv[:1] + OTHER_ARGS)
  
new_contents: # Copyright 2019 Red Hat, Inc.
  #
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  #
  #     http://www.apache.org/licenses/LICENSE-2.0
  #
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # 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.
  """
  Tests of the stratis CLI.
  """
  
  import argparse
  import sys
  import time
  import unittest
  
  from testlib.utils import exec_command, exec_test_command, process_exists
  from testlib.stratis import STRATIS_CLI, StratisCli, clean_up
  
  DISKS = []
  
  
  class StratisCertify(unittest.TestCase):
      """
      Unit tests for Stratis
      """
  
      def setUp(self):
          """
          Setup for an individual test.
          * Register a cleanup action, to be run if the test fails.
          * Ensure that stratisd is running via systemd.
          * Use the running stratisd instance to destroy any existing
          Stratis filesystems, pools, etc.
          :return: None
          """
          self.addCleanup(clean_up)
  
          if process_exists("stratisd") is None:
              exec_command(["systemctl", "start", "stratisd"])
              time.sleep(20)
  
          StratisCli.destroy_all()
          assert StratisCli.pool_list() == []
  
      def test_stratisd_version(self):
          """
          Test getting the daemon version.
          """
          exit_code, stdout, stderr = exec_test_command(
              [STRATIS_CLI, "daemon", "version"]
          )
          self.assertEqual(exit_code, 0)
          self.assertEqual(stderr, "")
          self.assertNotEqual(stdout, "")
  
  
  if __name__ == "__main__":
      ARGUMENT_PARSER = argparse.ArgumentParser()
      ARGUMENT_PARSER.add_argument(
          "--disk", action="append", dest="DISKS", help="disks to use", required=True
      )
      PARSED_ARGS, OTHER_ARGS = ARGUMENT_PARSER.parse_known_args()
      DISKS = PARSED_ARGS.DISKS
      print("Using block device(s) for tests: %s" % DISKS)
      unittest.main(argv=sys.argv[:1] + OTHER_ARGS)
  
subject: Add a test for getting the daemon version in the stratis-cli