def derive_where_needed(self): """A handful of fields might be parse-able from the original XML. If we don't have values through modification, derive them here""" if not self.comments_close_on: self.comments_close_on = self.derive_closing_date() if not self.rins: self.rins = self.derive_rins() if not self.cfr_refs: self.cfr_refs = self.derive_cfr_refs() if not self.effective: self.effective = self.derive_effective_date() if not self.docket_ids: self.docket_ids = self.derive_docket_ids() supporting = self.supporting_documents needs_supporting = not supporting for docket_id in self.docket_ids: proposal = regs_gov.proposal(docket_id, self.version_id) if proposal and not self.comment_doc_id: self.comment_doc_id = proposal.regs_id if proposal and not self.primary_docket: self.primary_docket = docket_id if needs_supporting: supporting.extend(regs_gov.supporting_docs(docket_id)) self.supporting_documents = supporting
def derive_where_needed(self): """A handful of fields might be parse-able from the original XML. If we don't have values through modification, derive them here""" if not self.comments_close_on: self.comments_close_on = self.derive_closing_date() if not self.rins: self.rins = self.derive_rins() if not self.cfr_refs: self.cfr_refs = self.derive_cfr_refs() if not self.effective: self.effective = self.derive_effective_date() if not self.docket_ids: self.docket_ids = self.derive_docket_ids() supporting = self.supporting_documents needs_supporting = not supporting for docket_id in self.docket_ids: proposal = regs_gov.proposal(docket_id, self.version_id) if proposal and not self.comment_doc_id: self.comment_doc_id = proposal.regs_id if proposal and not self.primary_docket: self.primary_docket = docket_id if needs_supporting: supporting.extend(regs_gov.supporting_docs(docket_id)) self.supporting_documents = supporting
def test_supporting_docs(self): """Should filter the results to the appropriate types""" self.expect_json_http({'documents': [ dict(documentId='1', documentType='Notice', title='a'), dict(documentId='2', documentType='Other', title='b'), dict(documentId='3', documentType='Final Rule', title='c'), dict(documentId='4', documentType='Supporting & Related Material', title='d')]}) self.assertEqual( list(regs_gov.supporting_docs('docket')), [regs_gov.RegsGovDoc('2', 'b'), regs_gov.RegsGovDoc('4', 'd')])