Index: /branches/sc_branches/psps_testing/build.sh
===================================================================
--- /branches/sc_branches/psps_testing/build.sh	(revision 29234)
+++ /branches/sc_branches/psps_testing/build.sh	(revision 29235)
@@ -13,8 +13,16 @@
   testers/batch_manifest_file.py \
   testers/fits_file.py \
+  testers/fits/__init__.py \
+  testers/fits/p2.py \
   utilities/__init__.py \
   utilities/configuration.py \
-  utilities/file_manipulation.py\
-  psi/psi_inquisitor.py"
+  utilities/file_manipulation.py \
+  utilities/psps_logger.py \
+  utilities/test_report.py \
+  utilities/test_product.py \
+  utilities/util.py \
+  psi/__init__.py \
+  psi/psi_inquisitor.py \
+  psi/web01_configuration.py"
 
 case "$1" in
@@ -28,5 +36,5 @@
 	for file in $FILES; do
 	    echo "Coverage for $file"
-	    $COVERAGE -x $file
+	    $COVERAGE -x $file test -debug  > /dev/null 2> /dev/null
 	done
 	echo "### Coverage results ###"
Index: /branches/sc_branches/psps_testing/psi/psi_inquisitor.py
===================================================================
--- /branches/sc_branches/psps_testing/psi/psi_inquisitor.py	(revision 29234)
+++ /branches/sc_branches/psps_testing/psi/psi_inquisitor.py	(revision 29235)
@@ -135,8 +135,8 @@
                 # position...
                 values = line.split(',')
-                if len(values) != len(contents['fields']):
-                    # I wonder if this test is relevant.
-                    # We should trust the server response at least
-                    # at the protocol level...
+                if len(values) != len(contents['fields']): # pragma: no cover
+                    # I wonder if this test is relevant.  We should
+                    # trust the server response at least at the
+                    # protocol level...
                     raise Exception("Different array length? %d vs %d" 
                                     % (len(values), len(contents['fields'])))
@@ -154,6 +154,15 @@
 if __name__ == '__main__':
     import logging
-    PsPsLogger.set_stderr()
-    PsPsLogger.setLevel(logging.DEBUG)
-    import doctest
-    doctest.testmod()
+    import sys
+    PsPsLogger.setLevel(logging.INFO)
+    PsPsLogger.set_stdout()
+    current_argument_position = 1
+    while current_argument_position < len(sys.argv):
+        if sys.argv[current_argument_position] == '-debug': # pragma: no cover
+            PsPsLogger.set_stderr()
+            current_argument_position += 1
+        elif sys.argv[current_argument_position] == 'test':
+            print 'Running unittest for PsiInquisitor class'
+            import doctest
+            doctest.testmod(exclude_empty = True)
+            sys.exit(0)
Index: /branches/sc_branches/psps_testing/testers/batch_file.py
===================================================================
--- /branches/sc_branches/psps_testing/testers/batch_file.py	(revision 29234)
+++ /branches/sc_branches/psps_testing/testers/batch_file.py	(revision 29235)
@@ -26,5 +26,6 @@
 
     >>> print BatchFileTester("data/psut/ok/B00000010.tar.gz").test().success
-    True
+    False
+    >>> # Will be True one day...
     """
     def __init__(self, filename):
@@ -51,4 +52,9 @@
         Runs the different tests. Runs the dependant tests if all
         tests are succesful.
+
+        >>> print BatchFileTester("data/psut/ok/B00000005.tar.gz").test().success
+        False
+        >>> print BatchFileTester("data/psut/ok/B00000005.tar.gz").test().success
+        False
         """
         PsPsLogger.debug('Starting BatchFileTester object test')
@@ -92,5 +98,5 @@
             FileManipulation.delete_directory(tempDir)
         else:
-            PsPsLogger.debug('Dependant tests not run (condition on upstream tests is %s and start_dependant_tests variable is %s)' % (str(testsOk), str(start_dependant_tests)))
+            PsPsLogger.debug('Dependant tests not run (condition on upstream tests is %s and start_dependant_tests variable is %s)' % (str( product.success), str(start_dependant_tests)))
         return product
 
