Exemple #1
0
    def test02props(self):
        """ test properties """

        # # valid values
        operation = Operation()

        operation.Arguments = "foobar"
        self.assertEqual(operation.Arguments, "foobar", "wrong Arguments")

        operation.SourceSE = "CERN-RAW"
        self.assertEqual(operation.SourceSE, "CERN-RAW", "wrong SourceSE")

        operation.TargetSE = "CERN-RAW"
        self.assertEqual(operation.TargetSE, "CERN-RAW", "wrong TargetSE")

        operation.Catalog = ""
        self.assertEqual(operation.Catalog, "", "wrong Catalog")

        operation.Catalog = "BookkeepingDB"
        self.assertEqual(operation.Catalog, "BookkeepingDB", "wrong Catalog")

        operation.Error = "error"
        self.assertEqual(operation.Error, "error", "wrong Error")

        # # wrong props
        try:
            operation.RequestID = "foo"
        except Exception as error:
            self.assertEqual(type(error), AttributeError, "wrong exc raised")
            self.assertEqual(str(error), "can't set attribute",
                             "wrong exc reason")

        try:
            operation.OperationID = "foo"
        except Exception as error:
            self.assertEqual(type(error), ValueError, "wrong exc raised")

        # # timestamps
        try:
            operation.SubmitTime = "foo"
        except Exception as error:
            self.assertEqual(type(error), ValueError, "wrong exp raised")
            self.assertEqual(
                str(error),
                "time data 'foo' does not match format '%Y-%m-%d %H:%M:%S'",
                "wrong exc reason")

        try:
            operation.LastUpdate = "foo"
        except Exception as error:
            self.assertEqual(type(error), ValueError, "wrong exc raised")
            self.assertEqual(
                str(error),
                "time data 'foo' does not match format '%Y-%m-%d %H:%M:%S'",
                "wrong exc reason")

        # # Status
        operation = Operation()
        try:
            operation.Status = "foo"
        except Exception as error:
            self.assertEqual(type(error), ValueError, "wrong exc raised")
            self.assertEqual(str(error), "unknown Status 'foo'",
                             "wrong exc reason")
        operation.addFile(File({"Status": "Waiting", "LFN": "/a"}))