<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE stax SYSTEM "stax.dtd">

<stax>

  <defaultcall function="Main"/>

  <function name="Main">
    <testcase name="'Scenario XYZ'">
      <sequence>

        <script>
          # Set to the machine where the manual test should be displayed
          testMach = 'local'     

          # Set to the machine where the MTS service is running
          serviceMach = 'local'  

          manualTestName = 'Scenario XYZ'
          manualTestTitle = 'Scenario XYZ CD Verification Title'
          manualTestDesc = 'Scenario XYZ CD Verification Manual Sequence'

          step1 = ManualTestChoice(
                  'Select the platform you are running this test on:',
                  ['AIX', 'HP/UX', 'Linux', 'Solaris', 'Windows 2000', 'other'])

          step2 = ManualTestEntry('Enter your name:')
  
          step3 = ManualTestInstruction(
          """Enter this command:
            mount /cdrom (if Unix/Linux)
          OR
            do nothing (if Windows)""")

          step4 = ManualTestEntry(
                  'Paste the output from the above command into this field:')

          step5 = ManualTestDecision(
                  'Are there any files present other than those listed above?')
       
          stepList = [step1, step2, step3, step4, step5]
        </script>

        <call function="'RunManualTest'">
           { 'name': manualTestName, 'testMach': testMach,
             'title': manualTestTitle, 'description': manualTestDesc,
             'serviceMach': serviceMach, 'stepList': stepList } 
        </call>
  
      </sequence>
    </testcase>
  </function>

  <function name="RunManualTest" scope="local">

    <function-map-args>
      <function-required-arg name="name"/>
      <function-required-arg name="testMach"/>
      <function-required-arg name="title"/>
      <function-required-arg name="description"/>
      <function-required-arg name="stepList"/>
      <function-optional-arg name="serviceMach" default="'local'"/>
    </function-map-args>

    <block name="'Manual Test %s on Machine %s' % (name, testMach)">
      <sequence>

        <message>
          'Starting manual test %s on machine %s' % \
            (manualTestName, testMach)
        </message>

        <manual-test name="manualTestName" title = "title"
                     machine="testMach" servicemachine="serviceMach">
 
          <manual-test-description>description</manual-test-description>

          <manual-test-step-list>stepList</manual-test-step-list>

        </manual-test>

        <if expr="RC == 0">
          <sequence>

            <script>
              # Check if all steps were checked and if all expected
              # input was provided
              theResults = manualTestCheckResults(STAXResult)
              [manualTestRC, unCheckedStepList, unAnsweredStepList] = theResults

              if manualTestRC == 0:
                result = 'pass'
                msg = ("""Manual Test %s on machine %s completed successfully.
                       STAXResult=%s""" % (manualTestName, testMach, STAXResult))
              else:
                result = 'fail'
                msg = 'Manual Test %s on machine %s' % (manualTestName, testMach)
                msg = '%s has unchecked and/or unanswered steps:\n' % (msg)
                if len(unCheckedStepList) != 0:
                  msg = '%s  Unchecked step list:  %s\n' % (msg, unCheckedStepList)
                if len(unAnsweredStepList) != 0:
                  msg = '%s  Unanswered step list: %s\n' % (msg, unAnsweredStepList)
                msg = '%s  STAXResult: %s' % (msg, STAXResult)
            </script>

            <tcstatus result="result">msg</tcstatus>

            <message>msg</message>

          </sequence>

          <else>
            <tcstatus result="'fail'">
              ("""Manual Test %s on machine %s failed with RC=%s STAFResult=%s""" % \
                (manualTestName, testMach, RC, STAFResult))
            </tcstatus>
          </else>

        </if>

      </sequence>
    </block>
  </function>

</stax>