Ejemplo n.º 1
0
    def test_unpublished_mur(self, get_bucket):
        mur_subject = 'Unpublished MUR'
        expected_mur = {
            'no': '101',
            'name': 'Test Unpublished MUR',
            'mur_type': 'current',
            'election_cycles': [2016],
            'doc_id': 'mur_101',
            'published_flg': False,
            'participants': [],
            'subjects': [mur_subject],
            'respondents': [],
            'documents': [],
            'commission_votes': [],
            'dispositions': [],
            'close_date': None,
            'open_date': None,
            'url': '/legal/matter-under-review/101/',
            'sort1': -101,
            'sort2': None
        }
        self.create_case(101, expected_mur['no'], expected_mur['name'],
                         mur_subject, expected_mur['published_flg'])
        actual_mur = next(get_cases('MUR'))

        assert actual_mur == expected_mur
Ejemplo n.º 2
0
    def test_simple_adr(self, get_bucket):
        adr_subject = 'Personal use'
        expected_adr = {
            'no': '1',
            'name': 'Simple ADR',
            'election_cycles': [2016],
            'doc_id': 'adr_1',
            'published_flg': True,
            'participants': [],
            'subjects': [adr_subject],
            'respondents': [],
            'documents': [],
            'commission_votes': [],
            'dispositions': [],
            'close_date': None,
            'open_date': None,
            'url': '/legal/alternative-dispute-resolution/1/',
            'sort1': -1,
            'sort2': None
        }
        self.create_case(1, expected_adr['no'], expected_adr['name'],
                         adr_subject, expected_adr['published_flg'], 'ADR')
        actual_adr = next(get_cases('ADR'))

        assert actual_adr == expected_adr
Ejemplo n.º 3
0
    def test_simple_mur(self, get_bucket):
        mur_subject = 'Fraudulent misrepresentation'
        expected_mur = {
            'no': '1',
            'name': 'Simple MUR',
            'mur_type': 'current',
            'election_cycles': [2016],
            'doc_id': 'mur_1',
            'published_flg': True,
            'participants': [],
            'subjects': [mur_subject],
            'respondents': [],
            'documents': [],
            'commission_votes': [],
            'dispositions': [],
            'close_date': None,
            'open_date': None,
            'url': '/legal/matter-under-review/1/',
            'sort1': -1,
            'sort2': None,
        }
        self.create_case(
            1,
            expected_mur['no'],
            expected_mur['name'],
            mur_subject,
            expected_mur['published_flg'],
        )
        actual_mur = next(get_cases('MUR'))

        assert actual_mur == expected_mur
Ejemplo n.º 4
0
    def test_mur_with_participants_and_documents(self, get_bucket,
                                                 get_credential):
        case_id = 1
        mur_subject = 'Fraudulent misrepresentation'
        expected_mur = {
            'no': '1',
            'name': 'MUR with participants',
            'mur_type': 'current',
            'published_flg': True,
            'election_cycles': [2016],
            'doc_id': 'mur_1',
            'subjects': [mur_subject],
            'respondents': ["Bilbo Baggins", "Thorin Oakenshield"],
        }
        participants = [
            ("Complainant", "Gollum"),
            ("Respondent", "Bilbo Baggins"),
            ("Respondent", "Thorin Oakenshield"),
        ]
        filename = "Some File.pdf"
        documents = [
            (
                'A Category',
                'Some text',
                'legal/murs/{0}/{1}'.format('1', filename.replace(' ', '-')),
            ),
            (
                'Another Category',
                'Different text',
                'legal/murs/{0}/{1}'.format('1', filename.replace(' ', '-')),
            ),
        ]

        self.create_case(
            case_id,
            expected_mur['no'],
            expected_mur['name'],
            mur_subject,
            expected_mur['published_flg'],
        )
        for entity_id, participant in enumerate(participants):
            role, name = participant
            self.create_participant(case_id, entity_id, role, name)
        for document_id, document in enumerate(documents):
            category, ocrtext, url = document
            self.create_document(case_id, document_id, category, ocrtext,
                                 filename)

        actual_mur = next(get_cases('MUR'))

        for key in expected_mur:
            assert actual_mur[key] == expected_mur[key]

        assert participants == [(p['role'], p['name'])
                                for p in actual_mur['participants']]

        assert [(d[0], d[1], len(d[1]))
                for d in documents] == [(d['category'], d['text'], d['length'])
                                        for d in actual_mur['documents']]
