def get(self, action, params=None): """Make GET request.""" return self.request( utils.join_url(self.base_url, action), 'GET', params=params or {}, )
def get(cls, api, resource_id): """Returns one object of this Resource. You have to give one keyword argument to find the object. """ url = utils.join_url(cls.get_endpoint_url(), resource_id) return cls(api, api.get(url))
def get_field_order(cls, api): """Return the list of fieldnames in order as defined in the MLS.""" url = utils.join_url( REST_API_URL, REST_API_VERSION, 'field_order', cls.endpoint, ) return api.get(url)
def get_field_titles(cls, api): """Return the translated titles of the fields.""" url = utils.join_url( REST_API_URL, REST_API_VERSION, 'field_titles', cls.endpoint, ) return api.get(url)
def test_group_field_order(self): """Validate the 'field_order' endpoint.""" resource = join_url('field_order', self.endpoint) response = utils.load_fixture('field_order-property_groups.json') responses.add( responses.GET, utils.get_url(self.API_BASE, resource), body=response, ) result = resources.PropertyGroup.get_field_order(self.api) self.assertEqual(result, json.loads(response))
def test_phase_field_order(self): """Validate the 'field_order' endpoint.""" resource = join_url('field_order', self.endpoint) response = utils.load_fixture('field_order-development_phases.json') responses.add( responses.GET, utils.get_url(self.API_BASE, resource), body=response, ) result = resources.DevelopmentPhase.get_field_order(self.api) self.assertEqual(result, json.loads(response))
def test_get_development(self): """Validate the 'get' endpoint.""" dev_id = 'dev-agency__dev001' resource = join_url(self.endpoint, dev_id) response = utils.load_fixture('development_en.json') responses.add( responses.GET, utils.get_url(self.API_BASE, resource), body=response, ) result = resources.Development.get(self.api, dev_id) self.assertIsInstance(result, resources.Development) response_dict = json.loads(response) self.assertEqual(result._data, response_dict.get('response'))
def test_development_phases(self): """Validate the development phase search for developments.""" data = json.loads(utils.load_fixture('development_en.json')) development = self._callFUT(self.api, data) resource = join_url(self.endpoint, development.get_id(), 'phases') response = utils.load_fixture('phase_list_en.json') responses.add( responses.GET, utils.get_url(self.API_BASE, resource), body=response, ) phases = development.phases() self.assertEqual(len(phases), 2) for phase in phases: self.assertIsInstance(phase, resources.DevelopmentPhase)
def test_property_groups(self): """Validate the property group search for developments.""" data = json.loads(utils.load_fixture('development_en.json')) development = self._callFUT(self.api, data) resource = join_url(self.endpoint, development.get_id(), 'groups') response = utils.load_fixture('group_list_en.json') responses.add( responses.GET, utils.get_url(self.API_BASE, resource), body=response, ) groups = development.groups() self.assertEqual(len(groups), 2) for group in groups: self.assertIsInstance(group, resources.PropertyGroup)
def get_endpoint_url(cls): """Returns the URL to the resource object.""" return utils.join_url(REST_API_URL, REST_API_VERSION, cls.endpoint)
def API_BASE(self): """Return the base API url for the tests.""" return join_url(self.BASE_URL, REST_API_URL, REST_API_VERSION)
def API_BASE(): return utils.join_url(BASE_URL, REST_API_URL, REST_API_VERSION)
def api_base_url(): """Return the API base URL.""" return utils.join_url(BASE_URL, REST_API_URL, REST_API_VERSION)
def api_base_url_listings(): """Return the API base URL for the still used listings API.""" return utils.join_url(BASE_URL, 'api/listings')