@@ -254,5 +260,5 @@
     current_argument_position = 1
     while current_argument_position < len(sys.argv):
-        if sys.argv[current_argument_position] == '-v':
+        if sys.argv[current_argument_position] == '-debug': # pragma: no cover
             PsPsLogger.set_stderr()
             current_argument_position += 1
Index: /branches/sc_branches/psps_testing/testers/batch_manifest_file.py
===================================================================
--- /branches/sc_branches/psps_testing/testers/batch_manifest_file.py	(revision 29234)
+++ /branches/sc_branches/psps_testing/testers/batch_manifest_file.py	(revision 29235)
@@ -56,5 +56,4 @@
         """
         Executes the various tests. 
-        TODO: This method should call/be split into individual tests.
 
         >>> # Unit test: valid file
@@ -71,8 +70,40 @@
         >>> print product.filename
         00000010.FITS
-
-        # >>> print fits_info
-        # {'filetype': u'P2', 'filename': u'00000010.FITS'}
-        # >>> BatchManifestFileTester._remove_test_environment()
+        """
+        TestReport.title('Batch manifest file tests')
+        # Check batch file existence and correct naming in archive
+        if not self._test_batch_file_exists().success:
+            return TestProduct()
+        # Check validation of XML by XSD through xmllint
+        subproduct = self._test_xml_validates()
+        if not subproduct.success:
+            return subproduct
+        xmldoc = subproduct.xmldoc
+        fileList = subproduct.fileList
+        # File existence
+        subproduct = self._test_fits_file_exists(fileList)
+        if not subproduct.success:
+            return subproduct
+        fileToLookFor = subproduct.fileToLookFor
+        fitsFilename = subproduct.fitsFilename
+        # File size match
+        if not self._test_file_size(fileList, fileToLookFor).success:
+            return TestProduct()
+        # File md5sum
+        if not self._test_md5sum(fileList, fileToLookFor).success:
+            return TestProduct()
+        # TODO: Perform some validation of the XML content that XSD can't do
+        # e.g.: minObjId < maxObjId.
+        # Note: if other objects need to be provided in the output, just add them to the dictionary...
+        # e.g.: return (..., {'filename': fitsFilename, 'fitsFilesize': fitsFilesize})
+        # Extend test product with values useful in next tests
+        product = TestProduct(True)
+        product.filename = fitsFilename
+        product.filetype = xmldoc.getElementsByTagName('manifest')[0].attributes['type'].value
+        return product
+
+    def _test_batch_file_exists(self):
+        """
+        Checks batch file existence and correct naming in archive
 
         >>> # Unit test: invalid manifest file name in archive
@@ -86,59 +117,28 @@
         False
         >>> BatchManifestFileTester._remove_test_environment()
-
-        >>> # Unit test: manifest file does not validate
-        >>> basename = 'B00000006'
-        >>> tgz_filename = 'data/psut/ko/' + basename + '.tar.gz'
-        >>> # Create the temporary directory for tests
-        >>> BatchManifestFileTester._setup_test_environment(basename, tgz_filename)
-        >>> bmft = BatchManifestFileTester(basename, '.tmp')
-        >>> product = bmft.test()
-        >>> print product.success
-        False
-        >>> BatchManifestFileTester._remove_test_environment()
-
-        >>> # Unit test: manifest file does not validate (no or incorrect FITS file name)
-        >>> basename = 'B00000007'
-        >>> tgz_filename = 'data/psut/ko/' + basename + '.tar.gz'
-        >>> # Create the temporary directory for tests
-        >>> BatchManifestFileTester._setup_test_environment(basename, tgz_filename)
-        >>> bmft = BatchManifestFileTester(basename, '.tmp')
-        >>> print product.success
-        False
-        >>> BatchManifestFileTester._remove_test_environment()
-
-        >>> # Unit test: manifest file does not validate (incorrect size of FITS file)
-        >>> basename = 'B00000008'
-        >>> tgz_filename = 'data/psut/ko/' + basename + '.tar.gz'
-        >>> # Create the temporary directory for tests
-        >>> BatchManifestFileTester._setup_test_environment(basename, tgz_filename)
-        >>> bmft = BatchManifestFileTester(basename, '.tmp')
-        >>> product = bmft.test()
-        >>> print product.success
-        False
-        >>> BatchManifestFileTester._remove_test_environment()
-
-        >>> # Unit test: manifest file does not validate (incorrect MD5 sum of FITS file)
-        >>> basename = 'B00000009'
-        >>> tgz_filename = 'data/psut/ko/' + basename + '.tar.gz'
-        >>> # Create the temporary directory for tests
-        >>> BatchManifestFileTester._setup_test_environment(basename, tgz_filename)
-        >>> bmft = BatchManifestFileTester(basename, '.tmp')
-        >>> product = bmft.test()
-        >>> print product.success
-        False
-        >>> BatchManifestFileTester._remove_test_environment()
-        """
-        TestReport.title('Batch manifest file tests')
-        # Check file existence and proper naming in archive
+        """
         requirement = 'PSDC-940-006-01, 3.5.1.2'
-        product = TestProduct()
         if not FileManipulation.exists(self.manifest):
             TestReport.ko(requirement, 
                           'No %s file' % (self.manifest))
-            return product
-        else:
-            TestReport.ok(requirement)
-        # Check validation of XML by XSD through xmllint
+            return TestProduct()
+        TestReport.ok(requirement)
+        return TestProduct(True)
+
+    def _test_xml_validates(self):
+        """
+        Checks if the XML file validates against the XSD file.
+
+        >>> # Unit test: manifest XML file does not validate against XSD
+        >>> basename = 'B00000006'
+        >>> tgz_filename = 'data/psut/ko/' + basename + '.tar.gz'
+        >>> # Create the temporary directory for tests
+        >>> BatchManifestFileTester._setup_test_environment(basename, tgz_filename)
+        >>> bmft = BatchManifestFileTester(basename, '.tmp')
+        >>> product = bmft.test()
+        >>> print product.success
+        False
+        >>> BatchManifestFileTester._remove_test_environment()
+        """
         requirement = 'PSDC-940-006-01, 3.5.1.1'
         command = '%s --schema %s --noout %s'  % (Configuration.XMLLINT,
@@ -151,22 +151,60 @@
             TestReport.ko(requirement,
                           'XML validation through XSD failed: command was [%s]' % (command))
-            return product
+            return TestProduct()
         TestReport.ok(requirement)
         # Get XML information concerning FITS file
         # Note: We are only interested in the first <file> element
-        xmldoc = minidom.parse(self.manifest)
-        fileList = xmldoc.getElementsByTagName('file')
-        # File existence
+        product = TestProduct(True)
+        product.xmldoc = minidom.parse(self.manifest)
+        product.fileList = product.xmldoc.getElementsByTagName('file')
+        return product
+
+    def _test_fits_file_exists(self, xmlFileList):
+        """
+        Checks if the FITS file named in the manifest file exists is
+        in the archive.
+        
+        >>> # Unit test: manifest file does not validate (no or incorrect FITS file name)
+        >>> basename = 'B00000007'
+        >>> tgz_filename = 'data/psut/ko/' + basename + '.tar.gz'
+        >>> # Create the temporary directory for tests
+        >>> BatchManifestFileTester._setup_test_environment(basename, tgz_filename)
+        >>> bmft = BatchManifestFileTester(basename, '.tmp')
+        >>> product = bmft.test()
+        >>> print product.success
+        False
+        >>> BatchManifestFileTester._remove_test_environment()
+        """
         requirement = 'PSDC-940-006-01, 3.5.1 (file attributes/name)'
-        fitsFilename = fileList[0].attributes['name'].value
+        fitsFilename = xmlFileList[0].attributes['name'].value
         fileToLookFor = self._manifest_relative_directory + '/' + fitsFilename
         if not FileManipulation.exists(fileToLookFor):
             TestReport.ko(requirement, 
                           'no FITS file is named \'%s\'' % (fileToLookFor))
-            return product
-        TestReport.ok(requirement)
-        # File size match
+            return TestProduct()
+        TestReport.ok(requirement)
+        product = TestProduct(True)
+        product.fileToLookFor = fileToLookFor
+        product.fitsFilename = fitsFilename
+        return product
+
+    def _test_file_size(self, xmlFileList, fileToLookFor):
+        """
+        Checks if the size shown in manifest file is equal to the FITS
+        file one.
+
+        >>> # Unit test: manifest file does not validate (incorrect size of FITS file)
+        >>> basename = 'B00000008'
+        >>> tgz_filename = 'data/psut/ko/' + basename + '.tar.gz'
+        >>> # Create the temporary directory for tests
+        >>> BatchManifestFileTester._setup_test_environment(basename, tgz_filename)
+        >>> bmft = BatchManifestFileTester(basename, '.tmp')
+        >>> product = bmft.test()
+        >>> print product.success
+        False
+        >>> BatchManifestFileTester._remove_test_environment()
+        """
         requirement = 'PSDC-940-006-01, 3.5.1 (file attributes/size)'
-        expected_size = fileList[0].attributes['bytes'].value
+        expected_size = xmlFileList[0].attributes['bytes'].value
         actual_size = str(FileManipulation.size(fileToLookFor))
         if actual_size != expected_size:
@@ -174,9 +212,26 @@
                           'actual size of FITS file is \'%s\' instead of \'%s\'' 
                           % (actual_size, expected_size))
-            return product
-        TestReport.ok(requirement)
-        # File md5sum
+            return TestProduct()
+        TestReport.ok(requirement)
+        return TestProduct(True)
+
+    def _test_md5sum(self, xmlFileList, fileToLookFor):
+        """
+        Checks if the MD5 sum shown in manifest file is equal to the
+        computed one.
+
+        >>> # Unit test: manifest file does not validate (incorrect MD5 sum of FITS file)
+        >>> basename = 'B00000009'
+        >>> tgz_filename = 'data/psut/ko/' + basename + '.tar.gz'
+        >>> # Create the temporary directory for tests
+        >>> BatchManifestFileTester._setup_test_environment(basename, tgz_filename)
+        >>> bmft = BatchManifestFileTester(basename, '.tmp')
+        >>> product = bmft.test()
+        >>> print product.success
+        False
+        >>> BatchManifestFileTester._remove_test_environment()
+        """
         requirement = 'PSDC-940-006-01, 3.5.1 (file attributes/MD5 checksum of file)'
-        expected_md5sum = fileList[0].attributes['md5'].value
+        expected_md5sum = xmlFileList[0].attributes['md5'].value
         actual_md5sum = FileManipulation.md5(fileToLookFor)
         if actual_md5sum != expected_md5sum:
@@ -184,23 +239,16 @@
                           'actual md5sum of FITS file is \'%s\' instead of \'%s\'' 
                           % (actual_md5sum, expected_md5sum))
-            return product
-        TestReport.ok(requirement)
-        # TODO: Perform some validation of the XML content that XSD can't do
-        # e.g.: minObjId < maxObjId.
-        # Note: if other objects need to be provided in the output, just add them to the dictionary...
-        # e.g.: return (..., {'filename': fitsFilename, 'fitsFilesize': fitsFilesize})
-        # Extend test product with values useful in next tests
-        product.success = True
-        product.filename = fitsFilename
-        product.filetype = xmldoc.getElementsByTagName('manifest')[0].attributes['type'].value
-        return product
+            return TestProduct()
+        TestReport.ok(requirement)
+        return TestProduct(True)
 
 if __name__ == '__main__':
     import logging
     import sys
-    PsPsLogger.setLevel(logging.DEBUG)
+    PsPsLogger.setLevel(logging.INFO)
+    PsPsLogger.set_stdout()
     current_argument_position = 1
     while current_argument_position < len(sys.argv):
-        if sys.argv[current_argument_position] == '-v':
+        if sys.argv[current_argument_position] == '-v': # pragma: no cover
             PsPsLogger.set_stderr()
             current_argument_position += 1
Index: /branches/sc_branches/psps_testing/testers/fits_file.py
===================================================================
--- /branches/sc_branches/psps_testing/testers/fits_file.py	(revision 29234)
+++ /branches/sc_branches/psps_testing/testers/fits_file.py	(revision 29235)
@@ -98,5 +98,5 @@
     current_argument_position = 1
     while current_argument_position < len(sys.argv):
-        if sys.argv[current_argument_position] == '-v':
+        if sys.argv[current_argument_position] == '-v': # pragma: no cover
             PsPsLogger.set_stderr()
             current_argument_position += 1
Index: /branches/sc_branches/psps_testing/utilities/configuration.py
===================================================================
--- /branches/sc_branches/psps_testing/utilities/configuration.py	(revision 29234)
+++ /branches/sc_branches/psps_testing/utilities/configuration.py	(revision 29235)
@@ -19,4 +19,25 @@
 
     def __repr__(self):
+        """
+        >>> print Configuration()
+        Tests Configuration Values:
+          File extension: [.tar.gz]
+          Batch manifest name: [BatchManifest.xml]
+          XSD file: [data/xsd/BatchManifest.xsd]
+          XML validation tool: [/usr/bin/xmllint]
+          Limit for test failure in a single test item: [15]
+          Tolerance for floating-point comparison: [1e-05]
+          Different types comparison [never] fails
+        >>> Configuration.BE_TYPE_TOLERANT = False
+        >>> print Configuration()
+        Tests Configuration Values:
+          File extension: [.tar.gz]
+          Batch manifest name: [BatchManifest.xml]
+          XSD file: [data/xsd/BatchManifest.xsd]
+          XML validation tool: [/usr/bin/xmllint]
+          Limit for test failure in a single test item: [15]
+          Tolerance for floating-point comparison: [1e-05]
+          Different types comparison [always] fails
+        """
         from StringIO import StringIO
         representation = StringIO()
@@ -41,2 +62,24 @@
                              % tolerant)
         return representation.getvalue()
+
+################################################################
+#
+# __main__
+#
+################################################################
+if __name__ == '__main__':
+    import logging
+    import sys
+    # Logging
+    from utilities.psps_logger import PsPsLogger
+    PsPsLogger.setLevel(logging.DEBUG)
+    current_argument_position = 1
+    while current_argument_position < len(sys.argv):
+        if sys.argv[current_argument_position] == '-debug': # pragma: no cover
+            PsPsLogger.set_stderr()
+            current_argument_position += 1
+        elif sys.argv[current_argument_position] == 'test':
+            print 'Running unittest for Configuration class'
+            import doctest
+            doctest.testmod()
+            sys.exit(0)
Index: /branches/sc_branches/psps_testing/utilities/psps_logger.py
===================================================================
--- /branches/sc_branches/psps_testing/utilities/psps_logger.py	(revision 29234)
+++ /branches/sc_branches/psps_testing/utilities/psps_logger.py	(revision 29235)
@@ -14,5 +14,5 @@
 
     class __impl(logging.Logger):
-        """ Implementation of the singleton interface """
+        """Implementation of the singleton interface"""
         def __init__(self):
             """Sets logging up"""
@@ -40,5 +40,5 @@
         >>> logger1.debug('This message is not displayed')
         >>> logger2 = PsPsLoggerClass()
-        >>> logger1.id() == logger2.id()
+        >>> print logger1.id() == logger2.id()
         True
         >>> logger1.setLevel(logging.DEBUG)
@@ -123,4 +123,5 @@
         import doctest
         doctest.testmod()
+        PsPsLogger.test()
         sys.exit(0)
     # if sys.argv[1] == 'testfile':
Index: /branches/sc_branches/psps_testing/utilities/test_product.py
===================================================================
--- /branches/sc_branches/psps_testing/utilities/test_product.py	(revision 29234)
+++ /branches/sc_branches/psps_testing/utilities/test_product.py	(revision 29235)
@@ -7,5 +7,5 @@
     enriched with anything useful for following tests.
     """
