Skip to content

Commit

Permalink
new unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fchrubasik authored Dec 15, 2019
1 parent 2b2e8a4 commit 4ae21bf
Showing 1 changed file with 177 additions and 1 deletion.
178 changes: 177 additions & 1 deletion refex/tests/test_law_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,183 @@ def test_extract14(self):
}
])

def test_extract15(self):
self.assert_refs([
{
'resource': 'law/extract15.txt',
'refs': [
Ref(ref_type=RefType.LAW, book='vwgo', section='124'),
Ref(ref_type=RefType.LAW, book='vwgo', section='124a'),
]
}
], True)

def test_extract16(self):
self.assert_refs([
{
'resource': 'law/extract16.txt',
'refs': [
Ref(ref_type=RefType.LAW, book='vwgo', section='167'),
Ref(ref_type=RefType.LAW, book='zpo', section='708'),
Ref(ref_type=RefType.LAW, book='zpo', section='711'),
]
}
], True)

def test_extract17(self):
self.assert_refs([
{
'resource': 'law/extract17.txt',
'refs': [
Ref(ref_type=RefType.LAW, book='baugb', section='34'),
Ref(ref_type=RefType.LAW, book='baunvo', section='2'),
Ref(ref_type=RefType.LAW, book='baunvo', section='3'),
Ref(ref_type=RefType.LAW, book='baunvo', section='4'),

]
}
], True)

def test_extract18(self):
self.assert_refs([
{
'resource': 'law/extract18.txt',
'refs': [
Ref(ref_type=RefType.LAW, book='vwgo', section='154'),
Ref(ref_type=RefType.LAW, book='vwgo', section='154'),
Ref(ref_type=RefType.LAW, book='vwgo', section='162'),
]
}
], True)

def test_extract19(self):
self.assert_refs([
{
'resource': 'law/extract19.txt',
'refs': [
Ref(ref_type=RefType.LAW, book='vwgo', section='42')
]
}
], True)


def test_extract20(self):
self.assert_refs([
{
'resource': 'law/extract20.txt',
'refs': [
Ref(ref_type=RefType.LAW, book='vwgo', section='154'),
Ref(ref_type=RefType.LAW, book='vwgo', section='154'),
Ref(ref_type=RefType.LAW, book='vwgo', section='162'),
]
}
], True)

def test_extract21(self):
self.assert_refs([
{
'resource': 'law/extract21.txt',
'refs': [
# § 77 Abs. 1 Satz 1, 1. Halbsatz AsylG
Ref(ref_type=RefType.LAW, book='asylg', section='77')
]
}
], True)

def test_extract22(self):
self.assert_refs([
{
'resource': 'law/extract22.txt',
'refs': [
# §§ 52 Abs. 1; 53 Abs. 2 Nr. 1; 63 Abs. 2 StPO
Ref(ref_type=RefType.LAW, book='stpo', section='52'),
Ref(ref_type=RefType.LAW, book='stpo', section='53'),
Ref(ref_type=RefType.LAW, book='stpo', section='63'),

]
}
], True)

@skip
def test_extract23(self):
self.assert_refs([
{
'resource': 'law/extract23.txt',
'refs': [
# Art 12 Abs 1 GG
Ref(ref_type=RefType.LAW, book='gg', section='1'),
Ref(ref_type=RefType.LAW, book='gg', section='2'),
Ref(ref_type=RefType.LAW, book='gg', section='3'),
Ref(ref_type=RefType.LAW, book='gg', section='12'),

# Ref(ref_type=RefType.LAW, book='stpo', section='53'),
# Ref(ref_type=RefType.LAW, book='stpo', section='63'),

]
}
], True)

# @skip
def test_extract24(self):
self.assert_refs([
{
'resource': 'law/extract24.txt',
'refs': [
# §§ 556d, 556g BGB
Ref(ref_type=RefType.LAW, book='bgb', section='556d'),
Ref(ref_type=RefType.LAW, book='bgb', section='556e'),

]
}
], True)

def test_extract25(self):
self.assert_refs([
{
'resource': 'law/extract25.txt',
'refs': [
# §§ 1, 2 Abs. 2, 3, 10 Abs. 1 Nr. 1 BGB
Ref(ref_type=RefType.LAW, book='bgb', section='1'),
Ref(ref_type=RefType.LAW, book='bgb', section='2'),
Ref(ref_type=RefType.LAW, book='bgb', section='3'),
Ref(ref_type=RefType.LAW, book='bgb', section='10'),

]
}
], True)


def test_extract26(self):
self.assert_refs([
{
'resource': 'law/extract26.txt',
'refs': [
# § 3d AsylG, aber auch § 123 VwGO. ... auch §§ 3, 3b AsylG
Ref(ref_type=RefType.LAW, book='asylg', section='3'),
Ref(ref_type=RefType.LAW, book='asylg', section='3b'),
Ref(ref_type=RefType.LAW, book='asylg', section='3d'),
Ref(ref_type=RefType.LAW, book='vwgo', section='123'),

]
}
], True)

def test_extract27(self):
self.assert_refs([
{
'resource': 'law/extract27.txt',
'refs': [
# duplicated book code parts
Ref(ref_type=RefType.LAW, book='sgg', section='136'),
Ref(ref_type=RefType.LAW, book='sgb x', section='48'),

]
}
], True)




def test_citation_styles(self):
# TODO insert citation styles into text, random location, single and multiple occurences, test on marker text
with open(os.path.join(self.resource_dir, 'citation_styles.txt')) as f:
Expand Down Expand Up @@ -300,4 +477,3 @@ def test_alternative_law_book_regex(self):
for code in self.get_book_codes_from_file() + ['SGB X', 'SGG', 'SGB IV']:
if not pattern.search(code):
print(code)

0 comments on commit 4ae21bf

Please sign in to comment.