Ejemplo n.º 5
0
    def test_admin_fine(self, get_bucket):
        dummy_subject = 'Personal use'
        expected_admin_fine = {
            'no': '1',
            'name': 'Big Admin Fine',
            'doc_id': 'af_1',
            'published_flg': True,
            'documents': [],
            'commission_votes': [{
                'action': None,
                'vote_date': None
            }],
            'committee_id': 'C001',
            'report_year': '2016',
            'report_type': '30G',
            'reason_to_believe_action_date': None,
            'reason_to_believe_fine_amount': 5000,
            'challenge_receipt_date': None,
            'challenge_outcome': '',
            'final_determination_date': None,
            'final_determination_amount': 5000,
            'check_amount': 5000,
            'treasury_referral_date': None,
            'treasury_referral_amount': 0,
            'petition_court_filing_date': None,
            'petition_court_decision_date': None,
            'url': '/legal/administrative-fine/1/',
            'sort1': -1,
            'sort2': None,
        }
        self.create_case(
            1,
            expected_admin_fine['no'],
            expected_admin_fine['name'],
            dummy_subject,
            expected_admin_fine['published_flg'],
            'AF',
        )
        self.create_admin_fine(
            1,
            expected_admin_fine['committee_id'],
            expected_admin_fine['report_year'],
            expected_admin_fine['report_type'],
            expected_admin_fine['reason_to_believe_action_date'],
            expected_admin_fine['reason_to_believe_fine_amount'],
            expected_admin_fine['challenge_receipt_date'],
            expected_admin_fine['challenge_outcome'],
            expected_admin_fine['final_determination_date'],
            expected_admin_fine['final_determination_amount'],
            expected_admin_fine['check_amount'],
            expected_admin_fine['treasury_referral_date'],
            expected_admin_fine['treasury_referral_amount'],
            expected_admin_fine['petition_court_filing_date'],
            expected_admin_fine['petition_court_decision_date'],
        )
        actual_admin_fine = next(get_cases('AF'))

        assert actual_admin_fine == expected_admin_fine
Ejemplo n.º 6
0
    def test_mur_offsets(self, get_bucket):
        mur_subject = 'Fraudulent misrepresentation'
        expected_mur1 = {
            'no': '1',
            'name': 'Simple MUR1',
            'mur_type': 'current',
            'election_cycles': [2016],
            'doc_id': 'mur_1',
            'published_flg': True,
            'participants': [],
            'subjects': [mur_subject],
            'respondents': [],
            'documents': [],
            'commission_votes': [],
            'dispositions': [],
            'close_date': None,
            'open_date': None,
            'url': '/legal/matter-under-review/1/',
            'sort1': -1,
            'sort2': None
        }
        expected_mur2 = {
            'no': '2',
            'name': 'Simple MUR2',
            'mur_type': 'current',
            'election_cycles': [2016],
            'doc_id': 'mur_2',
            'published_flg': True,
            'participants': [],
            'subjects': [mur_subject],
            'respondents': [],
            'documents': [],
            'commission_votes': [],
            'dispositions': [],
            'close_date': None,
            'open_date': None,
            'url': '/legal/matter-under-review/2/',
            'sort1': -2,
            'sort2': None
        }
        expected_mur3 = {
            'no': '3',
            'name': 'Simple MUR',
            'mur_type': 'current',
            'election_cycles': [2016],
            'doc_id': 'mur_3',
            'published_flg': True,
            'participants': [],
            'subjects': [mur_subject],
            'respondents': [],
            'documents': [],
            'commission_votes': [],
            'dispositions': [],
            'close_date': None,
            'open_date': None,
            'url': '/legal/matter-under-review/3/',
            'sort1': -3,
            'sort2': None
        }
        self.create_case(1, expected_mur1['no'], expected_mur1['name'],
                         mur_subject, expected_mur1['published_flg'])
        self.create_case(2, expected_mur2['no'], expected_mur2['name'],
                         mur_subject, expected_mur2['published_flg'])
        self.create_case(3, expected_mur3['no'], expected_mur3['name'],
                         mur_subject, expected_mur3['published_flg'])

        gen = get_cases('MUR')
        assert (next(gen)) == expected_mur1
        assert (next(gen)) == expected_mur2
        assert (next(gen)) == expected_mur3

        actual_murs = [mur for mur in get_cases('MUR', '2')]
        assert actual_murs == [expected_mur2]
