コード例 #1
0
ファイル: test_App.py プロジェクト: 12rambau/sepal_ui
    def test_show_tile(self):

        tiles = [sw.Tile(f'id_{i}', f'title_{i}') for i in range(5)]
        drawer_items = [
            sw.DrawerItem(f'title {i}', card=f'id_{i}') for i in range(5)
        ]
        appBar = sw.AppBar()
        footer = sw.Footer()

        title = 'main_title'
        id_ = 'main_id'
        main_tile = sw.Tile(id_, title)
        main_drawer = sw.DrawerItem(title, card=id_)
        tiles.append(main_tile)
        drawer_items.append(main_drawer)

        app = sw.App(tiles, appBar, footer, sw.NavDrawer(drawer_items))
        res = app.show_tile(id_)

        self.assertEqual(res, app)

        for tile in tiles:
            if tile == main_tile:
                self.assertTrue(tile.viz)
            else:
                self.assertFalse(tile.viz)

        for di in drawer_items:
            if di._metadata['card_id'] == id_:
                self.assertTrue(di.input_value)
            else:
                self.assertFalse(di.input_value)
コード例 #2
0
    def test_display_tile(self):

        # build fake tiles
        tiles = []
        for i in range(5):
            title = 'name_{}'.format(i)
            id_ = 'id_{}'.format(i)
            tiles.append(sw.Tile(id_, title))

        # create the real tile
        title = 'toto'
        id_ = 'toto_id'
        real_tile = sw.Tile(id_, title)
        tiles.append(real_tile)

        # create the drawer item and bind it to the tiles
        drawer_item = sw.DrawerItem(title, card=id_).display_tile(tiles)

        # fake the click
        drawer_item._on_click(None, None, None, tiles)

        # check the viz parameter of each tiles
        for tile in tiles:
            if tile.get_title() == title:
                self.assertTrue(tile.viz)
            else:
                self.assertFalse(tile.viz)

        return
コード例 #3
0
ファイル: test_App.py プロジェクト: 12rambau/sepal_ui
    def test_init(self):

        #default init
        app = sw.App()
        self.assertIsInstance(app, sw.App)
        self.assertEqual(len(app.children), 3)
        self.assertIsInstance(app.children[0], v.Overlay)
        self.assertIsInstance(app.children[1], sw.AppBar)
        self.assertIsInstance(app.children[2], v.Content)

        #exhaustive
        navDrawer = sw.NavDrawer(
            [sw.DrawerItem(f'title {i}') for i in range(5)])
        appBar = sw.AppBar()
        tiles = []
        for i in range(5):
            tiles.append(sw.Tile(f'id_{i}', f'title_{i}'))
        footer = sw.Footer()

        app = sw.App(tiles, appBar, footer, navDrawer)
        self.assertIsInstance(app, sw.App)
        self.assertEqual(len(app.children), 5)
        self.assertIsInstance(app.children[0], v.Overlay)
        self.assertIsInstance(app.children[1], sw.AppBar)
        self.assertIsInstance(app.children[2], sw.NavDrawer)
        self.assertIsInstance(app.children[3], v.Content)
        self.assertIsInstance(app.children[4], sw.Footer)

        return
コード例 #4
0
ファイル: test_Tile.py プロジェクト: 12rambau/sepal_ui
    def test_get_id(self):

        id_ = "id"
        tile = sw.Tile(id_, "title", [''])

        self.assertEqual(tile.get_id(), id_)

        return
コード例 #5
0
ファイル: test_Tile.py プロジェクト: 12rambau/sepal_ui
    def test_init(self):

        #default init
        id_ = "id"
        title = "title"
        tile = sw.Tile(id_, title)

        self.assertIsInstance(tile, sw.Tile)
        self.assertEqual(tile.children[0].children[0].children[0], title)
        self.assertEqual(len(tile.children[0].children), 2)

        #exhaustive
        btn = sw.Btn()
        alert = sw.Alert()
        tile = sw.Tile(id_, title, [''], btn, alert)
        self.assertIsInstance(tile, sw.Tile)
        self.assertEqual(len(tile.children[0].children), 4)

        return
コード例 #6
0
ファイル: test_Tile.py プロジェクト: 12rambau/sepal_ui
    def test_hide(self):

        id_ = "id"
        title = "title"
        tile = sw.Tile(id_, title)

        res = tile.hide()

        self.assertEqual(res, tile)
        self.assertFalse(tile.viz)
        self.assertNotIn('d-inline', str(tile.class_).strip())
コード例 #7
0
ファイル: test_Tile.py プロジェクト: 12rambau/sepal_ui
    def test_show(self):

        id_ = "id"
        title = "title"
        tile = sw.Tile(id_, title).hide()

        res = tile.show()

        self.assertEqual(res, tile)
        self.assertTrue(tile.viz)
        self.assertIn('d-inline', str(tile.class_).strip())

        return
コード例 #8
0
ファイル: test_Tile.py プロジェクト: 12rambau/sepal_ui
    def test_set_title(self):

        id_ = "id"
        title = "title"
        input_ = v.Slider()
        tile = sw.Tile(id_, title, [input_])

        title2 = "title2"
        res = tile.set_title(title2)

        self.assertEqual(res, tile)
        self.assertEqual(tile.children[0].children[0].children[0], title2)
        self.assertEqual(tile.children[0].children[1].children[0], input_)

        return
コード例 #9
0
ファイル: test_Tile.py プロジェクト: 12rambau/sepal_ui
    def test_set_content(self):

        id_ = "id"
        title = "title"
        tile = sw.Tile(id_, title, alert=sw.Alert(), btn=sw.Btn())

        input_ = v.Slider()

        res = tile.set_content([input_])

        self.assertEqual(res, tile)
        self.assertEqual(tile.children[0].children[0].children[0], title)
        self.assertEqual(tile.children[0].children[1].children[0], input_)

        return
コード例 #10
0
    def __init__(self, model, aoi_model):

        # gather models
        self.model = model
        self.aoi_model = aoi_model

        # create a result tile
        self.result_tile = sw.Tile('gfc_export_tile', "Results", inputs=[''])

        super().__init__("gfc_export_tile",
                         "Export the data",
                         btn=sw.Btn('Export data'),
                         alert=sw.Alert(),
                         inputs=[sw.Markdown(cm.gfc.txt)])

        # add js behaviour
        self.btn.on_event('click', self._on_click)
コード例 #11
0
ファイル: test_Tile.py プロジェクト: 12rambau/sepal_ui
    def test_toggle_inputs(self):

        inputs = []
        for i in range(5):
            inputs.append(v.Slider())

        input_2_show = v.Slider()
        inputs.append(input_2_show)

        id_ = "id"
        title = "title"
        tile = sw.Tile(id_, title, inputs)

        res = tile.toggle_inputs([input_2_show], inputs)

        self.assertEqual(res, tile)

        for input_ in inputs:
            if input_ == input_2_show:
                self.assertNotIn('d-none', str(input_.class_).strip())
            else:
                self.assertIn('d-none', str(input_.class_).strip())

        return