Ejemplo 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()))
Ejemplo n.º 2
0
    def test_project_changePort(self):
        project1 = Project("admin")
        project2 = Project("admin", portIn=[])
        project3 = Project("admin", portIn=[], portOut=[])

        portOwncloud = Port("port-owncloud")
        portOwncloud2 = Port("port-owncloud")
        portOwncloud3 = Port("port-owncloud")

        projOwncloud1 = Project("admin", portIn=[portOwncloud])
        project1.addPortIn(portOwncloud)
        self.assertEqual(project1, projOwncloud1)

        custom = [
            {
                "key": "filepath",
                "value": "/filepath/"
            }
        ]

        projOwncloud2 = Project("admin", portIn=[portOwncloud2])

        portOwncloud.setProperty("customProperties", custom)
        project4 = Project("admin", portIn=[portOwncloud])
        projOwncloud1.addPortIn(portOwncloud)
        self.assertEqual(project4, projOwncloud1)
        self.assertNotEqual(projOwncloud1, projOwncloud2)
        portOwncloud2.setProperty("customProperties", custom)
        self.assertEqual(projOwncloud1, projOwncloud2)
        projOwncloud2.addPortIn(portOwncloud3)
        self.assertNotEqual(projOwncloud1, projOwncloud2)
Ejemplo n.º 3
0
    def test_port_change(self):
        portOwncloud = Port("port-owncloud")

        expected = {
            "port": "port-owncloud",
            "properties": []
        }
        self.assertEqual(portOwncloud.getDict(), expected)
        self.assertEqual(portOwncloud, Port("port-owncloud"))

        with self.assertRaises(ValueError):
            portOwncloud.setProperty(1, True)
            portOwncloud.setProperty("fileStorage", 1)

        self.assertFalse(portOwncloud.setProperty("not-found", True))

        self.assertTrue(portOwncloud.setProperty("fileStorage", True))
        expected = {
            "port": "port-owncloud",
            "properties":
                [
                    {"portType": "fileStorage", "value": True}
                ]
        }
        self.assertEqual(portOwncloud.getDict(), expected)
        self.assertEqual(portOwncloud, Port("port-owncloud", fileStorage=True))

        portOwncloud.setProperty("metadata", True)
        expected = {
            "port": "port-owncloud",
            "properties":
                [
                    {"portType": "fileStorage", "value": True},
                    {"portType": "metadata", "value": True}
                ]
        }
        self.assertEqual(portOwncloud.getDict(), expected)
        self.assertEqual(portOwncloud, Port(
            "port-owncloud", fileStorage=True, metadata=True))