def test_removePackage(self): controlfile = \ "Source: foo\n" \ "Build-Depends: bar\n" \ "\n" \ "Package: foo1\n" \ "Suggests: something\n" \ "\n" \ "Package: foo2\n" \ "Suggests: something\n" \ "\n" \ "Package: foo3\n" \ "Suggests: something\n" \ "\n" \ "Package: foo4\n" \ "Suggests: something\n" parser = ControlFileParser(text=controlfile) parser.remove_package('foo1') parser.remove_package('foo2') parser.remove_package('foo4') self.assertEqual( parser.get_text(), "Source: foo\n" "Build-Depends: bar\n" "\n" "Package: foo3\n" "Suggests: something\n")
def test_addBuildDependsOneLine(self): controlfile = \ "Source: ffmpeg\n" \ "Build-Depends: flite1, bz2\n" parser = ControlFileParser(text=controlfile) parser.add_depends_entry(None, 'Build-Depends', 'fdk-aac') self.assertEqual( parser.get_text(), "Source: ffmpeg\n" "Build-Depends: flite1, bz2, fdk-aac\n")
def test_removeAllBuildDepends(self): controlfile = \ "Source: libproxy\n" \ "Build-Depends: llvm\n" \ "Uploaders: a <*****@*****.**>\n" parser = ControlFileParser(text=controlfile) parser.remove_depends_entry(None, 'Build-Depends', 'llvm') new = parser.get_text() self.assertEqual(new, "Source: libproxy\n" "Uploaders: a <*****@*****.**>\n")
def test_removeBuildDependsFinalOneLine(self): controlfile = \ "Source: gnome-online-accounts\n" \ "Build-Depends: soup, telepathy, webkit,\n" parser = ControlFileParser(text=controlfile) parser.remove_depends_entry(None, 'Build-Depends', 'webkit') self.assertEqual( parser.get_text(), "Source: gnome-online-accounts\n" "Build-Depends: soup, telepathy,\n")
def test_removeBuildDepends(self): controlfile = \ "Source: gnome-online-accounts\n" \ "Build-Depends: libsoup2.4-dev,\n" \ " telepathy,\n" \ " libwebkit2gtk-4.0-dev\n" parser = ControlFileParser(text=controlfile) parser.remove_depends_entry(None, 'Build-Depends', 'telepathy') self.assertEqual( parser.get_text(), "Source: gnome-online-accounts\n" "Build-Depends: libsoup2.4-dev,\n" " libwebkit2gtk-4.0-dev\n")
def test_addParagraph(self): controlfile = \ "Source: foo\n" \ "Build-Depends: bar\n" parser = ControlFileParser(text=controlfile) parser.add_paragraph("Package: mypkg\n" "Suggests: gcc\n") self.assertIsNotNone(parser.get_paragraph("mypkg")) self.assertEqual( parser.get_text(), "Source: foo\n" "Build-Depends: bar\n" "\n" "Package: mypkg\n" "Suggests: gcc\n")
def test_uploadersOneLine(self): controlfile = \ "Source: cheese\n" \ "Maintainer: GNOME <*****@*****.**>\n" \ "Uploaders: Frog <*****@*****.**>, James <*****@*****.**>\n" \ "Build-Depends: debhelper (>= 11)\n" parser = ControlFileParser(text=controlfile) parser.patch(None, 'Uploaders', 'new <*****@*****.**>') new = parser.get_text() self.assertEqual( new, "Source: cheese\n" "Maintainer: GNOME <*****@*****.**>\n" "Uploaders: new <*****@*****.**>\n" "Build-Depends: debhelper (>= 11)\n")
def test_patchBuildDependsVersionConstraint(self): controlfile = \ "Source: appstream\n" \ "Build-Depends: something\n" \ " cmake (>= 3.2),\n" \ " debhelper (>= 10),\n" parser = ControlFileParser(text=controlfile) result = parser.parse_depends(None, 'Build-Depends') parser.patch_at_offset(result["cmake"].position, "cmake (>= 4.0)") new = parser.get_text() self.assertEqual( new, "Source: appstream\n" "Build-Depends: something\n" " cmake (>= 4.0),\n" " debhelper (>= 10),\n")
def test_addField(self): controlfile = \ "Source: foo\n" \ "Build-Depends: bar\n" \ "\n" \ "Package: foo1\n" \ "Suggests: something\n" \ "\n" \ "Package: foo2\n" \ "Suggests: something\n" parser = ControlFileParser(text=controlfile) parser.add_field('foo1', 'X-Something', 'asdf') self.assertEqual( parser.get_text(), "Source: foo\n" "Build-Depends: bar\n" "\n" "Package: foo1\n" "Suggests: something\n" "X-Something: asdf\n" "\n" "Package: foo2\n" "Suggests: something\n")