Example #1
0
    def test_view_window_refresh(self):
        data = [{"key": "value"}]

        config = parse()

        controller = Controller(config)
        view_manager = controller._view
        keymapper = view_manager._keymapper.json_browser
        json_browser = JSONBrowser(view_manager, keymapper, data)

        # expand the first line
        content = json_browser.render((18, 3)).content()
        texts_before_refresh = [[t[2] for t in row] for row in content]

        # refresh view window
        new_data = {"key": "value"}
        json_browser.set_top_node(new_data)
        content = json_browser.render((18, 3)).content()
        texts_after_refresh = [[t[2] for t in row] for row in content]

        # verify
        self.assertTrue(texts_before_refresh != texts_after_refresh)
        texts_before_refresh_expected = [
            [B("[                 ")],
            [B("   "), B("{\xe2\x80\xa6}            ")],
            [B("]                 ")],
        ]
        self.assertEqual(texts_before_refresh_expected, texts_before_refresh)
        texts_after_refresh_expected = [
            [B("{                 ")],
            [B("   "), B("key"), B(": "),
             B("value     ")],
            [B("}                 ")],
        ]
        self.assertEqual(texts_after_refresh_expected, texts_after_refresh)
Example #2
0
 def test_parse_keymap_only(self):
     keymap_only_config = here / "configs" / "keymap_only.yml"
     configuration = parse(keymap_only_config)
     self.assertEqual("emacs", configuration.view.keymap.mode)
     self.assertIsNotNone(configuration.view.keymap.mapping)
     self.assertEqual("basic", configuration.view.appearance.theme)
     self.assertIsNotNone(configuration.view.appearance.color_scheme)
Example #3
0
    def test_query_on_esc(self):
        """
        test query window submit query to controller
        """
        config = parse()

        controller = Controller(config)
        controller.query = MagicMock()
        controller.complete = MagicMock(return_value=None)

        view_manager = controller._view
        keymapper = view_manager._keymapper.query_bar
        query_window = QueryBar(view_manager, controller, keymapper)
        query_window.setup()

        # act
        for char in ".test":
            query_window.keypress((18,), char)
        query_window.keypress((18,), 'esc')

        # verify
        self.assertEqual(5, controller.complete.call_count)
        controller.query.assert_called_once_with("$.test")
Example #4
0
 def setUp(self):
     self.config = parse(FIXTURES_DIR / self.config_file).view
     self.keymap = self.config.keymap.mapping
Example #5
0
def parse(*args, **kwargs):
    return config.parse(*args, **kwargs)