def test_500_fetch_error(self): path = '/foobar/xzurgsa/1/23/42-3.14' body = 'xozers12deA=41.' e = DidelEntity() e.path = path responses.add(responses.GET, self.url(path), body=body, status=500) self.assertFalse(e.fetch(self.session)) self.assertEquals(1, len(responses.calls)) self.assertEquals(body, responses.calls[0].response.text)
def test_populate_not_implemented_on_base_class(self): e = DidelEntity() self.assertRaises(NotImplementedError, lambda: e.populate(self.soup, self.session))
def test_dont_fetch_without_path(self): e = DidelEntity() self.assertFalse(e.fetch(self.session))
def test_dont_fetch_without_populate_method(self): e = DidelEntity() delattr(DidelEntity, 'populate') self.assertFalse(e.fetch(self.session))
def test_trying_to_access_subresource_fails_if_not_populated(self): e = DidelEntity() e.add_resource('foo', DidelEntity()) self.assertRaises(DidelError, lambda: e.foo)
def test_base_url(self): path = 'xzrd1d$z9' e = DidelEntity() e.path = path self.assertEquals(self.url(path), e.url())
def test_base_entity_should_not_be_populated(self): e = DidelEntity() self.assertFalse(e.is_populated())