def test_views_windows_update(self, init_db_data):
        """Test put api endpoint"""

        # retrieve database informations
        window_id = str(init_db_data['windows'][0])

        window_json = self.get_item_by_id(item_id=window_id)
        assert window_json.status_code == 200
        facade_id = str(window_json.json['facade_id'])
        # get etag value
        etag_value = window_json.headers.get('etag', None)

        # Update...
        w_name_updated = 'New window'
        response = self.put_item(item_id=window_id,
                                 name=w_name_updated,
                                 covering='Shade',
                                 surface_info=get_dictionary_no_none(
                                     window_json.json['surface_info']),
                                 facade_id=facade_id,
                                 u_value=43421.32,
                                 headers={'If-Match': etag_value})
        # ...update done
        assert response.status_code == 200
        assert response.json['name'] == w_name_updated
        assert response.json['covering'] == 'Shade'
        assert (get_dictionary_no_none(
            response.json['surface_info']) == get_dictionary_no_none(
                window_json.json['surface_info']))
        assert response.json['facade_id'] == facade_id
        assert response.json['u_value'] == 43421.32
示例#2
0
    def test_views_spaces_update(self, init_db_data):
        """Test put api endpoint"""

        # retrieve database informations
        space_id = str(init_db_data['spaces'][0])

        space_json = self.get_item_by_id(item_id=space_id)
        assert space_json.status_code == 200
        floor_id = str(space_json.json['floor_id'])
        # get etag value
        etag_value = space_json.headers.get('etag', None)

        # Update...
        s_name_updated = 'Spaces or tabs...'
        response = self.put_item(item_id=space_id,
                                 name=s_name_updated,
                                 floor_id=floor_id,
                                 kind=space_json.json['kind'],
                                 occupancy=get_dictionary_no_none(
                                     space_json.json['occupancy']),
                                 spatial_info=get_dictionary_no_none(
                                     space_json.json['spatial_info']),
                                 description='awful joke',
                                 headers={'If-Match': etag_value})
        # ...update done
        assert response.status_code == 200
        assert response.json['name'] == s_name_updated
        assert response.json['kind'] == space_json.json['kind']
        assert response.json['occupancy'] == space_json.json['occupancy']
        assert response.json['spatial_info'] == space_json.json['spatial_info']
        assert response.json['spatial_info']['area'] > 0
        assert response.json['spatial_info']['max_height'] > 0
        assert response.json['floor_id'] == floor_id
    def test_views_occupants_update(self, init_db_data):
        """Test put api endpoint"""

        # retrieve database informations
        occupant_id = str(init_db_data['occupants'][0])

        occupant_json = self.get_item_by_id(item_id=occupant_id)
        assert occupant_json.status_code == 200
        # get etag value
        etag_value = occupant_json.headers.get('etag', None)

        workspace = get_dictionary_no_none(occupant_json.json['workspace'])

        # Update occupant...
        gender_updated = 'Female'
        response = self.put_item(
            item_id=occupant_id, gender=gender_updated,
            age_category='ac_65',
            workspace=workspace,
            headers={'If-Match': etag_value})
        # ...update done
        assert response.status_code == 200
        assert response.json['gender'] == gender_updated
        assert response.json['age_category'] == 'ac_65'
        assert response.json['workspace']['kind'] == 'office'
        assert response.json['workspace']['desk_location_window'] == 'far'