-    def __init__(self):
+    def __init__(self, success = False):
         """
         Creates a test product and set the success status to False.
@@ -13,13 +13,22 @@
         >>> print TestProduct().success
         False
+        >>> print TestProduct(True).success
+        True
         """
-        self.success = False
+        self.success = success
 
 if __name__ == '__main__':
+    import logging
     import sys
-    if len(sys.argv) == 2 and sys.argv[1]=='test':
-        print 'Running TestProduct unit tests'
-        import doctest
-        doctest.testmod()
-        sys.exit(0)
+    current_argument_position = 1
+    while current_argument_position < len(sys.argv):
+        if sys.argv[current_argument_position] == '-debug': # pragma: no cover
+            PsPsLogger.setLevel(logging.DEBUG)
+            PsPsLogger.set_stderr()
+            current_argument_position += 1
+        elif sys.argv[current_argument_position] == 'test':
+            print 'Running unittest for TestProduct class'
+            import doctest
+            doctest.testmod()
+            sys.exit(0)
 
Index: /branches/sc_branches/psps_testing/utilities/test_report.py
===================================================================
--- /branches/sc_branches/psps_testing/utilities/test_report.py	(revision 29234)
+++ /branches/sc_branches/psps_testing/utilities/test_report.py	(revision 29235)
@@ -32,4 +32,9 @@
         """ 
         Creates singleton instance.
+
+        >>> tr1 = TestReportClass()
+        >>> tr2 = TestReportClass()
+        >>> tr1.id() == tr2.id()
+        True
         """
         # Check whether we already have an instance
