#NEWLINE# def testContainerValidFullJson( self ) : #NEWLINE# #INDENT# 'Proves that the same YAML parsing code handles JSON.' #NEWLINE# json_code = '\n      [\n        {\n          "name": "abc123",\n          "image": "foo/bar",\n          "command": [\n            "one",\n            "two"\n          ],\n          "workingDir": "/tmp",\n          "ports": [\n            {\n              "name": "port1",\n              "hostPort": 111,\n              "containerPort": 2222,\n              "protocol": "UDP"\n            }\n          ],\n          "volumeMounts": [\n            {\n              "name": "vol1",\n              "path": "/mnt",\n              "readOnly": true\n            }\n          ],\n          "env": [\n            {\n              "key": "KEY",\n              "value": "value str"\n            }\n          ]\n        }\n      ]\n      ' #NEWLINE# x = run_containers . LoadUserContainers ( yaml . load ( json_code ) , [ 'vol1' ] ) #NEWLINE# self . assertEqual ( 1 , len ( x ) ) #NEWLINE# self . assertEqual ( 'abc123' , x [ 0 ] . name ) #NEWLINE# self . assertEqual ( 'foo/bar' , x [ 0 ] . image ) #NEWLINE# self . assertEqual ( [ 'one' , 'two' ] , x [ 0 ] . command ) #NEWLINE# self . assertEqual ( '/tmp' , x [ 0 ] . working_dir ) #NEWLINE# self . assertEqual ( ( 111 , 2222 , '/udp' ) , x [ 0 ] . ports [ 0 ] ) #NEWLINE# self . assertEqual ( '/export/vol1:/mnt:ro' , x [ 0 ] . mounts [ 0 ] ) #NEWLINE# self . assertEqual ( 'KEY=value str' , x [ 0 ] . env_vars [ 0 ] )