Example #1
0
def test_update_case_was_moved_but_exists_in_db_non_identical(
        moved_case_raw_dict, moved_case_raw_dict_new, rf_courts):
    FirstParser.process_duplicates = process_duplicates
    c_new = FirstParser(
        stage=1,
        codex='koap',
        court=Court.objects.filter(title='Невский районный суд').first(
        )).save_from_raw(moved_case_raw_dict_new)
    moved_case_raw_dict['defenses'].append({
        'defendant': "Ипатов Н.К.",
        "codex_articles": '20.2 ч.5'
    })
    c_old = FirstParser(
        stage=1,
        codex='koap',
        court=Court.objects.filter(title='Невский районный суд').first(
        )).save_from_raw(moved_case_raw_dict)
    print('saved 2 cases')
    assert Case.objects.count() == 2
    c_old.update_case()
    print('updated')
    assert Case.objects.count() == 1
    assert c_old.defenses.count() == 2
    assert c_old.url != moved_case_raw_dict['url']
    assert c_old.url == moved_case_raw_dict_new['url']
Example #2
0
def test_merge_multiple_duplicates(rf_courts, koap_articles, mocker):
    court = Court.objects.filter(title='Выборгский районный суд').first()

    url = 'https://vbr--spb.sudrf.ru/modules.php?name=sud_delo&name_op=case&case_id=401366335&case_uid=f6a0de4d-819c-4458-9577-0565645e9c89&result=0&new=&delo_id=1502001&srv_num=1'  # 'https://oktibrsky--spb.sudrf.ru/modules.php?name=sud_delo&srv_num=1&name_op=case&case_id=419372260&case_uid=867f0e26-b0ea-40ec-8d30-be8f8f1fca9c&delo_id=1500001'
    FirstParser(court=court, stage=2, codex='koap').save_cases(urls=[
        url,
    ])
    old_case_query = ClonableCase.objects.all()
    old_case_query.update(
        **{
            'url': 'example_url_1',
            'result_text': 'result_text_1',
            'appeal_date': timezone.now()
        })
    another_old_case = old_case_query.first().make_clone(
        attrs={
            'url': 'example_url_2',
            'result_text': 'example_result_text_2',
            'protocol_number': 'example_number'
        })
    FirstParser(court=court, stage=2, codex='koap').save_cases(urls=[
        url,
    ])
    new_case = ClonableCase.objects.first()
    assert new_case
    assert ClonableCase.objects.count() == 1
    assert new_case.url == url
    assert new_case.result_text == 'example_result_text_2'
    assert new_case.protocol_number == '7'
Example #3
0
def test_update_case_was_moved(moved_case_raw_dict, rf_courts):
    c_old = FirstParser(
        stage=1,
        codex='koap',
        court=Court.objects.filter(title='Невский районный суд').first(
        )).save_from_raw(moved_case_raw_dict)
    c_old.update_case()
    assert Case.objects.count() == 1
    print(c_old.url, 'NEW_URL')
    assert c_old.url != moved_case_raw_dict['url']
Example #4
0
def test_update_case_change(case_raw_dict, rf_courts):
    parser = FirstParser(
        court=Court.objects.filter(title='Выборгский районный суд').first(),
        stage=2,
        codex='koap')
    case_raw_dict['case_uid'] = 'blabla'
    parser.save_from_raw(case_raw_dict)
    c_old = Case.objects.first()
    c_old.update_case()
    assert c_old.case_uid != 'blabla'
Example #5
0
def test_update_case_dont_remove(case_raw_dict, rf_courts):
    parser = FirstParser(
        court=Court.objects.filter(title='Выборгский районный суд').first(),
        stage=2,
        codex='koap')
    case_raw_dict['appeal_result'] = 'blabla'
    parser.save_from_raw(case_raw_dict)
    c_old = Case.objects.first()
    c_old.update_case()
    assert c_old.appeal_result == 'blabla'
Example #6
0
def test_non_double_processing(rf_courts, koap_articles):
    court = Court.objects.filter(title='Выборгский районный суд').first()
    court2 = Court.objects.filter(title='Кировский районный суд').first()
    urls = [
        'https://vbr--spb.sudrf.ru/modules.php?name=sud_delo&name_op=case&case_id=401366335&case_uid=f6a0de4d-819c-4458-9577-0565645e9c89&result=0&new=&delo_id=1502001&srv_num=1',
        'https://krv--spb.sudrf.ru/modules.php?name=sud_delo&srv_num=1&name_op=case&case_id=422424346&case_uid=cdda91f9-80db-41e3-92dc-fe32f63ee605&delo_id=1500001'
    ]
    FirstParser(court=court, stage=2, codex='koap').save_cases(urls=[
        urls[0],
    ])
    FirstParser(court=court2, stage=1, codex='koap').save_cases(urls=[
        urls[1],
    ])
    assert (Case.objects.count() == 2)
    assert (Case.duplicates.count() == 0)
Example #7
0
def test_raw_case_info_first(rf_courts, koap_articles):
    url = 'https://vbr--spb.sudrf.ru/modules.php?name=sud_delo&name_op=case&case_id=401366335&case_uid=f6a0de4d-819c-4458-9577-0565645e9c89&result=0&new=&delo_id=1502001&srv_num=1'  # 'https://oktibrsky--spb.sudrf.ru/modules.php?name=sud_delo&srv_num=1&name_op=case&case_id=419372260&case_uid=867f0e26-b0ea-40ec-8d30-be8f8f1fca9c&delo_id=1500001'
    case_info = FirstParser().get_raw_case_information(url)

    print(case_info['defenses'])
    assert case_info
    assert case_info['events'] != []
    FirstParser(
        court=Court.objects.filter(title='Выборгский районный суд').first(),
        stage=2,
        codex='koap').save_cases(urls=[
            url,
        ])
    case = Case.objects.first()
    assert Advocate.objects.count()
    assert Prosecutor.objects.count()
