Exemplo n.º 1
0
    def test_get_items_development(self):
        """Validate the 'search' endpoint to get all developments and get the
        list of developments from the result.
        """
        data_single = json.loads(utils.load_fixture('development_en.json'))
        development = self._callFUT(self.api, data_single)
        items = development.get_items()
        self.assertEqual(len(items), 0)

        data_list = json.loads(utils.load_fixture('development_list_1.json'))
        development = self._callFUT(self.api, data_list)
        items = development.get_items()
        self.assertEqual(len(items), 1)
        for item in items:
            self.assertIsInstance(item, resources.Development)
            self.assertEqual(item._data, data_single.get('response'))
Exemplo n.º 2
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)
Exemplo n.º 3
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)
Exemplo n.º 4
0
 def test_listings_url(self):
     """Validate the deprecated listing search for developments."""
     data = json.loads(utils.load_fixture('development_en.json'))
     development = self._callFUT(self.api, data)
     self.assertEqual(
         development.listings_url,
         'https://demomls.com/api/listings/search?lang=en'
         '&apikey=YOUR_API_KEY&development_listings=dev-agency__dev001',
     )
Exemplo n.º 5
0
 def test_pictures(self):
     """Validate the pictures for developments."""
     data = json.loads(utils.load_fixture('development_en.json'))
     development = self._callFUT(self.api, data)
     images = development.pictures()
     self.assertIsInstance(images, list)
     self.assertEqual(len(images), 2)
     for image in images:
         self.assertIsInstance(image, resources.Image)
Exemplo n.º 6
0
 def test_listings_url(self):
     """Validate the deprecated listing search for property groups."""
     data = json.loads(utils.load_fixture('group_list_en.json'))
     group_list = self._callFUT(self.api, data)
     group = group_list.get_items()[0]
     self.assertEqual(
         group.listings_url,
         'https://demomls.com/api/listings/search?property_group_listings'
         '=dev-agency__dev001__classy&apikey=YOUR_API_KEY'
     )
Exemplo n.º 7
0
 def test_listings_url(self):
     """Validate the deprecated listing search for development phases."""
     data = json.loads(utils.load_fixture('phase_list_en.json'))
     phase_list = self._callFUT(self.api, data)
     phase = phase_list.get_items()[0]
     self.assertEqual(
         phase.listings_url,
         'https://demomls.com/api/listings/search?'
         'apikey=YOUR_API_KEY&phase_listings=dev-agency__dev001__phase-1',
     )
Exemplo n.º 8
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))
Exemplo n.º 9
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))
Exemplo n.º 10
0
 def test_get_all(self):
     """Validate the 'search' endpoint to get all property groups."""
     resource = self.endpoint
     response = utils.load_fixture('group_list_en.json')
     responses.add(
         responses.GET,
         utils.get_url(self.API_BASE, resource),
         body=response,
     )
     result = resources.PropertyGroup.search(self.api)
     self.assertIsInstance(result, resources.PropertyGroup)
     response_dict = json.loads(response)
     self.assertEqual(result._data, response_dict.get('response'))
Exemplo n.º 11
0
 def test_view_types(self):
     resource = 'view_types'
     responses.add(
         responses.GET,
         utils.get_url(self.URL, resource),
         body=utils.load_fixture('category_view_types_en.json')
     )
     client = ListingResource(self.BASE_URL)
     category = client.category(resource)
     expected = [
         ('beach_view', 'Beach View'),
     ]
     assert category == expected
Exemplo n.º 12
0
 def test_get_all(self):
     """Validate the 'search' endpoint to get all developments."""
     resource = self.endpoint
     response = utils.load_fixture('development_list_1.json')
     responses.add(
         responses.GET,
         utils.get_url(self.API_BASE, resource),
         body=response,
     )
     result = resources.Development.search(self.api)
     self.assertIsInstance(result, resources.Development)
     response_dict = json.loads(response)
     self.assertEqual(result._data, response_dict.get('response'))
Exemplo n.º 13
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'))
Exemplo n.º 14
0
 def test_listing_types(self):
     resource = 'listing_types'
     responses.add(
         responses.GET,
         utils.get_url(self.URL, resource),
         body=utils.load_fixture('category_listing_types_en.json')
     )
     client = ListingResource(self.BASE_URL)
     category = client.category(resource)
     expected = [
         ('ll', 'Land Listing'),
         ('rl', 'Residential Lease'),
         ('rs', 'Residential Sale'),
     ]
     assert category == expected
Exemplo n.º 15
0
 def test_get_items_groups(self):
     """Validate the 'search' endpoint to get all groups and get the
     list of groups from the result.
     """
     resource = self.endpoint
     response = utils.load_fixture('group_list_en.json')
     responses.add(
         responses.GET,
         utils.get_url(self.API_BASE, resource),
         body=response,
     )
     result = resources.PropertyGroup.search(self.api)
     items = result.get_items()
     self.assertEqual(len(items), 2)
     for item in items:
         self.assertIsInstance(item, resources.PropertyGroup)
         self.assertIn('title', item._data)
         self.assertIn('status', item._data)
         self.assertIn('listings_url', item._data)
Exemplo n.º 16
0
 def test_get_items_phases(self):
     """Validate the 'search' endpoint to get all phases and get the
     list of phases from the result.
     """
     resource = self.endpoint
     response = utils.load_fixture('phase_list_en.json')
     responses.add(
         responses.GET,
         utils.get_url(self.API_BASE, resource),
         body=response,
     )
     result = resources.DevelopmentPhase.search(self.api)
     items = result.get_items()
     self.assertEqual(len(items), 2)
     for item in items:
         self.assertIsInstance(item, resources.DevelopmentPhase)
         self.assertIn('title', item._data)
         self.assertIn('units', item._data)
         self.assertIn('unit_types', item._data)
         self.assertIn('status', item._data)
         self.assertIn('listings_url', item._data)
Exemplo n.º 17
0
 def setUp(self):
     self.api = api.API(self.BASE_URL)
     self.data = json.loads(utils.load_fixture('basic_single.json'))