Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Workshop.activity/tests/mocks.py
diff options
context:
space:
mode:
Diffstat (limited to 'Workshop.activity/tests/mocks.py')
-rw-r--r--Workshop.activity/tests/mocks.py134
1 files changed, 134 insertions, 0 deletions
diff --git a/Workshop.activity/tests/mocks.py b/Workshop.activity/tests/mocks.py
new file mode 100644
index 0000000..d85d8f2
--- /dev/null
+++ b/Workshop.activity/tests/mocks.py
@@ -0,0 +1,134 @@
+import WorkshopModel
+import WorkshopController
+import Workshop
+
+class ViewMock():
+ """
+ Mock for the Workshop View
+
+ This mock contains a call list in which the name of the called function are added in the order they were called
+ """
+ def __init__(self):
+ self.__call_list ={}
+
+#method for handling the call list
+ def get_call_list(self):
+ return self.__call_list
+
+ def clear_call_list(self):
+ self.__call_list = {}
+
+ call_list = property(get_call_list)
+
+#method from the WorkshopView
+ def set_tutorial_list(self,tutorial_list):
+ self.__call_list.append('set_tutorial_list')
+
+ def change_sorting(self,sorting_key):
+ self.__call_list['change_sorting'] = sorting_key
+
+ def refresh_tutorial_info(self):
+ self.__call_list.append('refresh_tutorial_info')
+
+ def toggle_tutorial_publish(self,tutorial,published):
+ self.__call_list.append('toggle_tutorial_publish')
+
+ def display_detail(self,tutorial):
+ self.__call_list['display_detail'] = tutorial
+
+ def display_main_view(self):
+ self.__call_list['display_main_view'] = None
+
+ def display_info_dialog(self,tutorial):
+ self.__call_list['display_info_dialog'] = tutorial
+
+class WorkshopControllerMock(WorkshopController.WorkshopController):
+ def __init__(self):
+ self.__call_list =[]
+
+#method for handling the call list
+ def get_call_list(self):
+ return self.__call_list
+
+ def clear_call_list(self):
+ self.__call_list = []
+
+ call_list = property(get_call_list)
+
+#method from the WorkshopCOntroller
+ def tutorial_query(self,widget,keyword):
+ self.__call_list.append('tutorial_query')
+
+ def sort_selection_changed(self,widget,sort):
+ self.__call_list.append('sort_selection_changed')
+
+ def launch_tutorial_triggered(self,widget,tutorial):
+ self.__call_list.append('launch_tutorial_triggered')
+
+ def show_details(self,widget,tutorial):
+ self.__call_list.append('show_details')
+
+ def back_pressed(self,widget,data):
+ self.__call_list.append('back_pressed')
+
+ def edit_tutorial(self,widget,data):
+ self.__call_list.append('edit_tutorial')
+
+ def rate_tutorial(self,widget,data):
+ self.__call_list.append('rate_tutorial')
+
+ def update_tutorial(self,widget,tutorial):
+ self.__call_list.append('update_tutorial')
+
+ def info_tutorial(self,widget,tutorial):
+ self.__call_list.append('info_tutorial')
+
+ def delete_tutorial(self,widget,tutorial):
+ self.__call_list.append('delete_tutorial')
+
+ def publish_tutorial(self,widget,tutorial):
+ self,__call_list.append('publish_tutorial')
+
+ def unpublish_tutorial(self,widget,tutorial):
+ self,__call_list.append('unpublish_tutorial')
+
+class WorkshopModelMock():
+ def __init__(self):
+ self.__call_list ={}
+
+#method for handling the call list
+ def get_call_list(self):
+ return self.__call_list
+
+ def clear_call_list(self):
+ self.__call_list = {}
+
+ call_list = property(get_call_list)
+
+
+ def query(self,keyword):
+ self.__call_list['tutorial_query'] = keyword
+
+ def launch_tutorial(self,tutorial):
+ self.__call_list['launch_tutorial'] = tutorial
+
+ def rate_tutorial(self,tutorial,rating):
+ self.__call_list['rate_tutorial'] = (tutorial,rating)
+
+ def edit_tutorial(self,tutorial):
+ self.__call_list['edit_tutorial'] = tutorial
+
+ def save_metadata(self,tutorial):
+ self.__call_list['save_metadata'] = tutorial
+
+ def delete_tutorial(self,tutorial):
+ self.__call_list['delete_tutorial'] = tutorial
+
+ def update_tutorial_infos(self,tutorial,new_infos):
+ self.__call_list.append('update_tutorial_infos')
+
+ def publish_tutorial(self,tutorial):
+ self.__call_list['publish_tutorial'] = tutorial
+
+ def unpublish_tutorial(self,tutorial):
+ self.__call_list['unpublish_tutorial'] = tutorial