def test_get_processed_hotkeys(self): hotkeys = get_processed_hotkeys([{'keys': 'f', 'link': '/test/'}]) self.assertEquals(hotkeys, {70: {'link': '/test/'}}) hotkeys = get_processed_hotkeys([{'keys': 'ctrl+f', 'link': '/test/'}]) self.assertEquals(hotkeys, {17: {70: {'link': '/test/'}}}) hotkeys = get_processed_hotkeys([{ 'keys': 'ctrl+alt+f', 'link': '/test/' }]) self.assertEquals(hotkeys, {17: {18: {70: {'link': '/test/'}}}}) hotkeys = get_processed_hotkeys([{ 'keys': 'ctrl+alt+f', 'link': '/test/' }, { 'keys': 'ctrl+alt+d', 'link': '/test2/' }]) self.assertEquals( hotkeys, {17: { 18: { 68: { 'link': '/test2/' }, 70: { 'link': '/test/' } } }}) hotkeys = get_processed_hotkeys([{ 'keys': 'ctrl+alt+shift+f', 'link': '/test/' }]) self.assertEquals(hotkeys, {}) # only three levels for now
def test_get_processed_hotkeys(self): hotkeys = get_processed_hotkeys([{'keys': 'f', 'link': '/test/'}]) self.assertEquals(hotkeys, {70: {'link': '/test/'}}) hotkeys = get_processed_hotkeys([{'keys': 'ctrl+f', 'link': '/test/'}]) self.assertEquals(hotkeys, {17: {70: {'link': '/test/'}}}) hotkeys = get_processed_hotkeys([{'keys': 'ctrl+alt+f', 'link': '/test/'}]) self.assertEquals(hotkeys, {17: {18: {70: {'link': '/test/'}}}}) hotkeys = get_processed_hotkeys([{'keys': 'ctrl+alt+f', 'link': '/test/'}, {'keys': 'ctrl+alt+d', 'link': '/test2/'}]) self.assertEquals(hotkeys, {17: {18: {68: {'link': '/test2/'}, 70: {'link': '/test/'}}}}) hotkeys = get_processed_hotkeys([{'keys': 'ctrl+alt+shift+f', 'link': '/test/'}]) self.assertEquals(hotkeys, {}) # only three levels for now
def setup_hotkeys(): """ DSetup. Ex. {% load hotkeys %} {% setup_hotkeys %} """ return { 'hotkeys': get_processed_hotkeys(), 'special_disabled': ks_settings.SPECIAL_DISABLED, }
def test_get_processed_hotkeys_wrong_hotkeys(self): ks_settings.HOTKEYS = None hotkeys = get_processed_hotkeys([{'keys': 'af', 'link': '/test/'}]) self.assertEquals(hotkeys, dict()) hotkeys = get_processed_hotkeys([{'keys': '(', 'link': '/test/'}]) self.assertEquals(hotkeys, dict())
def test_get_processed_hotkeys_no_hotkeys(self): ks_settings.HOTKEYS = None hotkeys = get_processed_hotkeys() self.assertEquals(hotkeys, dict())
def test_get_processed_hotkeys_from_ks_settings(self): hotkeys = get_processed_hotkeys([{'keys': 'f', 'link': '/test/'}]) hotkeys_from_ks_settings = get_processed_hotkeys() self.assertEquals(hotkeys, hotkeys_from_ks_settings)