def test_thermal(self):
        self.warn = 80
        self.crit = 90

        f = 'thermal.xml'
        check = check_pa.modules.thermal.create_check(self)
        obj = check.resources[0]

        with responses.RequestsMock() as rsps:
            rsps.add(responses.GET,
                     obj.xml_obj.build_request_url(),
                     body=utils.read_xml(f),
                     status=200,
                     content_type='document',
                     match_querystring=True)
            with pytest.raises(SystemExit):
                check.main(verbose=3)

            assert check.exitcode == 0
            assert check.state == ServiceState(code=0, text='ok')
            assert check.summary_str == 'Temperature @ Test1 is 30 degrees' \
                                        ' Celsius, Temperature @ Test2 is 34' \
                                        ' degrees Celsius, Temperature @' \
                                        ' Test3 is 37 degrees Celsius,' \
                                        ' Temperature @ Test4' \
                                        ' is 25 degrees Celsius'
Example #2
0
    def __getitem__(self, index):
        img_name = self.imgNames[index]

        path2007 = self.path
        img_path = path2007 + "/JPEGImages/%s.jpg" % img_name
        img = Image.open(img_path).convert('RGB')

        # GET POINTS
        w, h = img.size
        points = np.zeros((h, w, 1))
        counts = np.zeros(20)
        counts_difficult = np.zeros(20)

        if self.split == "test":

            xml_path = path2007 + "/Annotations/%s.xml" % img_name
            xml = ut.read_xml(xml_path)
            for obj in xml.find_all("object"):
                if int(obj.find("difficult").text) == 1:
                    name = obj.find("name").text
                    counts_difficult[self.name2class[name]] += 1
                    continue

                name = obj.find("name").text
                xmin, xmax = obj.find("xmin").text, obj.find("xmax").text
                xmin, xmax = int(xmin), int(xmax)

                ymin, ymax = obj.find("ymin").text, obj.find("ymax").text
                ymin, ymax = int(ymin), int(ymax)

                yc = (ymax + ymin) // 2
                xc = (xmax + xmin) // 2

                points[yc, xc] = self.name2class[name] + 1
                counts[self.name2class[name]] += 1
                counts_difficult[self.name2class[name]] += 1

        else:
            pointLocs = self.pointsJSON[img_name]

            for p in pointLocs:
                if int(p["x"]) > w or int(p["y"]) > h:
                    continue
                else:
                    points[int(p["y"]), int(p["x"])] = p["cls"]
                    counts[p["cls"] - 1] += 1
                    counts_difficult[p["cls"] - 1] += 1

        points = FT.to_pil_image(points.astype("uint8"))
        if self.transform_function is not None:
            img, points = self.transform_function([img, points])

        return {
            "counts": torch.LongTensor(counts),
            "images": img,
            "points": points,
            "image_path": img_path,
            "index": index,
            "name": img_name
        }
    def test_sessinfo_warning2(self):
        f = 'mock_result.xml'
        self.warn = 4000
        self.crit = 5000

        check = check_pa.modules.sessioninfo.create_check(self)
        obj = check.resources[0]

        with responses.RequestsMock() as rsps:
            rsps.add(responses.GET,
                     obj.xml_obj.build_request_url(),
                     body=utils.read_xml(f),
                     status=200,
                     content_type='document',
                     match_querystring=True)

            nummax = 262142
            numactive = 5002
            kbps = 24266

            with mock.patch('check_pa.xml_reader.Finder.find_item',
                            side_effect=[nummax, numactive, kbps]):
                with pytest.raises(SystemExit):
                    check.main(verbose=3)

            assert check.exitcode == 2
            assert check.state == ServiceState(code=2, text='critical')
            assert check.summary_str == 'session is 5002 (outside range 0:5000)'
def read_xml_and_resize_bbox_by_ratio2(xml_path, label_size):  # 根据长短边resize
    rfind_path = raw_img_path[0:raw_img_path.rfind('\\')]
    resize_save_path = os.path.join(rfind_path, 'resize')
    if not os.path.exists(resize_save_path):
        os.makedirs(resize_save_path)
    xml_list = glob.glob(xml_path + '\\*.xml')
    for xml_s in xml_list:
        regions = utils.read_xml(xml_s)
        img_path1 = xml_s.replace('.xml', '.jpg')
        # img = cv2.imread(img_path1)
        img = utils.read_single_img(img_path1)
        height, width = img.shape[0], img.shape[1]
        tree = ET.parse(r'../exam_info/000000-template.xml')  # xml tree
        for index, region_info in enumerate(regions):
            bbox = region_info['bounding_box']
            im_region_list = get_img_region(img, bbox, label_size)
            tree = utils.create_xml(region_info['class_name'], tree,
                                    im_region_list[0], im_region_list[1],
                                    im_region_list[2], im_region_list[3])
        xml_name = xml_s.split('\\')[-1]
        save_path0 = os.path.join(resize_save_path, xml_name)
        tree.write(save_path0)
        height, width, _ = img.shape
        if height > width:
            image = cv2.resize(img, (min(label_size), max(label_size)),
                               interpolation=cv2.INTER_AREA)
        else:
            image = cv2.resize(img, (max(label_size), min(label_size)),
                               interpolation=cv2.INTER_AREA)
        # cv2.imwrite(save_path0.replace('.xml', '.jpg'), image)
        utils.write_single_img(image, save_path0.replace('.xml', '.jpg'))
    return resize_save_path