Example #8
0
def test_double_processing_identical(rf_courts, koap_articles):
    court = Court.objects.filter(title='Выборгский районный суд').first()
    url = 'https://vbr--spb.sudrf.ru/modules.php?name=sud_delo&name_op=case&case_id=401366335&case_uid=f6a0de4d-819c-4458-9577-0565645e9c89&result=0&new=&delo_id=1502001&srv_num=1'  # 'https://oktibrsky--spb.sudrf.ru/modules.php?name=sud_delo&srv_num=1&name_op=case&case_id=419372260&case_uid=867f0e26-b0ea-40ec-8d30-be8f8f1fca9c&delo_id=1500001'
    FirstParser(court=court, stage=2, codex='koap').save_cases(urls=[
        url,
    ])
    old_case_query = Case.objects.all()
    old_case_query.update(**{'url': 'example_url_1'})

    FirstParser(court=court, stage=2, codex='koap').save_cases(urls=[
        url,
    ])  # save a new identical case but with another url

    new_case = Case.objects.first()
    assert new_case
    assert Case.objects.count() == 1
    assert new_case.url == url
Example #9
0
def test_update_case_was_moved_but_exists_in_db(moved_case_raw_dict,
                                                moved_case_raw_dict_new,
                                                rf_courts):
    FirstParser.process_duplicates = process_duplicates
    c_new = FirstParser(
        stage=1,
        codex='koap',
        court=Court.objects.filter(title='Невский районный суд').first(
        )).save_from_raw(moved_case_raw_dict_new)
    c_old = FirstParser(
        stage=1,
        codex='koap',
        court=Court.objects.filter(title='Невский районный суд').first(
        )).save_from_raw(moved_case_raw_dict)
    assert Case.objects.count() == 2
    c_old.update_case()
    assert Case.objects.count() == 1
    assert c_old.url != moved_case_raw_dict['url']
    assert c_old.url == moved_case_raw_dict_new['url']
Example #10
0
def test_update_case_correct_defenses(case_raw_dict, rf_courts):
    parser = FirstParser(
        court=Court.objects.filter(title='Выборгский районный суд').first(),
        stage=2,
        codex='koap')
    error_defense_advocate_name = {
        'defendant': 'Рассохин А.А.',
        'codex_articles': ''
    }
    error_defense_prosecutor_name = {
        'defendant': 'Ильин Н.В.',
        'codex_articles': ''
    }
    case_raw_dict['defenses'].append(error_defense_advocate_name)
    case_raw_dict['defenses'].append(error_defense_prosecutor_name)
    c = parser.save_from_raw(case_raw_dict)
    c.update_case()
    # assert len(c.defenses.all()) == 1 #WTF
    assert len(c.get_advocates()) == 2
    assert len(c.get_prosecutors()) == 2
Example #11
0
def test_moved_finder(rf_courts, koap_articles):
    url = 'https://vbr--spb.sudrf.ru/modules.php?name=sud_delo&name_op=case&case_id=401366335&case_uid=f6a0de4d-819c-4458-9577-0565645e9c89&result=0&new=&delo_id=1502001&srv_num=1'  # 'https://oktibrsky--spb.sudrf.ru/modules.php?name=sud_delo&srv_num=1&name_op=case&case_id=419372260&case_uid=867f0e26-b0ea-40ec-8d30-be8f8f1fca9c&delo_id=1500001'

    FirstParser(
        court=Court.objects.filter(title='Выборгский районный суд').first(),
        stage=2,
        codex='koap').save_cases(urls=[
            url,
        ])
    case = Case.objects.first()
    assert (case)
    assert url != case.search_for_new_url()
Example #12
0
    def handle(self, *args, **options):
        urls = [
            'https://muhorshibirsky--bur.sudrf.ru/modules.php?name=sud_delo&srv_num=1&name_op=case&case_id=34508304'
            '&case_uid=49e857f5-f597-4686-aa0a-3cadd78ff2dd&delo_id=1500001'
        ]

        # urls=['https://ordjonikidzovsky--bkr.sudrf.ru/modules.php?name=sud_delo&srv_num=1&name_op=case&case_id
        # =527375399&delo_id=1500001']
        # urls=['https://birsky--bkr.sudrf.ru/modules.php?name=sud_delo&srv_num=1&name_op=case&case_id=470082934
        # &delo_id=1500001']
        # RFCasesGetter(codex='koap').save_cases(urls=urls)
        FirstParser(court=None, stage=1, codex='koap',
                    url=None).save_cases(urls=urls)
Example #13
0
    def update_case(self, case):

        from oi_sud.cases.parsers.rf import FirstParser, SecondParser
        from oi_sud.cases.parsers.moscow import MoscowParser

        try:
            parser = None
            codex = 'koap' if case.type == 1 else 'uk'
            if case.court.site_type == 1:
                parser = FirstParser(court=case.court,
                                     stage=case.stage,
                                     codex=codex)
            elif case.court.site_type == 2:
                parser = SecondParser(court=case.court,
                                      stage=case.stage,
                                      codex=codex)
Example #14
0
def test_get_raw_first():
    urls = [
        'https://vyatskopolyansky--kir.sudrf.ru/modules.php?name=sud_delo&srv_num=1&name_op=case&case_id=80099975&case_uid=6d2f602e-0770-4180-ba35-3e6790dc5a66&delo_id=1500001&nc=1'
    ]
    for url in urls:
        case_info = FirstParser().get_raw_case_information(url)