class_docstr: Test class for JSONParser
class_docstr_tok: ["Test","class","for","JSONParser"]
docstr: JSONParser - Inspec JSON
docstr_tok: ["JSONParser","-","Inspec","JSON"]
code: def test_inspec(self):
      """JSONParser - Inspec JSON"""
      options = {
          "schema": {
              "title": "string",
              "desc": "string",
              "impact": "float",
              "refs": [],
              "tags": {},
              "code": "string",
              "id": "string",
              "source_location": {},
              "results": [],
          },
          "configuration": {"json_path": "profiles[].controls[]"},
      }
  
      data = {
          "other_checks": [],
          "profiles": [
              {
                  "attributes": [],
                  "controls": [
                      {
                          "code": "code snippet 01",
                          "desc": None,
                          "id": "(generated from osquery.rb:1 b6ef5242a32098111f11cb7d21a05bb8)",
                          "impact": 0.5,
                          "refs": [],
                          "results": [
                              {
                                  "code_desc": "Processes states should eq ['SNs']",
                                  "run_time": 0.000992,
                                  "start_time": "2017-02-28 09:24:47 -0800",
                                  "status": "passed",
                              }
                          ],
                          "source_location": {
                              "line": 87,
                              "ref": "/opt/inspec/.../control_eval_context.rb",
                          },
                          "tags": {},
                          "title": None,
                      },
                      {
                          "code": "code snippet 02",
                          "desc": None,
                          "id": "(generated from osquery.rb:6 124c5f23cd897a018673b1ea512a9473)",
                          "impact": 0.5,
                          "refs": [],
                          "results": [
                              {
                                  "code_desc": "File osquery.conf mode should cmp == '0400'",
                                  "message": "foo message",
                                  "run_time": 0.011729,
                                  "start_time": "2017-02-28 09:24:47 -0800",
                                  "status": "failed",
                              }
                          ],
                          "source_location": {
                              "line": 87,
                              "ref": "/opt/inspec/.../control_eval_context.rb",
                          },
                          "tags": {},
                          "title": None,
                      },
                  ],
                  "groups": [
                      {
                          "controls": [
                              "(generated from osquery.rb:1 b6ef5242a32098111f11cb7d21a05bb8)"
                          ],
                          "id": "osquery.rb",
                          "title": None,
                      }
                  ],
                  "supports": [],
              }
          ],
          "statistics": {"duration": 0.040234},
          "version": "1.4.1",
      }
  
      record_data = json.dumps(data)
  
      # get parsed data
      parser = JSONParser(options)
      assert_equal(parser.parse(record_data), True)
  
      expected_result = [
          control
          for prof in data["profiles"]
          for control in prof["controls"]
      ]
  
      assert_equal(parser.parsed_records, expected_result)
  
imports: import json
  from mock import patch
  from nose.tools import assert_equal
  from streamalert.classifier.parsers import JSONParser
label_desc: Use image node_id 23 for calling the TestJSONParser obj's underlying member method code with example usage: obj.test_inspec() without return types