Esempio n. 1
0
    def test_port_customProperties(self):
        custom = [
            {
                "key": "serviceProjectId",
                "value": "12345"
            }
        ]

        expected = {
            "port": "port-owncloud",
            "properties":
                [
                    {
                        "portType": "customProperties",
                        "value": custom
                    }
                ]
        }

        portOwncloud = Port("port-owncloud", customProperties=custom)

        self.assertEqual(portOwncloud.getDict(), expected)

        expected["port"] = "port-zenodo"
        portZenodo = Port("port-zenodo")
        portZenodo.setProperty("customProperties", custom)

        self.assertEqual(portZenodo.getDict(), expected)

        self.assertEqual(portZenodo, Port.fromDict(portZenodo.getDict()))
        self.assertNotEqual(portOwncloud, Port.fromDict(portZenodo.getDict()))
        self.assertNotEqual(Port("port-zenodo"),
                            Port.fromDict(portZenodo.getDict()))
Esempio n. 2
0
    def __init__(self,
                 user,
                 status=Status.CREATED,
                 portIn=None,
                 portOut=None,
                 researchname=None):
        if portIn is None:
            portIn = []

        if portOut is None:
            portOut = []

        self.user = user
        self.status = status

        self.portIn = []
        self.portOut = []

        self.researchname = researchname

        # test, if the port can be converted to port object
        try:
            for port in portIn:
                self.portIn.append(Port.fromDict(port))
            for port in portOut:
                self.portOut.append(Port.fromDict(port))
        except:
            self.portIn = portIn
            self.portOut = portOut