Exemplo n.º 1
0
    def xmlimport(self, filename, num_recipes=1):
        """
        Tests importing beaker xml and crete templates
        """
        s = Parser(file=filename)
        s.run(position=100)

        recipes = RecipeTemplate.objects.filter(jobtemplate=s.job)

        self.assertEqual(
            len(recipes), num_recipes, msg="Number recipes is bad")
        self.assertEqual(s.job.position, 100, msg="job position is same")

        # workaround: ignore default packages
        settings.BEAKER_DEFAULT_PACKAGES = []

        job = JobGen()
        xml = job.getXML(s.job)
        xml_old = get_content_from_file(filename)

        xml = u"%s" % "".join(xml.splitlines(True))
        xml_old = u"%s" % "".join(xml_old.splitlines(True))

        bs1 = BeautifulSoup(xml_old, "lxml")
        bs2 = BeautifulSoup("".join(xml), "lxml")

        d = difflib.unified_diff(
            bs1.prettify().split("\n"),
            bs2.prettify().split("\n"))
        diff = "\n".join(d)

        print "-----------"
        print "'%s'" % diff
        print "-----------"

        self.assertEqual(len(diff), 0, msg="XML '%s' is different" % filename)
Exemplo n.º 2
0
    def xmlimport(self, filename, num_recipes=1):
        """
        Tests importing beaker xml and crete templates
        """
        s = Parser(file=filename)
        s.run(position=100)

        recipes = RecipeTemplate.objects.filter(jobtemplate=s.job)

        self.assertEqual(len(recipes),
                         num_recipes,
                         msg="Number recipes is bad")
        self.assertEqual(s.job.position, 100, msg="job position is same")

        # workaround: ignore default packages
        settings.BEAKER_DEFAULT_PACKAGES = []

        job = JobGen()
        xml = job.getXML(s.job)
        xml_old = get_content_from_file(filename)

        xml = u"%s" % "".join(xml.splitlines(True))
        xml_old = u"%s" % "".join(xml_old.splitlines(True))

        bs1 = BeautifulSoup(xml_old, "lxml")
        bs2 = BeautifulSoup("".join(xml), "lxml")

        d = difflib.unified_diff(bs1.prettify().split("\n"),
                                 bs2.prettify().split("\n"))
        diff = "\n".join(d)

        print "-----------"
        print "'%s'" % diff
        print "-----------"

        self.assertEqual(len(diff), 0, msg="XML '%s' is different" % filename)
Exemplo n.º 3
0
def get_xml(job_template):
    """Takes JobTemplate object and returns its prettified job XML"""
    jobG = JobGen()
    xml = jobG.getXML(job_template, reserve=True, is_manual=True)
    soup = BeautifulSoup(xml, "xml")
    return soup.prettify()
Exemplo n.º 4
0
def get_xml(job_template):
    """Takes JobTemplate object and returns its prettified job XML"""
    jobG = JobGen()
    xml = jobG.getXML(job_template, reserve=True, is_manual=True)
    soup = BeautifulSoup(xml, "xml")
    return soup.prettify()