'Test the PsCmdParser pass Validation() method.'

def testPsCmdParserValidation(self):

    test_artifacts_file = os.path.join(config.CONFIG['Test.data_dir'], 'artifacts', 'test_artifacts.json')
    artifact_registry.REGISTRY.AddFileSource(test_artifacts_file)
    parser = linux_cmd_parser.PsCmdParser
    parser.Validate()
    content_good1 = 'name:    GoodPsArgs1\ndoc:    "ps    with    the    default/typical    non-specified    format."\nsources:\n-    type:    COMMAND\n        attributes:\n                cmd:    "/bin/ps"\n                args:    ["-ef"]\nsupported_os:    [Linux]\n'
    content_good2 = 'name:    GoodPsArgs2\ndoc:    "ps    where    we    specify    the    format."\nsources:\n-    type:    COMMAND\n        attributes:\n                cmd:    "/bin/ps"\n                args:    ["h",    "-ewwo",    "pid,ppid,uid,comm,cmd"]\nsupported_os:    [Linux]\n'
    artifact.UploadArtifactYamlFile(content_good1, token=self.token)
    artifact.UploadArtifactYamlFile(content_good2, token=self.token)
    parser.supported_artifacts.extend(['GoodPsArgs1', 'GoodPsArgs2'])
    parser.Validate()
    content_bad1 = 'name:    BadPsArgsDuplicateCmd\ndoc:    "ps    command    with    \'cmd\'    specified    more    than    once."\nsources:\n-    type:    COMMAND\n        attributes:\n                cmd:    "/bin/ps"\n                args:    ["h",    "-ewwo",    "pid,ppid,uid,cmd,comm,cmd"]\nsupported_os:    [Linux]\n'
    content_bad2 = 'name:    BadPsArgsCmdNotAtEnd\ndoc:    "ps    command    with    \'cmd\'    specified,    but    not    at    the    end."\nsources:\n-    type:    COMMAND\n        attributes:\n                cmd:    "/bin/ps"\n                args:    ["-ewwo",    "pid,ppid,uid,cmd,comm"]\nsupported_os:    [Linux]\n'
    artifact.UploadArtifactYamlFile(content_bad1, token=self.token)
    artifact.UploadArtifactYamlFile(content_bad2, token=self.token)
    orig = parser.supported_artifacts
    for bad_artifact in ['BadPsArgsDuplicateCmd', 'BadPsArgsCmdNotAtEnd']:
        with self.assertRaises(parsers.ParserDefinitionError):
            parser.supported_artifacts = list(orig)
            parser.supported_artifacts.append(bad_artifact)
            parser.Validate()