Ejemplo n.º 7
0
    def test_mur_with_disposition(self, get_bucket, get_credential):
        case_id = 1
        case_no = '1'
        name = 'Open Elections LLC'
        mur_subject = 'Fraudulent misrepresentation'
        pg_date = '2016-10-08'
        published_flg = True
        self.create_case(case_id, case_no, name, mur_subject, published_flg)

        entity_id = 1
        event_date = '2005-01-01'
        event_id = 1
        self.create_calendar_event(entity_id, event_date, event_id, case_id)

        entity_id = 1
        event_date = '2008-01-01'
        event_id = 2
        self.create_calendar_event(entity_id, event_date, event_id, case_id)

        parent_event = 0
        event_name = 'Conciliation-PPC'
        path = ''
        is_key_date = 0
        check_primary_respondent = 0
        pg_date = '2016-01-01'
        self.create_event(event_id, parent_event, event_name, path,
                          is_key_date, check_primary_respondent, pg_date)

        first_name = "Commander"
        last_name = "Data"
        middle_name, prefix, suffix, type = ('', '', '', '')
        self.create_entity(entity_id, first_name, last_name, middle_name,
                           prefix, suffix, type, name, pg_date)

        master_key = 1
        detail_key = 1
        relation_id = 1
        self.create_relatedobjects(master_key, detail_key, relation_id)

        settlement_id = 1
        initial_amount = 0
        final_amount = 50000
        amount_received, settlement_type = (0, '')
        self.create_settlement(settlement_id, case_id, initial_amount,
                               final_amount, amount_received, settlement_type,
                               pg_date)

        stage = 'Closed'
        statutory_citation = '431'
        regulatory_citation = '456'
        self.create_violation(case_id, entity_id, stage, statutory_citation,
                              regulatory_citation)

        commission_id = 1
        agenda_date = event_date
        vote_date = event_date
        action = 'Conciliation Reached.'
        self.create_commission(commission_id, agenda_date, vote_date, action,
                               case_id, pg_date)

        actual_mur = next(get_cases('MUR'))

        expected_mur = {
            'commission_votes': [{
                'action': 'Conciliation Reached.',
                'vote_date': datetime(2008, 1, 1, 0, 0)
            }],
            'dispositions': [{
                'disposition':
                'Conciliation-PPC',
                'respondent':
                'Open Elections LLC',
                'penalty':
                Decimal('50000.00'),
                'citations': [{
                    'text':
                    '431',
                    'title':
                    '2',
                    'type':
                    'statute',
                    'url':
                    'https://www.govinfo.gov/link/uscode/52/30101'
                }, {
                    'text': '456',
                    'title': '11',
                    'type': 'regulation',
                    'url': '/regulations/456/CURRENT'
                }]
            }],
            'subjects': ['Fraudulent misrepresentation'],
            'respondents': [],
            'documents': [],
            'participants': [],
            'no':
            '1',
            'doc_id':
            'mur_1',
            'published_flg':
            True,
            'mur_type':
            'current',
            'name':
            'Open Elections LLC',
            'open_date':
            datetime(2005, 1, 1, 0, 0),
            'election_cycles': [2016],
            'close_date':
            datetime(2008, 1, 1, 0, 0),
            'url':
            '/legal/matter-under-review/1/',
            'sort1':
            -1,
            'sort2':
            None
        }
        assert actual_mur == expected_mur