示例#4
0
    def test_views_slabs_update(self, init_db_data):
        """Test put api endpoint"""

        # retrieve database informations
        slab_id = str(init_db_data['slabs'][0])

        slab_json = self.get_item_by_id(item_id=slab_id)
        building_id = str(slab_json.json['building_id'])
        assert slab_json.status_code == 200

        # get etag value
        etag_value = slab_json.headers.get('etag', None)

        surface_info = get_dictionary_no_none(slab_json.json['surface_info'])

        # Update...
        f_name_updated = 'An updated slab name'
        response = self.put_item(item_id=slab_id,
                                 name=f_name_updated,
                                 floors=slab_json.json['floors'],
                                 surface_info=surface_info,
                                 building_id=building_id,
                                 headers={'If-Match': etag_value})
        # ...update done
        assert response.status_code == 200
        assert response.json['name'] == f_name_updated
        assert set(response.json['floors']) == set(slab_json.json['floors'])
        assert 'description' not in response.json
        assert response.json['surface_info'] == slab_json.json['surface_info']
        assert response.json['building_id'] ==\
            str(slab_json.json['building_id'])
示例#5
0
    def test_views_floors_update(self, init_db_data):
        """Test put api endpoint"""

        # retrieve database informations
        floor_id = str(init_db_data['floors'][0])

        floor_json = self.get_item_by_id(item_id=floor_id)
        building_id = str(floor_json.json['building_id'])
        assert floor_json.status_code == 200
        # get etag value
        etag_value = floor_json.headers.get('etag', None)

        spatial_info = get_dictionary_no_none(floor_json.json['spatial_info'])

        # Update...
        f_name_updated = 'An updated floor name'
        response = self.put_item(item_id=floor_id,
                                 name=f_name_updated,
                                 kind=floor_json.json['kind'],
                                 level=floor_json.json['level'],
                                 building_id=building_id,
                                 spatial_info=spatial_info,
                                 headers={'If-Match': etag_value})
        # ...update done
        assert response.status_code == 200
        assert response.json['name'] == f_name_updated
        assert response.json['kind'] == floor_json.json['kind']
        assert response.json['level'] == floor_json.json['level']
        assert response.json['spatial_info'] == floor_json.json['spatial_info']
        assert 'description' not in response.json
        assert response.json['building_id'] == str(building_id)
示例#6
0
    def test_views_sites_update(self, init_db_data):
        """Test put api endpoint"""

        # retrieve database informations
        site_id = str(init_db_data['sites'][0])
        geo_json = self.get_item_by_id(item_id=site_id).json['geographic_info']
        geo_json_none = get_dictionary_no_none(geo_json)

        # get etag value
        response = self.get_item_by_id(item_id=site_id)
        assert response.status_code == 200
        etag_value = response.headers.get('etag', None)

        # Update item...
        s_name_updated = 'Updated site'
        response = self.put_item(item_id=site_id,
                                 name=s_name_updated,
                                 geographic_info=geo_json_none,
                                 headers={'If-Match': etag_value})
        # ...update done
        assert response.status_code == 200
        assert response.json['name'] == s_name_updated
        assert response.json['geographic_info'] == geo_json
示例#7
0
    def test_views_facades_update(self, init_db_data):
        """Test put api endpoint"""

        # retrieve database informations
        facade_id = str(init_db_data['facades'][0])

        facade_json = self.get_item_by_id(item_id=facade_id)
        building_id = str(facade_json.json['building_id'])
        assert facade_json.status_code == 200

        # get etag value
        etag_value = facade_json.headers.get('etag', None)

        surface_info = get_dictionary_no_none(facade_json.json['surface_info'])

        # Update...
        f_name_updated = 'An updated facade name'
        response = self.put_item(
            item_id=facade_id,
            name=f_name_updated,
            spaces=facade_json.json['spaces'],
            windows_wall_ratio=facade_json.json['windows_wall_ratio'],
            surface_info=surface_info,
            building_id=building_id,
            headers={'If-Match': etag_value})
        # ...update done
        assert response.status_code == 200
        assert response.json['name'] == f_name_updated
        assert set(response.json['spaces']) == set(facade_json.json['spaces'])
        assert (response.json['windows_wall_ratio'] ==
                facade_json.json['windows_wall_ratio'])
        assert 'description' not in response.json
        assert response.json['surface_info'] == (
            facade_json.json['surface_info'])
        assert response.json['building_id'] == str(
            facade_json.json['building_id'])