Example #5
0
    def test_underset_is_not_a_limit(self):
        xml_string = read_xml("underset_is_not_limit.xml", bug_fixes_path)
        ooxml_to_latex = OOXMLtoLatexParser.parse(xml_string, math_symbols=unicode_to_latex)

        self.assertMultiLineEqual(r'\underbrace{{\ 7}^{{\ k}}}_{{\ n\ digitos}}<{\ 7}^{{\ k+1}}{\ =7}\left ({\ 7}^'
                                  r'{{\ k}}\right )<\underbrace{{\ 10}\left ({\ 7}^{{\ k}}\right )}_{{\ n+1'
                                  r'\ digitos}}', ooxml_to_latex.result)
Example #6
0
    def test_fractions_without_bar_must_be_a_binom(self):
        xml_string = read_xml(
            "fractions_without_bar_must_be_a_binom.xml", bug_fixes_path)
        ooxml_to_latex = OOXMLtoLatexParser.parse(
            xml_string, math_symbols=unicode_to_latex)

        self.assertMultiLineEqual(r"\binom{{\ n}}{{\ 0}}", ooxml_to_latex.result)
Example #7
0
    def test_insert_parenthesis_in_superscript(self):
        xml_string = read_xml(
            "insert_parenthesis_in_superscript.xml", bug_fixes_path)
        xml_to_latex = OOXMLtoLatexParser.parse(
            xml_string, math_symbols=unicode_to_latex)

        self.assertEquals(r"\left ({\ a+b}\right )^{{\ n}}", xml_to_latex.result)
Example #8
0
    def test_radius_of_the_circle(self):
        xml_string = read_xml('radius_of_the_circle.xml', fixtures_path)
        ooxml_to_latex = OOXMLtoLatexParser.parse(
            xml_string, math_symbols=unicode_to_latex)

        self.assertEquals(r'{\ C}{\ =}{\ \pi  }{\ \cdot  }{\ d}{\ =}{\ 2}{\ \cdot  '
                          r'}{\ \pi  }{\ \cdot  }{\ r}', ooxml_to_latex.result)
Example #9
0
def main():
    filename = './origin_data/bugreports.xml'
    path = './bug_reports'
    bugslist = utils.read_xml(filename)
    # print(bugslist)
    label = utils.read_label('./origin_data/goldset.txt')
    # print(label)
    samples, ids = utils.get_content(bugslist)
    # print(samples)
    num_word_list, numword = utils.count_word(samples)
    # print(len(num_word_list))

    # for i in num_word_list:
    #     num_sentence.append(len(i))
    utils.savefile(samples)
    # print(num_sentence)
    results = textrank.bugsum(path, numword, num_word_list)
    print(len(i) for i in results)
    # extra_ids = index2id(results,ids)
    # print(len(extra_ids))
    pred = eval.index2pred(results, ids)
    y = eval.label2y(label, ids)
    mean_acc, mean_pr, mean_re, mean_f1 = eval.evaluate(y, pred)
    print('mean_acc, mean_pr, mean_re, mean_f1', mean_acc, mean_pr, mean_re,
          mean_f1)
Example #10
0
 def test_expansao_de_uma_soma(self):
     xml_string = read_xml("expansao_de_uma_soma.xml", bug_fixes_path)
     ooxml_to_latex = OOXMLtoLatexParser.parse(xml_string, math_symbols=unicode_to_latex)
     self.assertMultiLineEqual(r'\left ({\ 1+x}\right )^{{\ n}}{\ =1+}\frac{{\ nx}}{{\ 1\text{!} }}{\ +}'
                               r'\frac{{\ n}\left '
                               r'({\ n-1}\right ){\ x}^{{\ 2}}}{{\ 2\text{!} }}{\ +\ldots  }',
                               ooxml_to_latex.result)
Example #11
0
 def test_expansao_de_taylor(self):
     xml_string = read_xml("expansao_de_taylor.xml", bug_fixes_path)
     ooxml_to_latex = OOXMLtoLatexParser.parse(xml_string, math_symbols=unicode_to_latex)
     self.assertMultiLineEqual(r'{\ e}^{{\ x}}{\ =1+}\frac{{\ x}}{{\ 1\text{!} }}{\ +}\frac{{\ x}^{{\ 2}}}{{\ '
                               r'2\text{!} }}{\ +}'
                               r'\frac{{\ x}^{{\ 3}}}{{\ 3\text{!} }}{\ +\ldots  ,}{\ -\infty <x<\infty }',
                               ooxml_to_latex.result)
