Esempio n. 1
0
    def test_setitem(self):

        # string
        d = ServiceOptsDict({"omero.share": "2", "omero.user": "******"})
        d["omero.group"] = "-1"

        # unicode
        d = ServiceOptsDict({"omero.share": u'2', "omero.user": u'1'})
        d["omero.group"] = u'-1'

        # int
        d = ServiceOptsDict({"omero.share": 1, "omero.user": 2})
        d["omero.group"] = -1

        # long
        import sys
        maxint = sys.maxint
        d = ServiceOptsDict({"omero.group": (maxint + 1)})
        d["omero.user"] = (maxint + 1)

        # Setter passed None as value remove from internal dict
        d = ServiceOptsDict({"omero.share": "2", "omero.user": "******"})
        self.assertNotEqual(d.get("omero.share"), None)
        d.setOmeroShare()
        self.assertEqual(d.get("omero.share"), None)
        self.assertNotEqual(d.get("omero.user"), None)
        d.setOmeroUser()
        self.assertEqual(d.get("omero.user"), None)

        try:
            d = ServiceOptsDict({"omero.group": True})
            d["omero.user"] = True
        except:
            pass
        else:
            self.fail(
                "AttributeError: ServiceOptsDict argument must be a string, unicode or numeric type"
            )

        try:
            d = ServiceOptsDict({"omero.group": []})
            d["omero.user"] = []
        except:
            pass
        else:
            self.fail(
                "AttributeError: ServiceOptsDict argument must be a string, unicode or numeric type"
            )

        try:
            d = ServiceOptsDict({"omero.group": {}})
            d["omero.user"] = {}
        except:
            pass
        else:
            self.fail(
                "AttributeError: ServiceOptsDict argument must be a string, unicode or numeric type"
            )
Esempio n. 2
0
    def test_setitem(self):

        # string
        d = ServiceOptsDict({"omero.share": "2", "omero.user": "******"})
        d["omero.group"] = "-1"

        # unicode
        d = ServiceOptsDict({"omero.share": u'2', "omero.user": u'1'})
        d["omero.group"] = u'-1'

        # int
        d = ServiceOptsDict({"omero.share": 1, "omero.user": 2})
        d["omero.group"] = -1

        # long
        import sys
        maxint = sys.maxint
        d = ServiceOptsDict({"omero.group": (maxint + 1)})
        d["omero.user"] = (maxint + 1)

        # Setter passed None as value remove from internal dict
        d = ServiceOptsDict({"omero.share": "2", "omero.user": "******"})
        assert d.get("omero.share") is not None
        d.setOmeroShare()
        assert d.get("omero.share") is None
        assert d.get("omero.user") is not None
        d.setOmeroUser()
        assert d.get("omero.user") is None

        try:
            d = ServiceOptsDict({"omero.group": True})
            d["omero.user"] = True
        except:
            pass
        else:
            self.fail("AttributeError: ServiceOptsDict argument must be a"
                      " string, unicode or numeric type")

        try:
            d = ServiceOptsDict({"omero.group": []})
            d["omero.user"] = []
        except:
            pass
        else:
            self.fail("AttributeError: ServiceOptsDict argument must be a"
                      " string, unicode or numeric type")

        try:
            d = ServiceOptsDict({"omero.group": {}})
            d["omero.user"] = {}
        except:
            pass
        else:
            self.fail("AttributeError: ServiceOptsDict argument must be a"
                      " string, unicode or numeric type")
Esempio n. 3
0
    def test_setter_an_getter(self):
        group = -1
        user = 1
        share = 2

        d = ServiceOptsDict()
        d.set("omero.group", group)
        self.assertEqual(d.get("omero.group"), d.getOmeroGroup())

        d.setOmeroGroup(group)
        self.assertEqual(d.get("omero.group"), d.getOmeroGroup())

        d.set("omero.user", user)
        self.assertEqual(d.get("omero.user"), d.getOmeroUser())

        d.setOmeroUser(user)
        self.assertEqual(d.get("omero.user"), d.getOmeroUser())

        d.set("omero.share", share)
        self.assertEqual(d.get("omero.share"), d.getOmeroShare())

        d.setOmeroShare(share)
        self.assertEqual(d.get("omero.share"), d.getOmeroShare())
Esempio n. 4
0
 def test_setter_an_getter(self):
     group = -1
     user = 1
     share = 2
     
     d = ServiceOptsDict()
     d.set("omero.group", group)
     assert d.get("omero.group") ==  d.getOmeroGroup()
     
     d.setOmeroGroup(group)
     assert d.get("omero.group") ==  d.getOmeroGroup()
     
     d.set("omero.user", user)
     assert d.get("omero.user") ==  d.getOmeroUser()
     
     d.setOmeroUser(user)
     assert d.get("omero.user") ==  d.getOmeroUser()
     
     d.set("omero.share", share)
     assert d.get("omero.share") ==  d.getOmeroShare()
     
     d.setOmeroShare(share)
     assert d.get("omero.share") ==  d.getOmeroShare()