NinjaGaiden
NinjaGaiden

Reputation: 3146

Robotframework testing dictionary values

I have a dictionary (json) that looks like this

[{"foo":"fooval1a",type:"xfs"},{"foo":"fooval2a",type:"ext2"},{"foo":"fooval3a",type:"nfs"},{"foo":"fooval4a",type:"ntfs"}]

I would like to check in this list, when "foo" is value "fooval3a" it should be "nfs". I have like 20 of these sort of tests. Is there a way to do this easily with robotframework?

Upvotes: 0

Views: 333

Answers (1)

Flibidisch
Flibidisch

Reputation: 36

You miss quote on "type"

${listOfDict}    Evaluate    [{"foo":"fooval1a","type":"xfs"},{"foo":"fooval2a","type":"ext2"},{"foo":"fooval3a","type":"nfs"},{"foo":"fooval4a","type":"ntfs"}]
FOR    ${dict}    IN    @{listOfDict}
    IF    "${dict}[foo]"=="fooval3a"
        Should Be Equal    ${dict}[type]    nfs
    END
END

Upvotes: 1

Related Questions