Example #12
0
 def test_identidade_trigonometrica1(self):
     xml_string = read_xml("identidade_trigonometrica1.xml", bug_fixes_path)
     ooxml_to_latex = OOXMLtoLatexParser.parse(xml_string, math_symbols=unicode_to_latex)
     self.assertMultiLineEqual(r'{\ sin}{\ \alpha  }{\ \pm  }{\ sin}{\ \beta  }{\ =2}{\ sin}\frac{{\ 1}}{{\ 2}}'
                               r'\left ({\ \alpha  \pm  \beta  }\right ){\ cos}\frac{{\ 1}}{{\ 2}}\left ({\ \alpha  '
                               r'\mp  \beta  }\right )',
                               ooxml_to_latex.result)
Example #13
0
 def test_serie_de_fourier(self):
     xml_string = read_xml("serie_de_Fourier.xml", bug_fixes_path)
     ooxml_to_latex = OOXMLtoLatexParser.parse(xml_string, math_symbols=unicode_to_latex)
     self.assertMultiLineEqual(r'{\ f}\left ({\ x}\right ){\ =}{\ a}_{{\ 0}}{\ +}\sum  _{{\ n=1}}^{{\ \infty }}'
                               r'\left ({\ a}_{{\ n}}{\ cos}\frac{{\ n\pi  x}}{{\ L}}{\ +}{\ b}_{{\ n}}{\ sin}'
                               r'\frac{{\ n\pi  x}}{{\ L}}\right )',
                               ooxml_to_latex.result)
Example #14
0
 def test_integral_de_bloqueio_de_modo(self):
     xml_string = read_xml("integral_de_bloqueio_de_modo.xml", bug_fixes_path)
     ooxml_to_latex = OOXMLtoLatexParser.parse(xml_string, math_symbols=unicode_to_latex)
     self.assertMultiLineEqual(r'\frac{{\ 1}}{{\ 2}{\ \pi  }}\int_{{\ 0}}^{{\ 2}{\ \pi  }}\frac{{\ \mathscr{d} }'
                               r'{\ \theta  }}{{\ a}{\ +}{\ b}{\ sin}{\ \theta  }}{\ =}\frac{{\ 1}}{\sqrt{{\ a}^'
                               r'{{\ 2}}{\ -}{\ b}^{{\ 2}}}}',
                               ooxml_to_latex.result)
Example #15
0
    def test_sum(self):
        xml_string = read_xml("sum.xml", bug_fixes_path)
        ooxml_to_latex = OOXMLtoLatexParser.parse(
            xml_string, math_symbols=unicode_to_latex)

        self.assertEquals(r"\bigcap  _{}^{}{\ l=}\bigcap  _{{\ i\in I}}^{}{\ S}_{{\ i}}{\ =}"
                          r"\left \{{\ x/ x\in }{\ S}_{{\ i}}{\ para\ cada\ i\in I}\right \}", ooxml_to_latex.result)
    def check_pa(self, time, ibytes, obytes, filename):
        objects = []
        file1 = filename

        check = check_pa.modules.throughput.create_check(self)

        for res in check.resources:
            objects.append(res)

        with responses.RequestsMock() as rsps:
            rsps.add(responses.GET,
                     objects[0].xml_obj.build_request_url(),
                     body=utils.read_xml(file1),
                     status=200,
                     content_type='document',
                     match_querystring=True)

            with mock.patch('check_pa.modules.throughput.get_time',
                            return_value=time):
                with mock.patch('check_pa.xml_reader.Finder.find_item',
                                side_effect=[ibytes, obytes]):
                    with pytest.raises(SystemExit):
                        check.main(verbose=3)

        return check
Example #17
0
    def test_notsupset(self):
        xml_string = read_xml('notsupset.xml', fixtures_path)
        ooxml_to_latex = OOXMLtoLatexParser.parse(
            xml_string, math_symbols=unicode_to_latex)

        self.assertEquals(r'{\ 2}{\ \not\supset  }{\ 2}',
                          ooxml_to_latex.result)
Example #18
0
    def test_bigcup_bug_fix(self):
        xml_string = read_xml("bigcup.xml", bug_fixes_path)
        ooxml_to_latex = OOXMLtoLatexParser.parse(
            xml_string, math_symbols=unicode_to_latex)

        self.assertEquals(r'\left (\bigcup  _{{\ i\in I}}^{}{\ S}_{{\ i}}\right )^{{\ c}}{\ =}\bigcap'
                          r'  _{{\ i\in I}}^{}\left ({\ S}_{{\ i}}^{{\ c}}\right )', ooxml_to_latex.result)
