Пример #1
0
  def test01ctors(self):
    """ File construction and (de)serialisation """
    # # empty default ctor
    theFile = File()
    self.assertEqual(isinstance(theFile, File), True)

    # # fromDict
    try:
      theFile = File(self.fromDict)
    except AttributeError as error:
      print("AttributeError: %s" % str(error))

    self.assertEqual(isinstance(theFile, File), True)
    for key, value in self.fromDict.items():
      self.assertEqual(getattr(theFile, key), value)

    toJSON = theFile.toJSON()
    self.assertEqual(toJSON["OK"], True, "JSON serialization error")
Пример #2
0
def test_ctors():
    """File construction and (de)serialisation"""
    theFile = File()
    assert isinstance(theFile, File)

    fromDict = {
        "Size": 1,
        "LFN": "/test/lfn",
        "ChecksumType": "ADLER32",
        "Checksum": "123456",
        "Status": "Waiting",
    }
    try:
        theFile = File(fromDict)
    except AttributeError as error:
        print("AttributeError: %s" % str(error))

    assert isinstance(theFile, File)
    for key, value in fromDict.items():
        assert getattr(theFile, key) == value

    toJSON = theFile.toJSON()
    assert toJSON["OK"], "JSON serialization error"