

def testPackageSourceData(self):
    test_data = "\n    # Security updates\n    deb  http://security.debian.org/ wheezy/updates main contrib non-free\n    deb-src  [arch=amd64,trusted=yes]    ftp://security.debian.org/ wheezy/updates main contrib non-free\n\n    ## Random comment\n\n    # Different transport protocols below\n    deb  ssh://ftp.debian.org/debian wheezy main contrib non-free\n    deb-src    file:/mnt/deb-sources-files/ wheezy main contrib non-free\n\n    # correct - referencing root file system\n    deb-src file:/\n    # incorrect\n    deb-src http://\n\n    # Bad lines below - these shouldn't get any URIs back\n    deb\n    deb-src   [arch=i386]\n    deb-src abcdefghijklmnopqrstuvwxyz\n    "
    file_obj = StringIO.StringIO(test_data)
    pathspec = rdf_paths.PathSpec(path='/etc/apt/sources.list')
    stat = rdf_client.StatEntry(pathspec=pathspec)
    parser = config_file.APTPackageSourceParser()
    results = list(parser.Parse(stat, file_obj, None))
    result = [d for d in results if isinstance(d, rdf_protodict.AttributedDict)][0]
    self.assertEqual('/etc/apt/sources.list', result.filename)
    self.assertEqual(5, len(result.uris))
    self.assertEqual('http', result.uris[0].transport)
    self.assertEqual('security.debian.org', result.uris[0].host)
    self.assertEqual('/', result.uris[0].path)
    self.assertEqual('ftp', result.uris[1].transport)
    self.assertEqual('security.debian.org', result.uris[1].host)
    self.assertEqual('/', result.uris[1].path)
    self.assertEqual('ssh', result.uris[2].transport)
    self.assertEqual('ftp.debian.org', result.uris[2].host)
    self.assertEqual('/debian', result.uris[2].path)
    self.assertEqual('file', result.uris[3].transport)
    self.assertEqual('', result.uris[3].host)
    self.assertEqual('/mnt/deb-sources-files/', result.uris[3].path)
    self.assertEqual('file', result.uris[4].transport)
    self.assertEqual('', result.uris[4].host)
    self.assertEqual('/', result.uris[4].path)

dataset/ETHPy150Open google/grr/grr/parsers/config_file_test.py APTPackageSourceParserTests.testPackageSourceData/original