Example #19
0
    def test_ln(self):
        xml_string = read_xml('ln.xml', fixtures_path)
        ooxml_to_latex = OOXMLtoLatexParser.parse(
            xml_string, math_symbols=unicode_to_latex)

        self.assertEquals(r'{\ ln}\left ({\ 10}\right )',
                          ooxml_to_latex.result)
Example #20
0
    def test_bar(self):
        xml_string = read_xml('bar.xml', fixtures_path)
        ooxml_to_latex = OOXMLtoLatexParser.parse(
            xml_string, math_symbols=unicode_to_latex)

        self.assertEquals(r'\left \vert  {\ 1}\right \vert  ',
                          ooxml_to_latex.result)
Example #21
0
    def test_ll(self):
        xml_string = read_xml('preccurlyeq.xml', fixtures_path)
        ooxml_to_latex = OOXMLtoLatexParser.parse(
            xml_string, math_symbols=unicode_to_latex)

        self.assertEquals(r'{\ 1}{\ \preccurlyeq  }{\ 2}',
                          ooxml_to_latex.result)
Example #22
0
 def test_integral_gaussiano(self):
     xml_string = read_xml("integral_gaussiano.xml", bug_fixes_path)
     ooxml_to_latex = OOXMLtoLatexParser.parse(xml_string, math_symbols=unicode_to_latex)
     self.assertMultiLineEqual(r'\int_{{\ -\infty }}^{{\ \infty }}{\ e}^{{\ -}{\ x}^{{\ 2}}}{\ dx}{\ =}\left '
                               r'[\int_{{\ -\infty }}^{{\ \infty }}{\ e}^{{\ -}{\ x}^{{\ 2}}}{\ dx}\int_{{\ '
                               r'-\infty }}^{{\ \infty }}{\ e}^{{\ -}{\ y}^{{\ 2}}}{\ dy}\right ]^{{\ 1}{\ / }{\ 2}}',
                               ooxml_to_latex.result)
Example #23
0
    def test_fractions_without_bar_must_be_a_binom(self):
        xml_string = read_xml("fractions_without_bar_must_be_a_binom.xml",
                              bug_fixes_path)
        ooxml_to_latex = OOXMLtoLatexParser.parse(
            xml_string, math_symbols=unicode_to_latex)

        self.assertMultiLineEqual(r"\binom{{\ n}}{{\ 0}}",
                                  ooxml_to_latex.result)
Example #24
0
    def test_insert_parenthesis_in_superscript(self):
        xml_string = read_xml("insert_parenthesis_in_superscript.xml",
                              bug_fixes_path)
        xml_to_latex = OOXMLtoLatexParser.parse(xml_string,
                                                math_symbols=unicode_to_latex)

        self.assertEquals(r"\left ({\ a+b}\right )^{{\ n}}",
                          xml_to_latex.result)
Example #25
0
    def test_radius_of_the_circle(self):
        xml_string = read_xml('radius_of_the_circle.xml', fixtures_path)
        ooxml_to_latex = OOXMLtoLatexParser.parse(
            xml_string, math_symbols=unicode_to_latex)

        self.assertEquals(
            r'{\ C}{\ =}{\ \pi  }{\ \cdot  }{\ d}{\ =}{\ 2}{\ \cdot  '
            r'}{\ \pi  }{\ \cdot  }{\ r}', ooxml_to_latex.result)
Example #26
0
    def test_multiple_squares(self):
        xml_string = read_xml("multiple_squares.xml", bug_fixes_path)
        ooxml_to_latex = OOXMLtoLatexParser.parse(
            xml_string, math_symbols=unicode_to_latex)

        self.assertMultiLineEqual(
            r'\sqrt{\sqrt{\sqrt{{\ 100}}{\ +}\sqrt{{\ 36}}}}',
            ooxml_to_latex.result)
Example #27
0
    def test_sup_does_not_work(self):
        xml_string = read_xml("sup_does_not_work.xml", bug_fixes_path)
        ooxml_to_latex = OOXMLtoLatexParser.parse(
            xml_string, math_symbols=unicode_to_latex)

        self.assertMultiLineEqual(
            r'{\ l=}\left \{{\ S}_{{\ k}}\right \}_{{\ k=1}}^{{\ 5}}',
            ooxml_to_latex.result)
Example #28
0
 def test_teorema_binomial(self):
     xml_string = read_xml("teorema_binomial.xml", bug_fixes_path)
     ooxml_to_latex = OOXMLtoLatexParser.parse(
         xml_string, math_symbols=unicode_to_latex)
     self.assertMultiLineEqual(
         r'\left ({\ x+a}\right )^{{\ n}}{\ =}\sum  _{{\ k=0}}^{{\ n}}\left (\binom{{\ n}}'
         r'{{\ k}}\right ){\ x}^{{\ k}}{\ a}^{{\ n-k}}',
         ooxml_to_latex.result)
