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', '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_mur(1, expected_mur['no'], expected_mur['name'], mur_subject) actual_mur = next(get_murs(None)) assert actual_mur == expected_mur
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', 'election_cycles': [2016], 'doc_id': 'mur_1', 'subjects': [mur_subject], 'subject': { "text": [mur_subject] }, 'respondents': ["Bilbo Baggins", "Thorin Oakenshield"] } participants = [("Complainant", "Gollum"), ("Respondent", "Bilbo Baggins"), ("Respondent", "Thorin Oakenshield")] documents = [ ('A Category', 'Some text'), ('Another Category', 'Different text'), ] self.create_mur(case_id, expected_mur['no'], expected_mur['name'], mur_subject) 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 = document self.create_document(case_id, document_id, category, ocrtext) actual_mur = next(get_murs(None)) 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']] for d in actual_mur['documents']: assert re.match( r'https://BUCKET_NAME.s3-us-gov-west-1.amazonaws.com/legal/murs/current', d['url'])
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', '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_mur(case_id, expected_mur['no'], expected_mur['name'], mur_subject) 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_murs(None)) 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']]
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', '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_mur(case_id, expected_mur['no'], expected_mur['name'], mur_subject) 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_murs(None)) 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']]
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', '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_mur(1, expected_mur['no'], expected_mur['name'], mur_subject) actual_mur = next(get_murs(None)) assert actual_mur == expected_mur
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', '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', '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', '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_mur(1, expected_mur1['no'], expected_mur1['name'], mur_subject) self.create_mur(2, expected_mur2['no'], expected_mur2['name'], mur_subject) self.create_mur(3, expected_mur3['no'], expected_mur3['name'], mur_subject) gen = get_murs(None) assert(next(gen)) == expected_mur1 assert(next(gen)) == expected_mur2 assert(next(gen)) == expected_mur3 gen = get_murs('2') assert(next(gen)) == expected_mur2 assert(next(gen)) == expected_mur3
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' self.create_mur(case_id, case_no, name, mur_subject) 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_murs(None)) 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://api.fdsys.gov/link?collection=uscode&year=mostrecent&link-type=html&title=52' '§ion=30101'}, {'text': '456', 'title': '11', 'type': 'regulation', 'url': '/regulations/456/CURRENT'} ] }], 'subjects': ['Fraudulent misrepresentation'], 'respondents': [], 'documents': [], 'participants': [], 'no': '1', 'doc_id': 'mur_1', '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
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', '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', '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', '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_mur(1, expected_mur1['no'], expected_mur1['name'], mur_subject) self.create_mur(2, expected_mur2['no'], expected_mur2['name'], mur_subject) self.create_mur(3, expected_mur3['no'], expected_mur3['name'], mur_subject) gen = get_murs(None) assert(next(gen)) == expected_mur1 assert(next(gen)) == expected_mur2 assert(next(gen)) == expected_mur3 gen = get_murs('2') assert(next(gen)) == expected_mur2 assert(next(gen)) == expected_mur3
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' self.create_mur(case_id, case_no, name, mur_subject) 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_murs(None)) 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://api.fdsys.gov/link?collection=uscode&year=mostrecent&link-type=html&title=52' '§ion=30101'}, {'text': '456', 'title': '11', 'type': 'regulation', 'url': '/regulations/456/CURRENT'} ] }], 'subjects': ['Fraudulent misrepresentation'], 'respondents': [], 'documents': [], 'participants': [], 'no': '1', 'doc_id': 'mur_1', '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