Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Workshop.activity/tests/mocks.py
blob: d85d8f208b108f44f5ab1e350658be4539f46f81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
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