Example #29
0
    def test_function(self):
        xml_string = read_xml('function.xml', fixtures_path)
        ooxml_to_latex = OOXMLtoLatexParser.parse(
            xml_string, math_symbols=unicode_to_latex)

        self.assertEquals(r'{\ f}\left ({\ x}\right ){\ =}\sum  _{{\ i}{\ =}{\ 0}}^{{\ '
                          r'\infty }}\frac{{\ f}^{\left ({\ i}\right )}\left ({\ 0}\right )}{{\ i}'
                          r'{\ !}}{\ x}^{{\ i}}', ooxml_to_latex.result)
Example #30
0
 def test_identidade_trigonometrica1(self):
     xml_string = read_xml("identidade_trigonometrica1.xml", bug_fixes_path)
     ooxml_to_latex = OOXMLtoLatexParser.parse(
         xml_string, math_symbols=unicode_to_latex)
     self.assertMultiLineEqual(
         r'{\ sin}{\ \alpha  }{\ \pm  }{\ sin}{\ \beta  }{\ =2}{\ sin}\frac{{\ 1}}{{\ 2}}'
         r'\left ({\ \alpha  \pm  \beta  }\right ){\ cos}\frac{{\ 1}}{{\ 2}}\left ({\ \alpha  '
         r'\mp  \beta  }\right )', ooxml_to_latex.result)
Example #31
0
    def test_multiple_fractions(self):
        xml_string = read_xml("multiple_fractions.xml", bug_fixes_path)
        ooxml_to_latex = OOXMLtoLatexParser.parse(
            xml_string, math_symbols=unicode_to_latex)

        self.assertMultiLineEqual(r"{\ S}_{{\ n}}{\ :}\frac{{\ 1}}{\sqrt{{\ 1}}}{\ +}\frac{{\ 1}}"
                                  r"{\sqrt{{\ 2}}}{\ +\cdots  +}\frac{{\ 1}}{\sqrt"
                                  r"{{\ n}}}{\ \geq  }\sqrt{{\ n}}", ooxml_to_latex.result)
Example #32
0
 def test_serie_de_fourier(self):
     xml_string = read_xml("serie_de_Fourier.xml", bug_fixes_path)
     ooxml_to_latex = OOXMLtoLatexParser.parse(
         xml_string, math_symbols=unicode_to_latex)
     self.assertMultiLineEqual(
         r'{\ f}\left ({\ x}\right ){\ =}{\ a}_{{\ 0}}{\ +}\sum  _{{\ n=1}}^{{\ \infty }}'
         r'\left ({\ a}_{{\ n}}{\ cos}\frac{{\ n\pi  x}}{{\ L}}{\ +}{\ b}_{{\ n}}{\ sin}'
         r'\frac{{\ n\pi  x}}{{\ L}}\right )', ooxml_to_latex.result)
Example #33
0
 def test_expansao_de_uma_soma(self):
     xml_string = read_xml("expansao_de_uma_soma.xml", bug_fixes_path)
     ooxml_to_latex = OOXMLtoLatexParser.parse(
         xml_string, math_symbols=unicode_to_latex)
     self.assertMultiLineEqual(
         r'\left ({\ 1+x}\right )^{{\ n}}{\ =1+}\frac{{\ nx}}{{\ 1\text{!} }}{\ +}'
         r'\frac{{\ n}\left '
         r'({\ n-1}\right ){\ x}^{{\ 2}}}{{\ 2\text{!} }}{\ +\ldots  }',
         ooxml_to_latex.result)
Example #34
0
    def test_bigcup_bug_fix(self):
        xml_string = read_xml("bigcup.xml", bug_fixes_path)
        ooxml_to_latex = OOXMLtoLatexParser.parse(
            xml_string, math_symbols=unicode_to_latex)

        self.assertMultiLineEqual(
            r'\left (\bigcup  _{{\ i\in I}}^{}{\ S}_{{\ i}}\right )^{{\ c}}{\ =}\bigcap'
            r'  _{{\ i\in I}}^{}\left ({\ S}_{{\ i}}^{{\ c}}\right )',
            ooxml_to_latex.result)
Example #35
0
    def test_lim(self):
        xml_string = read_xml("lim.xml", fixtures_path)
        ooxml_to_latex = OOXMLtoLatexParser.parse(
            xml_string, math_symbols=unicode_to_latex)

        self.assertMultiLineEqual(
            r"\underset{\ n\rightarrow  \infty }{lim}\left "
            r"({\ 1+}\frac{{\ 1}}{{\ n}}\right )^{{\ n}}",
            ooxml_to_latex.result)
