예제 #1
0
 def testFileAdler(self):
     """ fileAdler tests """
     # no args
     try:
         Adler.fileAdler()
     except Exception, error:
         self.assertEqual(isinstance(error, TypeError), True)
예제 #2
0
 def testFileAdler( self ):
   """ fileAdler tests """
   # no args
   try:
     Adler.fileAdler()
   except Exception, error:
     self.assertEqual( isinstance(error,TypeError ), True )
예제 #3
0
 def testFileAdler( self ):
   """ fileAdler tests """
   # no args
   try:
     Adler.fileAdler() #pylint: disable=no-value-for-parameter
   except Exception as error:
     self.assertEqual( isinstance(error,TypeError ), True )
   # read-protected file
   self.assertEqual( Adler.fileAdler( "/root/.login" ), False )
   # inexisting file
   self.assertEqual( Adler.fileAdler( "Stone/Dead/Norwegian/Blue/Parrot/In/Camelot" ), False )
   # normal operation
   fd, path  = tempfile.mkstemp("_adler32", "norewgian_blue")
   self.assertEqual( int(Adler.fileAdler( path )), int(self.emptyAdler) )
   os.write( fd,  string.letters )
   self.assertEqual( Adler.fileAdler( path ), self.lettersAdler )
예제 #4
0
 def testFileAdler(self):
     """fileAdler tests"""
     # no args
     try:
         Adler.fileAdler()  # pylint: disable=no-value-for-parameter
     except Exception as error:
         self.assertEqual(isinstance(error, TypeError), True)
     # read-protected file
     self.assertEqual(Adler.fileAdler("/root/.login"), False)
     # inexisting file
     self.assertEqual(Adler.fileAdler("Stone/Dead/Norwegian/Blue/Parrot/In/Camelot"), False)
     # normal operation
     fd, path = tempfile.mkstemp("_adler32", "norewgian_blue")
     self.assertEqual(int(Adler.fileAdler(path)), int(self.emptyAdler))
     os.write(fd, string.ascii_letters.encode())
     self.assertEqual(Adler.fileAdler(path), self.lettersAdler)
예제 #5
0
        self.assertEqual(Adler.intAdlerToHex("a"), False)
        # normal operation
        self.assertEqual(int(Adler.intAdlerToHex(1)),
                         Adler.hexAdlerToInt(Adler.intAdlerToHex(1)))
        self.assertEqual(Adler.hexAdlerToInt("0x01"),
                         int(Adler.intAdlerToHex(Adler.hexAdlerToInt("0x01"))))

    def testFileAdler(self):
        """ fileAdler tests """
        # no args
        try:
            Adler.fileAdler()
        except Exception, error:
            self.assertEqual(isinstance(error, TypeError), True)
        # read-protected file
        self.assertEqual(Adler.fileAdler("/root/.login"), False)
        # inexisting file
        self.assertEqual(
            Adler.fileAdler("Stone/Dead/Norwegian/Blue/Parrot/In/Camelot"),
            False)
        # normal operation
        fd, path = tempfile.mkstemp("_adler32", "norewgian_blue")
        self.assertEqual(int(Adler.fileAdler(path)), int(self.emptyAdler))
        os.write(fd, string.letters)
        self.assertEqual(Adler.fileAdler(path), self.lettersAdler)

    def testCompareAdler(self):
        """ compareAdler tests """
        # same adlers
        self.assertEqual(
            Adler.compareAdler(Adler.stringAdler(""), Adler.stringAdler("")),
예제 #6
0
    self.assertEqual( Adler.intAdlerToHex("a"), False )
    # normal operation
    self.assertEqual( int(Adler.intAdlerToHex(1)), 
                      Adler.hexAdlerToInt( Adler.intAdlerToHex(1) ) ) 
    self.assertEqual( Adler.hexAdlerToInt( "0x01" ),
                      int( Adler.intAdlerToHex( Adler.hexAdlerToInt( "0x01" ) ) ) )
  
  def testFileAdler( self ):
    """ fileAdler tests """
    # no args
    try:
      Adler.fileAdler()
    except Exception, error:
      self.assertEqual( isinstance(error,TypeError ), True )
    # read-protected file 
    self.assertEqual( Adler.fileAdler( "/root/.login" ), False )
    # inexisting file
    self.assertEqual( Adler.fileAdler( "Stone/Dead/Norwegian/Blue/Parrot/In/Camelot" ), False )
    # normal operation
    fd, path  = tempfile.mkstemp("_adler32", "norewgian_blue")
    self.assertEqual( int(Adler.fileAdler( path )), int(self.emptyAdler) )
    os.write( fd,  string.letters )
    self.assertEqual( Adler.fileAdler( path ), self.lettersAdler )
   
  def testCompareAdler( self ):
    """ compareAdler tests """
    # same adlers
    self.assertEqual( Adler.compareAdler( Adler.stringAdler(""), Adler.stringAdler("") ), True  )
    # diff adlers
    self.assertEqual( Adler.compareAdler( Adler.stringAdler(""), Adler.stringAdler( string.letters ) ), False )