コード例 #1
0
ファイル: api.py プロジェクト: propertyshelf/mls.apiclient
 def get(self, action, params=None):
     """Make GET request."""
     return self.request(
         utils.join_url(self.base_url, action),
         'GET',
         params=params or {},
     )
コード例 #2
0
    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))
コード例 #3
0
 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)
コード例 #4
0
 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)
コード例 #5
0
 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))
コード例 #6
0
 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))
コード例 #7
0
 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'))
コード例 #8
0
    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)
コード例 #9
0
    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)
コード例 #10
0
 def get_endpoint_url(cls):
     """Returns the URL to the resource object."""
     return utils.join_url(REST_API_URL, REST_API_VERSION, cls.endpoint)
コード例 #11
0
 def API_BASE(self):
     """Return the base API url for the tests."""
     return join_url(self.BASE_URL, REST_API_URL, REST_API_VERSION)
コード例 #12
0
def API_BASE():
    return utils.join_url(BASE_URL, REST_API_URL, REST_API_VERSION)
コード例 #13
0
def api_base_url():
    """Return the API base URL."""
    return utils.join_url(BASE_URL, REST_API_URL, REST_API_VERSION)
コード例 #14
0
def api_base_url_listings():
    """Return the API base URL for the still used listings API."""
    return utils.join_url(BASE_URL, 'api/listings')