Example #36
0
    def test_underset_is_not_a_limit(self):
        xml_string = read_xml("underset_is_not_limit.xml", bug_fixes_path)
        ooxml_to_latex = OOXMLtoLatexParser.parse(
            xml_string, math_symbols=unicode_to_latex)

        self.assertMultiLineEqual(
            r'\underbrace{{\ 7}^{{\ k}}}_{{\ n\ digitos}}<{\ 7}^{{\ k+1}}{\ =7}\left ({\ 7}^'
            r'{{\ k}}\right )<\underbrace{{\ 10}\left ({\ 7}^{{\ k}}\right )}_{{\ n+1'
            r'\ digitos}}', ooxml_to_latex.result)
Example #37
0
 def test_expansao_de_taylor(self):
     xml_string = read_xml("expansao_de_taylor.xml", bug_fixes_path)
     ooxml_to_latex = OOXMLtoLatexParser.parse(
         xml_string, math_symbols=unicode_to_latex)
     self.assertMultiLineEqual(
         r'{\ e}^{{\ x}}{\ =1+}\frac{{\ x}}{{\ 1\text{!} }}{\ +}\frac{{\ x}^{{\ 2}}}{{\ '
         r'2\text{!} }}{\ +}'
         r'\frac{{\ x}^{{\ 3}}}{{\ 3\text{!} }}{\ +\ldots  ,}{\ -\infty <x<\infty }',
         ooxml_to_latex.result)
Example #38
0
    def test_function(self):
        xml_string = read_xml('function.xml', fixtures_path)
        ooxml_to_latex = OOXMLtoLatexParser.parse(
            xml_string, math_symbols=unicode_to_latex)

        self.assertMultiLineEqual(
            r'{\ f}\left ({\ x}\right ){\ =}\sum  _{{\ i}{\ =}{\ 0}}^{{\ '
            r'\infty }}\frac{{\ f}^{\left ({\ i}\right )}\left ({\ 0}\right )}{{\ i}'
            r'{\ \text{!} }}{\ x}^{{\ i}}', ooxml_to_latex.result)
Example #39
0
 def test_integral_gaussiano(self):
     xml_string = read_xml("integral_gaussiano.xml", bug_fixes_path)
     ooxml_to_latex = OOXMLtoLatexParser.parse(
         xml_string, math_symbols=unicode_to_latex)
     self.assertMultiLineEqual(
         r'\int_{{\ -\infty }}^{{\ \infty }}{\ e}^{{\ -}{\ x}^{{\ 2}}}{\ dx}{\ =}\left '
         r'[\int_{{\ -\infty }}^{{\ \infty }}{\ e}^{{\ -}{\ x}^{{\ 2}}}{\ dx}\int_{{\ '
         r'-\infty }}^{{\ \infty }}{\ e}^{{\ -}{\ y}^{{\ 2}}}{\ dy}\right ]^{{\ 1}{\ / }{\ 2}}',
         ooxml_to_latex.result)
Example #40
0
 def test_integral_de_bloqueio_de_modo(self):
     xml_string = read_xml("integral_de_bloqueio_de_modo.xml",
                           bug_fixes_path)
     ooxml_to_latex = OOXMLtoLatexParser.parse(
         xml_string, math_symbols=unicode_to_latex)
     self.assertMultiLineEqual(
         r'\frac{{\ 1}}{{\ 2}{\ \pi  }}\int_{{\ 0}}^{{\ 2}{\ \pi  }}\frac{{\ \mathscr{d} }'
         r'{\ \theta  }}{{\ a}{\ +}{\ b}{\ sin}{\ \theta  }}{\ =}\frac{{\ 1}}{\sqrt{{\ a}^'
         r'{{\ 2}}{\ -}{\ b}^{{\ 2}}}}', ooxml_to_latex.result)
Example #41
0
    def test_sum(self):
        xml_string = read_xml("sum.xml", bug_fixes_path)
        ooxml_to_latex = OOXMLtoLatexParser.parse(
            xml_string, math_symbols=unicode_to_latex)

        self.assertEquals(
            r"\bigcap  _{}^{}{\ l=}\bigcap  _{{\ i\in I}}^{}{\ S}_{{\ i}}{\ =}"
            r"\left \{{\ x/ x\in }{\ S}_{{\ i}}{\ para\ cada\ i\in I}\right \}",
            ooxml_to_latex.result)
