Esempio n. 1
0
    def test_db_slab_get_filter(self, init_floors):
        floor_ids, building_ids, _ = init_floors
        building_id = building_ids[0]
        slab_db = SlabDB()

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

        # create an item
        slab_db.create(
            Slab('Slab #0', [floor_ids[0]],
                 SurfaceInfo(32.3, 23, 0.9),
                 building_id,
                 kind='Roof'))
        slab_db.create(
            Slab('Slab #1',
                 floor_ids,
                 SurfaceInfo(32.3, 23, 0.9),
                 building_id,
                 kind='FloorSlab'))
        result = slab_db.get_all(building_id=building_id)
        assert len(list(result)) == 2

        result = slab_db.get_all(floor_id=floor_ids[0])
        assert len(list(result)) == 2
        result = slab_db.get_all(floor_id=floor_ids[1])
        assert len(list(result)) == 1
Esempio n. 2
0
    def test_db_window_create(self, init_facades):

        facade_ids = init_facades
        window_db = WindowDB()

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

        # create an item

        window = Window('Window #0',
                        facade_ids[0],
                        SurfaceInfo(3.3, 1.3, 0.09),
                        covering='Curtain',
                        glazing='DoubleGlazing',
                        u_value=54.32)
        new_window_id = window_db.create(window)
        assert new_window_id is not None
        assert new_window_id == window.id

        # check that database is not empty now
        result = window_db.get_all()
        windows = list(result)
        assert len(windows) == 1
        assert windows[0].id == window.id
        assert windows[0].name == window.name
        assert windows[0].description == window.description
        assert windows[0].surface_info.area == window.surface_info.area
        assert windows[0].surface_info.max_height ==\
            window.surface_info.max_height
        assert windows[0].surface_info.width == window.surface_info.width
        assert windows[0].covering == window.covering
        assert windows[0].glazing.replace(" ", "") == window.glazing
        assert windows[0].facade_id == window.facade_id == facade_ids[0]
        assert windows[0].u_value == window.u_value

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

        # test with wrong value for covering
        window = Window('Window #0',
                        facade_ids[0],
                        SurfaceInfo(3.3, 1.3, 0.09),
                        covering='Cobain',
                        glazing='DoubleGlazing',
                        u_value=76.32)
        with pytest.raises(ValidationError):
            new_window_id = window_db.create(window)

        # test with wrong value for glazing
        window = Window('Window #0',
                        facade_ids[0],
                        SurfaceInfo(3.3, 1.3, 0.09),
                        covering='Curtain',
                        glazing='GFGRT')
        with pytest.raises(ValidationError):
            new_window_id = window_db.create(window)
Esempio n. 3
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
Esempio n. 4
0
def init_windows():
    facade_ids, space_ids, floor_ids, building_ids, site_ids = init_facades()
    windows = [
        Window('Window #{}'.format(idx+1), facade_ids[1],
               SurfaceInfo(25, 3.54, 0.012), description='A sample window',
               covering='Blind', glazing='SimpleGlazing', u_value=12.34)
        for idx, _ in enumerate(_get_facade_ids())]
    window_ids = [WindowDB().create(window) for window in windows]
    return window_ids, facade_ids, space_ids, floor_ids, building_ids, site_ids
Esempio n. 5
0
def init_slabs():
    floor_ids, building_ids, site_ids = init_floors()
    slabs = [
        Slab('Slab #{}'.format(idx+1), [floor_ids[0], floor_ids[1]],
             SurfaceInfo(25, 3.54, 0.012), building_ids[0],
             description='A sample slab', kind='FloorSlab', id=slab_id)
        for idx, slab_id in enumerate(_get_slab_ids())]
    slab_ids = [SlabDB().create(slab) for slab in slabs]
    return slab_ids, floor_ids, building_ids, site_ids
Esempio n. 6
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
Esempio n. 7
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]
Esempio n. 8
0
    def test_db_slab_create(self, init_floors):

        floor_ids, building_ids, _ = init_floors
        slab_db = SlabDB()

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

        # create an item
        slab = Slab('Slab #0',
                    floor_ids[:1],
                    SurfaceInfo(32.3, 23, 0.9),
                    building_ids[1],
                    kind='Roof')
        new_slab_id = slab_db.create(slab)
        assert new_slab_id is not None
        assert new_slab_id == slab.id

        # check that database is not empty now
        result = slab_db.get_all()
        slabs = list(result)
        assert len(slabs) == 1
        assert slabs[0].id == slab.id
        assert slabs[0].name == slab.name
        assert slabs[0].description == slab.description
        assert slabs[0].surface_info.area == slab.surface_info.area
        assert slabs[0].surface_info.max_height ==\
            slab.surface_info.max_height
        assert set(slabs[0].floors) == set(slab.floors)
        assert slabs[0].kind == slab.kind
        assert slabs[0].building_id == slab.building_id == building_ids[1]

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