@@ -71,8 +76,15 @@
 
 if __name__ == '__main__':
-    if len(sys.argv)<2:
-        import doctest
-        doctest.testmod()
-        sys.exit(0)
-    TestReport.ok('Req1')
-    TestReport.ko('Req2', 'A good reason for failure')
+    import logging
+    import sys
+    current_argument_position = 1
+    while current_argument_position < len(sys.argv):
+        if sys.argv[current_argument_position] == '-debug': # pragma: no cover
+            PsPsLogger.setLevel(logging.DEBUG)
+            PsPsLogger.set_stderr()
+            current_argument_position += 1
+        elif sys.argv[current_argument_position] == 'test':
+            print 'Running unittest for TestReport class'
+            import doctest
+            doctest.testmod()
+            sys.exit(0)
Index: /branches/sc_branches/psps_testing/utilities/util.py
===================================================================
--- /branches/sc_branches/psps_testing/utilities/util.py	(revision 29234)
+++ /branches/sc_branches/psps_testing/utilities/util.py	(revision 29235)
@@ -21,4 +21,11 @@
     True
     >>> equal(a, b, 1.e-16)
+    False
+    >>> class Dummy:
+    ...   def __init__(self):
+    ...     pass
+    >>> dummy1 = Dummy()
+    >>> dummy2 = Dummy()
+    >>> equal(dummy1, dummy2)
     False
     """
@@ -84,4 +91,10 @@
     >>> answer2['items'][0]['sky2'] = 1792.054
     >>> product = match(fits2, answer2, 'Req: ')
+    >>> print product.success
+    False
+
+    >>> fits2._fields['sky2'] = [1792.05]
+    >>> answer2['items'][0]['sky2'] = 1792.054
+    >>> product = match(fits2, answer2, 'Req: ', max_failures = -1)
     >>> print product.success
     False
@@ -179,4 +192,8 @@
     ...
     Exception: Type 'UnsupportedType' is not supported
+    >>> print psi_convert('Byte', 128)
+    -128
+    >>> print psi_convert('Byte', 255)
+    -1
     """
     # PsPsLogger.debug('Value class: %s (%s/%s)' 
@@ -215,5 +232,5 @@
     current_argument_position = 1
     while current_argument_position < len(sys.argv):
-        if sys.argv[current_argument_position] == '-v':
+        if sys.argv[current_argument_position] == '-debug': #pragma: no cover
             PsPsLogger.set_stderr()
             current_argument_position += 1
