about summary refs log tree commit diff stats
path: root/tests/test_cmd_account.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_cmd_account.h')
-rw-r--r--tests/test_cmd_account.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/test_cmd_account.h b/tests/test_cmd_account.h
index ccb2a16c..535d3aec 100644
--- a/tests/test_cmd_account.h
+++ b/tests/test_cmd_account.h
@@ -38,3 +38,8 @@ void cmd_account_set_muc_sets_muc(void **state);
 void cmd_account_set_muc_shows_message(void **state);
 void cmd_account_set_nick_sets_nick(void **state);
 void cmd_account_set_nick_shows_message(void **state);
+void cmd_account_set_status_shows_message_when_invalid_status(void **state);
+void cmd_account_set_status_sets_status_when_valid(void **state);
+void cmd_account_set_status_sets_status_when_last(void **state);
+void cmd_account_set_status_shows_message_when_set_valid(void **state);
+void cmd_account_set_status_shows_message_when_set_last(void **state);
com> 2010-04-19 22:43:29 +0200 ranger.api: import common variables' href='/akspecs/ranger/commit/ranger/api/apps.py?h=v1.9.0b1&id=24821ca5cda156c846a2308c564f51743a7f21c8'>24821ca5 ^
d46a05a8 ^
bd0ede8d ^
b828e4ac ^
a4570538 ^
23236d0c ^
cc952d63 ^
d46a05a8 ^
4be8b401 ^
63f22638 ^
0128bee7 ^
4be8b401 ^








4e9450f9 ^

4be8b401 ^
4e9450f9 ^
4be8b401 ^









ea87d005 ^
4be8b401 ^
b828e4ac ^
4be8b401 ^

b828e4ac ^
4be8b401 ^

d46a05a8 ^






710b0bb7 ^



d46a05a8 ^


bd0ede8d ^
d46a05a8 ^








bd0ede8d ^
b102486b ^
d46a05a8 ^



63f22638 ^



cc952d63 ^
728fb838 ^
cc952d63 ^



ea87d005 ^
4f1a6e67 ^





bd0ede8d ^
0546ef7c ^
4f1a6e67 ^
b828e4ac ^



9db1828f ^

b828e4ac ^






cc952d63 ^

728fb838 ^
cc952d63 ^


728fb838 ^
9207e83c ^





cc952d63 ^
a5e1ccdd ^


710b0bb7 ^
a5e1ccdd ^

5914f940 ^
710b0bb7 ^


a5e1ccdd ^
4be8b401 ^
23236d0c ^
4be8b401 ^






d46a05a8 ^

4f1a6e67 ^
d46a05a8 ^


710b0bb7 ^



d46a05a8 ^

a3540c6c ^

b102486b ^


b828e4ac ^
b102486b ^



a3540c6c ^
b102486b ^

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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
                                                                 
 



                                                                      
 






                                                                       
 
                  
                        
                                         
                                                      
                                      
                                               
 
 
                                     
           
                                                                         
                                  








                                                                              

                                                                    
 
                                                                              









                                                                             
 
                                     
                                      

                                      
                                       

           






                                               



                                                                                            


                                                              
                                                        








                                                                                 
                                                            
                                                                         



                                                                         



                                                   
                           
                                                                                       



                                                          
 





                                                             
                                                    
                                                            
                                                  



                                              

                                     






                                                                   

                           
                                                               


                                                  
                                                                   





                                                                                          
 


                                                                       
                                                                    

                                                    
                                                           


                                                                         
 
 
               






                                                                  

                   
 


                                   



                                                

                          

 


                                                                  
                            



                                                               
                                    

                                                           
# Copyright (C) 2009, 2010  Roman Zimbelmann <romanz@lavabit.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import os, sys, re
from ranger.api import *
from ranger.ext.iter_tools import flatten
from ranger.ext.get_executables import get_executables
from ranger.core.runner import Context
from ranger.core.shared import FileManagerAware


