def test_multiple_bill_id(self):
        json_path = 'Bills/by_id.json'
        collection = RTC.Bill
        TestBill = alter_response(json_path, collection)

        self.bill_id = 'hr2-112'
        self.bills = TestBill.get_mult_bills([self.bill_id], sections='')
        for i in self.bills:
            self.assertEqual(i['bill_id'], self.bill_id)
 def test_documents_get_by_date(self):
     json_path = 'Documents/by_date.json'
     collection = RTC.Documents
     TestDocument = alter_response(json_path, collection)
     
     self.date = '2011-03-14'
     self.documents = TestDocument.get_by_date(self.date, sections='')
     assert len(self.documents) != 0, 'There should be at least 1 documents'
     import re #using regex because 'posted_at' field has timestamp format
     for i in self.documents:
         assert re.match(self.date, i['posted_at']), 'timestamp field for document should contain requested date'
 def test_committeehearings_search(self):
     json_path = "CommitteeHearings/search.json"
     collection = RTC.CommitteeHearings
     TestCommitteeHearings = alter_response(json_path, collection)
     self.query = "examine"
     self.committeehearings = TestCommitteeHearings.search(self.query, sections="")
     # self.committeehearings = RTC.CommitteeHearings.search(self.query, sections='')
     self.assertNotEqual(len(self.committeehearings), 0, "There should be at least 1 result")
     # check that they all contain "examine"
     for i in self.committeehearings:
         self.assertIn(self.query, i["description"])
 def test_by_bioguide_id(self):
     json_path = 'Videos/by_bioguide.json'
     TestHouseVideos = alter_response(json_path, collection)
     results = RTC.HouseVideos.get_by_bioguide_id(bioguide_id)
     assert len(results) != 0, 'We expect at least one video to be returned'
     for r in results:
         for c in r['clips']:
             assert bioguide_id in c['bioguide_ids'], 'Expecited bioguide_id to ' +\
                     'be in bioguide_ids %s' % bioguide_id
     #should this be allowed if it connects to server?    
     results = RTC.HouseVideos.get_by_bioguide_id('nobioguididhere')
     assert len(results) == 0, 'there should be no legislators with this bioguide_id'
    def test_by_bill(self):
        json_path = 'Videos/by_bill.json'
        TestHouseVideos = alter_response(json_path, collection)

        videos = TestHouseVideos.get_by_bill(bill_id)
        assert len(videos) != 0, 'We expect at least one video to be returned'
        for v in videos:
            assert bill_id in v['bills'], 'The bill id that is being searched ' +\
                    'for should be in list of bills that are returned'

        videos = RTC.HouseVideos.get_by_bill('hrnotabill')
        assert len(videos) == 0, 'not bills should match this bill id'
    def test_by_legislator_name(self):

        json_path = 'Videos/by_name.json'
        TestHouseVideos = alter_response(json_path, collection)

        results = RTC.HouseVideos.get_by_legislator_name(leg_name)
        assert len(results) != 0, 'We expect at least one video to be returned'
        for r in results:
            for c in r['clips']:
                assert leg_name in c['legislator_names'], 'Expecited name to ' +\
                        'be in legislator_names %s' % leg_name
            
        results = RTC.HouseVideos.get_by_legislator_name('not a legislator name')
        assert len(results) == 0, 'there should be no legislators with this name'
    def test_committeehearings_get(self):
        json_path = "CommitteeHearings/get.json"
        collection = RTC.CommitteeHearings
        TestCommitteeHearings = alter_response(json_path, collection)
        self.date = "2011-10-06"
        self.chamber = "senate"
        self.committee_id = "SSEV"
        self.query = "uranium"

        self.committeehearings = TestCommitteeHearings.get(
            date=self.date, chamber=self.chamber, committee_id=self.committee_id, search=self.query
        )

        self.assertNotEqual(len(self.committeehearings), 0, "There should be at least 1 result")
        # self.committeehearings = RTC.CommitteeHearings.get(date=self.date,
        # chamber=self.chamber, committee_id=self.committee_id,
        # search=self.query)
        # check that it contains the keyword arguments
        for i in self.committeehearings:
            self.assertIn(self.date, i["legislative_day"], "Should have correct legi day")
            self.assertIn(self.chamber, i["chamber"], "Should have correct chamber")
            self.assertIn(self.committee_id, i["committee_id"], "Should have correct committee_id")
            self.assertIn(self.query, i["description"], "Should have correct query in description field")