

def testGetArtifactPathDependencies(self):
    sources = [{
        'type': artifact_registry.ArtifactSource.SourceType.REGISTRY_KEY,
        'attributes': {
            'keys': ['%%current_control_set%%\\Control\\Session Manager\\Environment\\Path'],
        },
    }, {
        'type': artifact_registry.ArtifactSource.SourceType.WMI,
        'attributes': {
            'query': "SELECT * FROM Win32_UserProfile WHERE SID='%%users.sid%%'",
        },
    }, {
        'type': artifact_registry.ArtifactSource.SourceType.GREP,
        'attributes': {
            'content_regex_list': ['^%%users.username%%:'],
        },
    }]
    artifact = artifact_registry.Artifact(name='artifact', doc='Doco', provides=['environ_windir'], supported_os=['Windows'], urls=['http://blah'], sources=sources)
    self.assertItemsEqual([x['type'] for x in artifact.ToPrimitiveDict()['sources']], ['REGISTRY_KEY', 'WMI', 'GREP'])

    class Parser1(object):
        knowledgebase_dependencies = ['appdata', 'sid']

    class Parser2(object):
        knowledgebase_dependencies = ['sid', 'desktop']

    @classmethod
    def MockGetClassesByArtifact(unused_cls, _):
        return [Parser1, Parser2]
    with utils.Stubber(parsers.Parser, 'GetClassesByArtifact', MockGetClassesByArtifact):
        self.assertItemsEqual(artifact.GetArtifactPathDependencies(), ['appdata', 'sid', 'desktop', 'current_control_set', 'users.sid', 'users.username'])

dataset/ETHPy150Open google/grr/grr/lib/artifact_utils_test.py ArtifactTests.testGetArtifactPathDependencies/original