コード例 #1
0
    def test_list_get(self):
        # Test for a list of NamedValue objects
        self.args = self.login_args() + [
            "obj", "new", "MapAnnotation", "ns=test"]
        state = self.go()
        ann = state.get_row(0)
        # An empty list
        self.args = self.login_args() + [
            "obj", "list-get", ann, "mapValue", "0"]
        with pytest.raises(NonZeroReturnCode):
                state = self.go()
        self.args = self.login_args() + [
            "obj", "map-set", ann, "mapValue", "name1", "value1"]
        self.go()
        self.args = self.login_args() + [
            "obj", "map-set", ann, "mapValue", "name2", "value2"]
        self.go()
        self.args = self.login_args() + [
            "obj", "map-set", ann, "mapValue", "name3", "value3"]
        self.go()
        self.args = self.login_args() + [
            "obj", "list-get", ann, "mapValue", "0"]
        state = self.go()
        assert state.get_row(0) == "(name1,value1)"
        self.args = self.login_args() + [
            "obj", "list-get", ann, "mapValue", "2"]
        state = self.go()
        assert state.get_row(0) == "(name3,value3)"
        # Python indices so negative values can be used
        self.args = self.login_args() + [
            "obj", "list-get", ann, "mapValue", "-1"]
        state = self.go()
        assert state.get_row(0) == "(name3,value3)"
        # Out of bounds
        self.args = self.login_args() + [
            "obj", "list-get", ann, "mapValue", "3"]
        with pytest.raises(NonZeroReturnCode):
                state = self.go()

        # Test for a list of strings
        updateService = self.root.getSession().getUpdateService()
        n = NamespaceI()
        n.setName(rstring(self.uuid()))
        n.setKeywords(["keyword1", "keyword2"])
        n = updateService.saveAndReturnObject(n)
        self.args = self.login_args() + [
            "obj", "list-get", "Namespace:%s" % n.id.val, "keywords", "0"]
        state = self.go()
        assert state.get_row(0) == "keyword1"
        # Query a non-list field
        self.args = self.login_args() + [
            "obj", "list-get", "Namespace:%s" % n.id.val, "name", "0"]
        with pytest.raises(NonZeroReturnCode):
                state = self.go()
コード例 #2
0
ファイル: test_obj.py プロジェクト: patrick330602/fomf3dbd
    def test_get_list_field(self):
        updateService = self.root.getSession().getUpdateService()

        # Test for a list of NamedValue objects
        self.args = self.login_args() + [
            "obj", "new", "MapAnnotation", "ns=test"
        ]
        state = self.go()
        ann = state.get_row(0)
        self.args = self.login_args() + ["obj", "get", ann, "mapValue"]
        state = self.go()
        assert state.get_row(0) == ""
        self.args = self.login_args() + [
            "obj", "map-set", ann, "mapValue", "name1", "value1"
        ]
        self.go()
        self.args = self.login_args() + ["obj", "get", ann, "mapValue"]
        state = self.go()
        assert state.get_row(0) == "(name1,value1)"
        self.args = self.login_args() + [
            "obj", "map-set", ann, "mapValue", "name2", "value2"
        ]
        self.go()
        self.args = self.login_args() + ["obj", "get", ann, "mapValue"]
        state = self.go()
        assert state.get_row(0) == "(name1,value1),(name2,value2)"

        # Test for a list of strings
        n = NamespaceI()
        n.setName(rstring(self.uuid()))
        n = updateService.saveAndReturnObject(n)
        self.args = self.login_args() + [
            "obj", "get", "Namespace:%s" % n.id.val, "keywords"
        ]
        state = self.go()
        assert state.get_row(0) == ""
        n.setKeywords(["keyword1"])
        n = updateService.saveAndReturnObject(n)
        self.args = self.login_args() + [
            "obj", "get", "Namespace:%s" % n.id.val, "keywords"
        ]
        state = self.go()
        assert state.get_row(0) == "keyword1"
        n.setKeywords(["keyword1", "keyword2"])
        n = updateService.saveAndReturnObject(n)
        self.args = self.login_args() + [
            "obj", "get", "Namespace:%s" % n.id.val, "keywords"
        ]
        state = self.go()
        assert state.get_row(0) == "keyword1,keyword2"
