def test_it_ignores_expired_pad_bins(self, nycdb): tiny = fixtures.load_hpd_registration("tiny-landlord.json") medium = fixtures.load_hpd_registration("medium-landlord.json") medium.registrationenddate = datetime.date(2000, 1, 1) medium.save() boop = get_landlord(tiny.pad_bbl, medium.pad_bin) assert isinstance(boop, Individual)
def test_it_returns_none_on_db_error(self, nycdb): with patch.object(HPDRegistration.objects, 'from_pad_bbl') as fpbblmock: fpbblmock.side_effect = DatabaseError() with patch('nycdb.models.logger.exception') as loggermock: assert get_landlord('1234567890') is None loggermock.assert_called_once_with( f'Error while retrieving data from NYCDB')
def test_it_returns_contact_of_pad_bbl_on_success(self, nycdb): tiny = fixtures.load_hpd_registration("tiny-landlord.json") boop = get_landlord(tiny.pad_bbl) assert isinstance(boop, Individual) assert boop.name == "BOOP JONES"
def test_it_returns_none_if_pad_bbl_does_not_exist(self, nycdb): assert get_landlord('1234567890') is None
def test_it_returns_none_if_nycdb_is_disabled(self): assert get_landlord('') is None assert get_landlord('blarg') is None
def test_it_falls_back_to_pad_bbl_if_pad_bin_fails(self, nycdb): tiny = fixtures.load_hpd_registration("tiny-landlord.json") boop = get_landlord(tiny.pad_bbl, '999') assert isinstance(boop, Individual)
def test_it_returns_contact_of_pad_bin_on_success(self, nycdb): tiny = fixtures.load_hpd_registration("tiny-landlord.json") boop = get_landlord('zzzzz', tiny.pad_bin) assert isinstance(boop, Individual)