Пример #1
0
    def test_db_facade_get_filter(self, init_spaces, get_created_building_ids):
        space_ids = init_spaces
        building_id = get_created_building_ids[0]
        facade_db = FacadeDB()

        # check that database is empty
        result = facade_db.get_all(building_id=building_id)
        assert list(result) == []
        result = facade_db.get_all(space_id=space_ids[0])
        assert list(result) == []

        # create an item
        facade_db.create(
            Facade('Facade #0', [space_ids[0]],
                   SurfaceInfo(32.3, 23, 0.9),
                   building_id,
                   0.323,
                   interior=True))
        facade_db.create(
            Facade('Facade #1',
                   space_ids,
                   SurfaceInfo(32.3, 23, 0.9),
                   building_id,
                   0.323,
                   interior=True))
        result = facade_db.get_all(building_id=building_id)
        assert len(list(result)) == 2

        result = facade_db.get_all(space_id=space_ids[0])
        assert len(list(result)) == 2
        result = facade_db.get_all(space_id=space_ids[1])
        assert len(list(result)) == 1
Пример #2
0
def _create_facades(building_ids, spaces):
    facades_data = [
        {
            'name': 'facade_A',
            'building_id': building_ids[0]
        },
        {
            'name': 'facade_B',
            'building_id': building_ids[0]
        },
        {
            'name': 'facade_C',
            'building_id': building_ids[2]
        },
        {
            'name': 'facade_D',
            'building_id': building_ids[3]
        },
    ]

    nb_spaces = randint(0, len(spaces))
    f_spaces = [str(space_id) for space_id in spaces[:nb_spaces]]

    f_surface_info = SurfaceInfo(area=10)

    return [
        db_accessor.create(
            Facade(spaces=f_spaces,
                   orientation='South_West',
                   windows_wall_ratio=0.3,
                   surface_info=f_surface_info,
                   **data)) for data in facades_data
    ]
Пример #3
0
def init_facades():
    space_ids, floor_ids, building_ids, site_ids = init_spaces()
    facades = [
        Facade('Facade #{}'.format(idx+1), space_ids,
               SurfaceInfo(25, 3.54, 0.012), building_ids[0], 0.23243,
               description='A sample facade', interior=True, id=facade_id)
        for idx, facade_id in enumerate(_get_facade_ids())]
    facade_ids = [FacadeDB().create(facade) for facade in facades]
    return facade_ids, space_ids, floor_ids, building_ids, site_ids
Пример #4
0
    def test_db_wall_create(self, init_spaces, get_created_building_ids):

        space_ids = init_spaces
        building_ids = get_created_building_ids
        facade_db = FacadeDB()

        # check that database is empty
        result = facade_db.get_all()
        assert list(result) == []

        # create an item

        facade = Facade('Facade #0',
                        space_ids[:1],
                        SurfaceInfo(32.3, 23, 0.9),
                        building_ids[1],
                        0.323,
                        orientation='South',
                        interior=True)
        new_facade_id = facade_db.create(facade)
        assert new_facade_id is not None
        assert new_facade_id == facade.id

        # check that database is not empty now
        result = facade_db.get_all()
        facades = list(result)
        assert len(facades) == 1
        assert facades[0].id == facade.id
        assert facades[0].name == facade.name
        assert facades[0].description == facade.description
        assert facades[0].surface_info.area == facade.surface_info.area
        assert facades[0].surface_info.max_height ==\
            facade.surface_info.max_height
        assert facades[0].surface_info.width == facade.surface_info.width
        assert facades[0].windows_wall_ratio == facade.windows_wall_ratio
        assert facades[0].orientation == facade.orientation
        assert facades[0].interior == facade.interior
        assert facades[0].building_id == facade.building_id == building_ids[1]

        # ensure we can access the parent site
        sites = SiteDB().get_all()
        assert facade_db.get_parent(facade.id) in\
            [str(site.id) for site in sites]