Example #42
0
    def test_multiple_fractions(self):
        xml_string = read_xml("multiple_fractions.xml", bug_fixes_path)
        ooxml_to_latex = OOXMLtoLatexParser.parse(
            xml_string, math_symbols=unicode_to_latex)

        self.assertMultiLineEqual(
            r"{\ S}_{{\ n}}{\ :}\frac{{\ 1}}{\sqrt{{\ 1}}}{\ +}\frac{{\ 1}}"
            r"{\sqrt{{\ 2}}}{\ +\cdots  +}\frac{{\ 1}}{\sqrt"
            r"{{\ n}}}{\ \geq  }\sqrt{{\ n}}", ooxml_to_latex.result)
    def test_new_output_less_than_old(self, statefile):
        file1 = 'throughput1.xml'

        self.warn = 8000000000
        self.crit = 9000000000
        self.interface = 'ethernet1/1'
        interfaces = []
        for interface in self.interface.split(','):
            interfaces.append(interface)

        check = check_pa.modules.throughput.create_check(self)
        objects = []
        for res in check.resources:
            objects.append(res)

        with responses.RequestsMock() as rsps:

            rsps.add(responses.GET,
                     objects[0].xml_obj.build_request_url(),
                     body=utils.read_xml(file1),
                     status=200,
                     content_type='document',
                     match_querystring=True)

            from nagiosplugin import Cookie

            with Cookie(statefile) as cookie:
                cookie[self.host + interfaces[0] + 'i'] = 10
                cookie[self.host + interfaces[0] + 'o'] = 10
                cookie[self.host + interfaces[0] + 't'] = 1441324800

            # Check will be executed exactly ten seconds later
            now = 1441324810
            xml_ibytes = 11
            xml_obytes = 9

            with mock.patch('check_pa.modules.throughput.get_time',
                            return_value=now):
                with mock.patch('check_pa.xml_reader.Finder.find_item',
                                side_effect=[xml_ibytes, xml_obytes]):
                    with pytest.raises(SystemExit):
                        check.main(verbose=3)

            with Cookie(statefile) as cookie:
                input = cookie.get(self.host + interfaces[0] + 'i')
                output = cookie.get(self.host + interfaces[0] + 'o')
                time = cookie.get(self.host + interfaces[0] + 't')

                assert input == xml_ibytes
                assert output == xml_obytes
                assert time == now

        assert check.exitcode == 3
        assert check.state == ServiceState(code=3, text='unknown')
        assert check.summary_str == 'Couldn\'t get a valid value: Found throughput less then old!'
Example #44
0
 def test_sessinfo(self):
     f = 'mock_result.xml'
     check = sessioninfo.create_check(self)
     with responses.RequestsMock() as rsps:
         rsps.add(responses.GET,
                  check.resources[0].xml_obj.build_request_url(),
                  body=utils.read_xml(f),
                  status=200,
                  content_type='document',
                  match_querystring=True)
         check.__call__()
     assert check.name == 'SessInfo'
Example #45
0
 def test_laplaciano_em_cartesiano_e_esfera(self):
     xml_string = read_xml("laplaciano_em_cartesiano_e_esfera.xml", bug_fixes_path)
     ooxml_to_latex = OOXMLtoLatexParser.parse(xml_string, math_symbols=unicode_to_latex)
     self.assertMultiLineEqual(r'{\ \nabla  }{\ \cdot  }{\ \nabla  }{\ \psi  }{\ =}\frac{{\ \partial  }^{{\ 2}}'
                               r'{\ \psi  }}{{\ \partial  }{\ x}^{{\ 2}}}{\ +}\frac{{\ \partial  }^{{\ 2}}'
                               r'{\ \psi  }}{{\ \partial  }{\ y}^{{\ 2}}}{\ +}\frac{{\ \partial  }^{{\ 2}}'
                               r'{\ \psi  }}{{\ \partial  }{\ z}^{{\ 2}}}{\ =}\frac{{\ 1}}{{\ r}^{{\ 2}}{\ sin}'
                               r'{\ \theta  }}\left [{\ sin}{\ \theta  }\frac{{\ \partial  }}{{\ \partial  }{\ r}}'
                               r'\left ({\ r}^{{\ 2}}\frac{{\ \partial  }{\ \psi  }}{{\ \partial  }{\ r}}\right )'
                               r'{\ +}\frac{{\ \partial  }}{{\ \partial  }{\ \theta  }}\left ({\ sin}{\ \theta  }'
                               r'\frac{{\ \partial  }{\ \psi  }}{{\ \partial  }{\ \theta  }}\right ){\ +}\frac'
                               r'{{\ 1}}{{\ sin}{\ \theta  }}\frac{{\ \partial  }^{{\ 2}}{\ \psi  }}{{\ \partial  }'
                               r'{\ \varphi  }^{{\ 2}}}\right ]',
                               ooxml_to_latex.result)
Example #46
0
    def test_bigcap(self):
        xml_string = read_xml("bigcap.xml", fixtures_path)
        ooxml_to_latex = OOXMLtoLatexParser.parse(
            xml_string, math_symbols=unicode_to_latex)

        self.assertEquals(r"\bigcap  _{}^{}", ooxml_to_latex.result)
