Exemplo n.º 1
0
    def test_law_paragraph_add_text_paragraphs(self):

        law = Law("test")

        para = LawParagraph(number="Test", name="Test", parent=law)

        number = "1"
        text = TextParagraph(text="My law text", number=number)

        para.add_text_paragraphs([text])

        self.assertEqual(len(para.children), 1)
        self.assertListEqual(para.children, [text])
        self.assertEqual(text.parent, para)
Exemplo n.º 2
0
    def test_merge_keywords(self):

        law = Law("test")
        law_para = LawParagraph("test", "number-test", law)
        self.service.merge_keywords(law_para, ["keyword1", "keyword2"])

        print(self.service.get_keywords_by_law_paragraph_id(law_para.id))
Exemplo n.º 3
0
def merge_text_paragraph(service: LawService,
                         law_id="law_test",
                         para_number="para_test",
                         text_number="text_test") -> TextParagraph:
    law = Law(law_id)
    para = LawParagraph(number=para_number, name="para_test_name", parent=law)
    text = TextParagraph(number=text_number,text="My text",  parent=para)
    service.merge_text_paragraph(text)
    return text
Exemplo n.º 4
0
    def get_law_paragraph(self, response):

        law_sec = response.css('h1 > span::text').extract()

        if len(law_sec) is not 2:
            return None

        number = law_sec[0].strip().replace(" ", "")
        return LawParagraph(name=law_sec[1], number=number)
Exemplo n.º 5
0
    def test_law_paragraph_create(self):
        number = "test"

        law = Law("test")

        para = LawParagraph(number=number, name="Test", parent=law)

        self.assertEqual(para.name, "Test")
        self.assertEqual(para.number, number)
        self.assertEqual(para.parent, law)
        self.assertEqual(para.id, "test-" + number)
Exemplo n.º 6
0
    def test_text_paragraph_create(self):
        number = "test"

        law = Law("test")

        para = LawParagraph(number=number, name="Test", parent=law)
        text = TextParagraph(number=number, text="my text", parent=para)

        self.assertEqual(text.text, "my text")
        self.assertEqual(text.number, number)
        self.assertEqual(text.parent, para)
        self.assertEqual(text.id, "test-test-" + number)
Exemplo n.º 7
0
    def test_law_add_paragraph(self):
        number = "test"

        law = Law("My-Id")

        para = LawParagraph(number=number, name="Test")

        law.add_law_paragraph(para)

        expect = {number: para}

        self.assertDictEqual(law.children, expect)
        self.assertEqual(para.parent, law)