コード例 #3
0
    def test_list_get(self):
        # Test for a list of NamedValue objects
        self.args = self.login_args() + [
            "obj", "new", "MapAnnotation", "ns=test"]
        state = self.go()
        ann = state.get_row(0)
        # An empty list
        self.args = self.login_args() + [
            "obj", "list-get", ann, "mapValue", "0"]
        with pytest.raises(NonZeroReturnCode):
            state = self.go()
        self.args = self.login_args() + [
            "obj", "map-set", ann, "mapValue", "name1", "value1"]
        self.go()
        self.args = self.login_args() + [
            "obj", "map-set", ann, "mapValue", "name2", "value2"]
        self.go()
        self.args = self.login_args() + [
            "obj", "map-set", ann, "mapValue", "name3", "value3"]
        self.go()
        self.args = self.login_args() + [
            "obj", "list-get", ann, "mapValue", "0"]
        state = self.go()
        assert state.get_row(0) == "(name1,value1)"
        self.args = self.login_args() + [
            "obj", "list-get", ann, "mapValue", "2"]
        state = self.go()
        assert state.get_row(0) == "(name3,value3)"
        # Python indices so negative values can be used
        self.args = self.login_args() + [
            "obj", "list-get", ann, "mapValue", "-1"]
        state = self.go()
        assert state.get_row(0) == "(name3,value3)"
        # Out of bounds
        self.args = self.login_args() + [
            "obj", "list-get", ann, "mapValue", "3"]
        with pytest.raises(NonZeroReturnCode):
            state = self.go()

        # Test for a list of strings
        updateService = self.root.getSession().getUpdateService()
        n = NamespaceI()
        n.setName(rstring(self.uuid()))
        n.setKeywords(["keyword1", "keyword2"])
        n = updateService.saveAndReturnObject(n)
        self.args = self.login_args() + [
            "obj", "list-get", "Namespace:%s" % n.id.val, "keywords", "0"]
        state = self.go()
        assert state.get_row(0) == "keyword1"
        # Query a non-list field
        self.args = self.login_args() + [
            "obj", "list-get", "Namespace:%s" % n.id.val, "name", "0"]
        with pytest.raises(NonZeroReturnCode):
            state = self.go()
コード例 #4
0
    def test_get_list_field(self):
        updateService = self.root.getSession().getUpdateService()

        # Test for a list of NamedValue objects
        self.args = self.login_args() + [
            "obj", "new", "MapAnnotation", "ns=test"]
        state = self.go()
        ann = state.get_row(0)
        self.args = self.login_args() + ["obj", "get", ann, "mapValue"]
        state = self.go()
        assert state.get_row(0) == ""
        self.args = self.login_args() + [
            "obj", "map-set", ann, "mapValue", "name1", "value1"]
        self.go()
        self.args = self.login_args() + ["obj", "get", ann, "mapValue"]
        state = self.go()
        assert state.get_row(0) == "(name1,value1)"
        self.args = self.login_args() + [
            "obj", "map-set", ann, "mapValue", "name2", "value2"]
        self.go()
        self.args = self.login_args() + ["obj", "get", ann, "mapValue"]
        state = self.go()
        assert state.get_row(0) == "(name1,value1),(name2,value2)"

        # Test for a list of strings
        n = NamespaceI()
        n.setName(rstring(self.uuid()))
        n = updateService.saveAndReturnObject(n)
        self.args = self.login_args() + [
            "obj", "get", "Namespace:%s" % n.id.val, "keywords"]
        state = self.go()
        assert state.get_row(0) == ""
        n.setKeywords(["keyword1"])
        n = updateService.saveAndReturnObject(n)
        self.args = self.login_args() + [
            "obj", "get", "Namespace:%s" % n.id.val, "keywords"]
        state = self.go()
        assert state.get_row(0) == "keyword1"
        n.setKeywords(["keyword1", "keyword2"])
        n = updateService.saveAndReturnObject(n)
        self.args = self.login_args() + [
            "obj", "get", "Namespace:%s" % n.id.val, "keywords"]
        state = self.go()
        assert state.get_row(0) == "keyword1,keyword2"