Example #47
0
    def test_frac(self):
        xml_string = read_xml('frac.xml', fixtures_path)
        ooxml_to_latex = OOXMLtoLatexParser.parse(
            xml_string, math_symbols=unicode_to_latex)

        self.assertEquals(r'\frac{{\ 2}}{{\ 2}}', ooxml_to_latex.result)
Example #48
0
    def test_multiples_symbols_in_text(self):
        xml_string = read_xml('multiples_symbols_in_text.xml', fixtures_path)
        ooxml_to_latex = OOXMLtoLatexParser.parse(
            xml_string, math_symbols=unicode_to_latex)

        self.assertEquals(r'{\ \pi  n}', ooxml_to_latex.result)
Example #49
0
    def test_ast(self):
        xml_string = read_xml('ast.xml', fixtures_path)
        ooxml_to_latex = OOXMLtoLatexParser.parse(
            xml_string, math_symbols=unicode_to_latex)

        self.assertEquals('{\\ \\ast }', ooxml_to_latex.result)
Example #50
0
    def test_lim(self):
        xml_string = read_xml("lim.xml", fixtures_path)
        ooxml_to_latex = OOXMLtoLatexParser.parse(xml_string, math_symbols=unicode_to_latex)

        self.assertMultiLineEqual(r"\underset{\ n\rightarrow  \infty }{lim}\left "
                                  r"({\ 1+}\frac{{\ 1}}{{\ n}}\right )^{{\ n}}", ooxml_to_latex.result)
Example #51
0
    def test_bar(self):
        xml_string = read_xml('bar.xml', fixtures_path)
        ooxml_to_latex = OOXMLtoLatexParser.parse(
            xml_string, math_symbols=unicode_to_latex)

        self.assertEquals(r'\left |{\ 1}\right |', ooxml_to_latex.result)
Example #52
0
    def test_curly_braces(self):
        xml_string = read_xml('curly_braces.xml', fixtures_path)
        ooxml_to_latex = OOXMLtoLatexParser.parse(
            xml_string, math_symbols=unicode_to_latex)

        self.assertEquals(r'\left \{{\ 2}\right \}', ooxml_to_latex.result)
Example #53
0
    def test_sup_does_not_work(self):
        xml_string = read_xml("sup_does_not_work.xml", bug_fixes_path)
        ooxml_to_latex = OOXMLtoLatexParser.parse(xml_string, math_symbols=unicode_to_latex)

        self.assertMultiLineEqual(r'{\ l=}\left \{{\ S}_{{\ k}}\right \}_{{\ k=1}}^{{\ 5}}', ooxml_to_latex.result)
Example #54
0
    def test_times(self):
        xml_string = read_xml('times.xml', fixtures_path)
        ooxml_to_latex = OOXMLtoLatexParser.parse(
            xml_string, math_symbols=unicode_to_latex)

        self.assertEquals(r'{\ 1}{\ \cdot  }{\ 2}', ooxml_to_latex.result)
Example #55
0
    def test_forall(self):
        xml_string = read_xml('forall.xml', fixtures_path)
        ooxml_to_latex = OOXMLtoLatexParser.parse(
            xml_string, math_symbols=unicode_to_latex)

        self.assertEquals(r'{\ \forall  }', ooxml_to_latex.result)
Example #56
0
    def test_notin(self):
        xml_string = read_xml('notin.xml', fixtures_path)
        ooxml_to_latex = OOXMLtoLatexParser.parse(
            xml_string, math_symbols=unicode_to_latex)

        self.assertEquals(r'{\ 3}{\ \notin }{\ 1}', ooxml_to_latex.result)
Example #57
0
    def test_supseteq(self):
        xml_string = read_xml('supseteq.xml', fixtures_path)
        ooxml_to_latex = OOXMLtoLatexParser.parse(
            xml_string, math_symbols=unicode_to_latex)

        self.assertEquals(r'{\ 2}{\ \supseteq  }{\ 2}', ooxml_to_latex.result)
Example #58
0
    def test_dots(self):
        xml_string = read_xml("dots.xml", fixtures_path)
        ooxml_to_latex = OOXMLtoLatexParser.parse(
            xml_string, math_symbols=unicode_to_latex)

        self.assertEquals(r"{\ \cdots  }", ooxml_to_latex.result)
Example #59
0
    def test_propto(self):
        xml_string = read_xml('propto.xml', fixtures_path)
        ooxml_to_latex = OOXMLtoLatexParser.parse(
            xml_string, math_symbols=unicode_to_latex)

        self.assertEquals(r'{\ 5}{\ \propto  }{\ 10}', ooxml_to_latex.result)
Example #60
0
    def test_real_set(self):
        xml_string = read_xml('real_set.xml', fixtures_path)
        ooxml_to_latex = OOXMLtoLatexParser.parse(
            xml_string, math_symbols=unicode_to_latex)

        self.assertEquals(r'{\ \mathbb{R} }', ooxml_to_latex.result)