class Applications(FileManagerAware):
	"""
	This class contains definitions on how to run programs and should
	be extended in ranger.apps

	The user can decide what program to run, and if he uses eg. 'vim', the
	function app_vim() will be called.  However, usually the user
	simply wants to "start" the file without specific instructions.
	In such a case, app_default() is called, where you should examine
	the context and decide which program to use.

	All app functions have a name starting with app_ and return a string
	containing the whole command or a tuple containing a list of the
	arguments. They are supplied with one argument, which is the
	AppContext instance.

	You should define at least app_default, app_pager and app_editor since
	internal functions depend on those.  Here are sample implementations:

	def app_default(self, context):
		if context.file.media:
			if context.file.video:
				# detach videos from the filemanager
				context.flags += 'd'
			return self.app_mplayer(context)
		else:
			return self.app_editor(context)

	def app_pager(self, context):
		return 'less', context

	def app_editor(self, context):
		return ('vim', context)
	"""

	def _meets_dependencies(self, fnc):
		try:
			deps = fnc.dependencies
		except AttributeError:
			return True

		for dep in deps:
			if dep == 'X':
				if 'DISPLAY' not in os.environ or not os.environ['DISPLAY']:
					return False
				continue
			if hasattr(dep, 'dependencies') \
			and not self._meets_dependencies(dep):
				return False
			if dep not in get_executables():
				return False

		return True

	def either(self, context, *args):
		for app in args:
			try:
				application_handler = getattr(self, 'app_' + app)
			except AttributeError:
				if app in get_executables():
					return _generic_app(app, context)
				continue
			if self._meets_dependencies(application_handler):
				return application_handler(context)

	def app_self(self, context):
		"""Run the file itself"""
		return "./" + context.file.basename

	def get(self, app):
		"""Looks for an application, returns app_default if it doesn't exist"""
		try:
			return getattr(self, 'app_' + app)
		except AttributeError:
			return self.app_default

	def apply(self, app, context):
		if not app:
			app = 'default'
		try:
			handler = getattr(self, 'app_' + app)
		except AttributeError:
			if app in get_executables():
				return [app] + list(context)
			handler = self.app_default
		arguments = handler(context)
		# flatten
		if isinstance(arguments, str):
			return (arguments, )
		if arguments is None:
			return None
		result = []
		for obj in arguments:
			if isinstance(obj, (tuple, list, Context)):
				result.extend(obj)
			else:
				result.append(obj)
		return result

	def has(self, app):
		"""Returns whether an application is defined"""
		return hasattr(self, 'app_' + app)

	def all(self):
		"""Returns a list with all application functions"""
		result = set()
		# go through all the classes in the mro (method resolution order)
		# so subclasses will return the apps of their superclasses.
		for cls in self.__class__.__mro__:
			result |= set(m[4:] for m in cls.__dict__ if m.startswith('app_'))
		return sorted(result)

	@classmethod
	def generic(cls, *args, **keywords):
		flags = 'flags' in keywords and keywords['flags'] or ""
		deps = 'deps' in keywords and keywords['deps'] or ()
		for name in args:
			assert isinstance(name, str)
			if not hasattr(cls, "app_" + name):
				fnc = _generic_wrapper(name, flags=flags)
				fnc = depends_on(*deps)(fnc)
				setattr(cls, "app_" + name, fnc)


def tup(*args):
	"""
	This helper function creates a tuple out of the arguments.

	('a', ) + tuple(some_iterator)
	is equivalent to:
	tup('a', *some_iterator)
	"""
	return args


def depends_on(*args):
	args = tuple(flatten(args))
	def decorator(fnc):
		try:
			fnc.dependencies += args
		except:
			fnc.dependencies  = args
		return fnc
	return decorator


def _generic_app(name, context, flags=''):
	"""Use this function when no other information is given"""
	context.flags += flags
	return name, context


def _generic_wrapper(name, flags=''):
	"""Wraps _generic_app into a method for Applications"""
	assert isinstance(name, str)
	return depends_on(name)(lambda self, context:
			_generic_app(name, context, flags))