Skip to content
Snippets Groups Projects
Commit 68023b8e authored by Martin Burchell's avatar Martin Burchell
Browse files

Added exception for when tab does not exist

parent adcec33d
Branches
No related tags found
2 merge requests!23Tabbed view header styling,!19Tab registry
_pool = {}
class MissingTabError(Exception):
pass
def register_tab(name, tab):
global _pool
_pool[name] = tab
......@@ -9,4 +13,14 @@ def register_tab(name, tab):
def get_tab(name):
global _pool
return _pool[name]
try:
return _pool[name]
except KeyError:
raise MissingTabError()
def clear_tabs():
# Currently only used in test code
global _pool
_pool = {}
import pytest
from ..tab_pool import register_tab, get_tab
from ..tab_pool import (
register_tab,
get_tab,
clear_tabs,
MissingTabError,
)
def setup_function(function):
clear_tabs()
class TestTab(object):
......@@ -12,7 +21,11 @@ def tab():
return TestTab()
@pytest.mark.django_db
def test_tab_is_registered(tab):
register_tab('test-tab', tab)
assert get_tab('test-tab') == tab
def test_exception_when_tab_not_registered(tab):
with pytest.raises(MissingTabError):
get_tab('test-tab')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment