Пример #1
0
    def test_get_citations_statute(self, reclassify_statutory_citation):
        reclassify_statutory_citation.return_value = ('99', '31999')
        citation_text = [
            '2 U.S.C. 23',
            '2 U.S.C. 23a',
            '2 U.S.C. 23a-1',
            '4 U.S.C. 23a-1(a)(i)',
            '4 U.S.C. 24ff',
        ]

        expected_calls = [
            mock.call('2', '23'),
            mock.call('2', '23a'),
            mock.call('2', '23a-1'),
            mock.call('4', '23a-1'),
            mock.call('4', '24ff'),
        ]

        citations = load_legal_docs.get_citations(citation_text)
        us_code = citations['us_code']

        assert len(us_code) == len(expected_calls)
        assert reclassify_statutory_citation.call_args_list == expected_calls

        assert us_code[0]['text'] == '99 U.S.C. 31999'
        assert us_code[1]['text'] == '99 U.S.C. 31999'
        assert us_code[2]['text'] == '99 U.S.C. 31999'
        assert us_code[3]['text'] == '99 U.S.C. 31999(a)(i)'
        assert us_code[4]['text'] == '99 U.S.C. 31999'

        url = us_code[0]['url']
        assert url == 'https://www.govinfo.gov/link/uscode/99/31999'
Пример #2
0
    def test_get_citations_regulation_no_section(self):
        citation_text = [
            '11 C.F.R. 19',
        ]

        citations = load_legal_docs.get_citations(citation_text)
        regulations = citations['regulations']
        assert len(regulations) == 1

        assert regulations[0]['url'] == '/regulations/19/CURRENT'
Пример #3
0
    def test_get_citations_statute(self,
                                   reclassify_archived_mur_statutory_citation):
        reclassify_archived_mur_statutory_citation.return_value = ('99',
                                                                   '31999')
        citation_text = [
            '2 U.S.C. 23',
            '2 U.S.C. 23a',
            '2 U.S.C. 23a-1',
            '4 U.S.C. 23a-1(a)(i)',
            '4 U.S.C. 24ff',
        ]

        expected_calls = [
            mock.call('2', '23'),
            mock.call('2', '23a'),
            mock.call('2', '23a-1'),
            mock.call('4', '23a-1'),
            mock.call('4', '24ff'),
        ]

        citations = load_legal_docs.get_citations(citation_text)
        us_code = citations['us_code']

        assert len(us_code) == len(expected_calls)
        assert reclassify_archived_mur_statutory_citation.call_args_list == expected_calls

        assert us_code[0]['text'] == '99 U.S.C. 31999'
        assert us_code[1]['text'] == '99 U.S.C. 31999'
        assert us_code[2]['text'] == '99 U.S.C. 31999'
        assert us_code[3]['text'] == '99 U.S.C. 31999(a)(i)'
        assert us_code[4]['text'] == '99 U.S.C. 31999'

        parsed_url = urllib.parse.urlparse(us_code[0]['url'])
        query = urllib.parse.parse_qs(parsed_url.query)

        assert query == dict([
            ('collection', ['uscode']),
            ('link-type', ['html']),
            ('year', ['mostrecent']),
            ('title', ['99']),
            ('section', ['31999']),
        ])