40
40
class CommonReplies:
41
41
"""Because I don't like typing the same thing too many times."""
42
notFound = 'El facto @%s no existe.'
43
created = 'Facto @%s creado.'
44
edit = 'Facto @%s actualizado.'
42
notFound = 'El facto %s no existe.'
43
created = 'Facto %s creado.'
44
edit = 'Facto %s actualizado.'
45
45
maxlen = 'Me diste un facto de %s carácteres. El máximo es 400.'
46
46
dup = '@%s ya existe. Si desea editarlo utilise @no.'
47
47
locked = '@%s está protegido contra cambios.'
87
89
Fconf.repeatProtection.collision.setValue(False)
89
91
def testFact(self):
90
self.assertResponse('foobar', reply('notFound', 'foobar'))
91
self.assertResponse('foobar es una prueba', reply('created', 'foobar'))
92
self.assertResponse('foobar', reply('notFound', '@foobar'))
93
self.assertResponse('foobar es una prueba', reply('created', '@foobar'))
92
94
self.assertResponse('foobar', 'foobar es una prueba')
93
95
self.assertResponse('foobar: ...', reply('dup', 'foobar'))
94
self.assertResponse('foo: bar', reply('created', 'foo'))
96
self.assertResponse('foo: bar', reply('created', '@foo'))
95
97
self.assertResponse('foo', 'bar')
105
107
#self.assertError(' es test ')
106
108
# add a disabled fact
107
109
self.assertNotError('borrar foo')
108
self.assertResponse('foo es otro foo', reply('created', 'foo'))
110
self.assertResponse('foo es otro foo', reply('created', '@foo'))
109
111
self.assertResponse('foo', 'foo es otro foo')
113
self.assertResponse('la respuesta a todo', reply('notFound', '@la respuesta a todo'))
114
self.assertResponse('la respuesta a todo es algo que no existe',
115
reply('created', '@la respuesta a todo'))
116
self.assertResponse('la respuesta a todo', 'la respuesta a todo es algo que no existe')
117
self.assertResponse('what to do now: the same as yesterday',
118
reply('created', '@what to do now'))
119
self.assertResponse('what to do now', 'the same as yesterday')
111
121
def testFactSpecialTests(self):
112
122
self.assertNotError('foo es bar')
119
129
self.prefix = 'test!user@factos.net'
120
130
# add a fact with quotes
121
131
#conf.supybot.commands.quotes.set('')
122
self.assertResponse('comillas es "dobles" y \'simples\'', reply('created', 'comillas'))
132
self.assertResponse('comillas es "dobles" y \'simples\'', reply('created', '@comillas'))
123
133
self.assertResponse('comillas', 'comillas es "dobles" y \'simples\'')
124
134
# channels that end with 'es'
125
135
self.assertNotError('bar#test-es es un facto.')
128
138
def testFactChannelPrefix(self):
129
139
# test facts with '#' on their names
130
self.assertResponse('#kubuntu-es es un canal de soporte', reply('created', '#kubuntu-es'))
140
self.assertResponse('#kubuntu-es es un canal de soporte', reply('created', '@#kubuntu-es'))
131
141
self.assertResponse('#kubuntu-es', '#kubuntu-es es un canal de soporte')
132
self.assertResponse('#kubuntu-es#test es un facto', reply('created', '#kubuntu-es#test'))
142
self.assertResponse('#kubuntu-es#test es un facto', reply('created', '@#kubuntu-es#test'))
133
143
self.assertResponse('#kubuntu-es', '#kubuntu-es es un facto')
134
144
self.assertResponse('#kubuntu-es#', '#kubuntu-es es un canal de soporte')
136
def testFactHighlight(self):
146
def _testFactHighlight(self):
137
147
self.assertNotError('foo : bar')
138
148
self.assertResponse('foo', 'bar')
139
149
m = self.getMsg('foo>user')
169
179
self.assertEqual(m.args[1], 'user: por favor mira mi mensaje privado.')
170
180
# if there was an error the 'see my private msg' shouldn't be send
171
181
self.assertResponse('dile a nouser sobre foo', reply('nouser', 'nouser'))
172
self.assertResponse('dile a user sobre moo', reply('notFound', 'moo'))
182
self.assertResponse('dile a user sobre moo', reply('notFound', '@moo'))
173
183
self.assertResponse('foo', 'bar')
175
185
def testEditFact(self):
176
self.assertResponse('no, foo es bar', reply('notFound', 'foo'))
186
self.assertResponse('no, foo es bar', reply('notFound', '@foo'))
177
187
self.assertNotError('foo:bar')
178
188
self.assertResponse('foo', 'bar')
179
self.assertResponse('no, foo es bar', reply('edit', 'foo'))
189
self.assertResponse('no, foo es bar', reply('edit', '@foo'))
180
190
self.assertResponse('foo', 'foo es bar')
181
self.assertResponse('no foo : bar', reply('edit', 'foo'))
191
self.assertResponse('no, foo : bar', reply('edit', '@foo'))
182
192
self.assertResponse('foo', 'bar')
183
193
self.assertResponse('no, foo:bar', 'Pero si @foo ya dice eso.')
186
196
self.assertRegexp('no, foo:%s' % s , reply('maxlen', len(s)))
187
self.assertResponse('no,foo:barbar', reply('edit', 'foo'))
197
self.assertResponse('no,foo:barbar', reply('edit', '@foo'))
188
198
# test bugfix: facts that starts with 'no' aren't confused as edit cmd
189
self.assertResponse('normas alias foo', reply('created', 'normas→foo'))
199
self.assertResponse('normas alias foo', reply('created', '@normas→foo'))
191
self.assertError('no asd asd asd')
201
self.assertError('no, asd asd asd')
203
self.assertNotError('servidor ftp es un server de archivos')
204
self.assertResponse('no, servidor ftp: Descargas disponibles en asd asdasd.',
205
reply('edit', '@servidor ftp'))
193
def testSubstitute(self):
207
def _testSubstitute(self):
194
208
self.assertNotError('foo:bar')
195
209
self.assertNotError('s/$/ bar/foo')
196
210
self.assertResponse('foo', 'bar bar')
222
236
self.assertNotError('agrega a alias BBB')
223
237
self.assertResponse('alias', 'bar AAA A BBB')
225
def testSpecialChars(self):
239
def _testSpecialChars(self):
226
240
self.assertNotError('ña_-a.z es válido')
227
241
self.assertResponse('ña_-a.z', 'ña_-a.z es válido')
228
242
self.assertNotError('test: %sasd %')
229
243
self.assertResponse('test', '%sasd %')
231
def testCaseInsensible(self):
245
def _testCaseInsensible(self):
232
246
self.assertNotError('tEsT:testing...')
233
247
self.assertResponse('test', 'testing...')
234
248
self.assertResponse('TEST', 'testing...')
249
263
self.assertNotError('ÑOO es bar')
250
264
self.assertResponse('ñoo', 'ÑOO es bar')
252
def testChannelSpecific(self):
266
def _testChannelSpecific(self):
253
267
self.assertNotError('foo:global')
254
268
self.assertResponse('foo', 'global')
255
269
self.assertResponse('foo#test : local', reply('created', 'foo#test'))
265
279
self.assertNotError('desborrar foo#test')
266
280
self.assertResponse('bar', 'local')
268
def testChannelSpecificEdit(self):
282
def _testChannelSpecificEdit(self):
269
283
self.assertNotError('foo:global')
270
284
self.assertNotError('foo#test:local')
271
285
self.assertNotError('no, foo : local2')
299
313
self.assertResponse('foo', 'bar')
300
314
self.assertResponse('añadir a foo AAA --preview', 'Preview: bar AAA')
302
def testRemoveFact(self):
316
def _testRemoveFact(self):
303
317
self.assertNotError('foo:bar')
304
318
self.assertResponse('foo', 'bar')
305
319
self.assertResponse('borrar foo', reply('deleted', 'foo'))
325
339
self.assertResponse('desborrar foo', reply('forbidden', 'foo'))
326
340
self.assertResponse('foo:bar', reply('forbidden', 'foo'))
342
def _testAlias(self):
329
343
self.assertNotError('foo:bar')
330
344
self.assertResponse('test alias foo', reply('created', 'test→foo'))
331
345
self.assertResponse('test', 'bar')
355
369
self.assertNotError('no, foo es bar')
356
370
self.assertResponse('foobar', 'foo es bar')
358
def testAliasLoops(self):
372
def _testAliasLoops(self):
359
373
self.assertNotError('foo:bar')
360
374
self.assertResponse('test alias foo', reply('created', 'test→foo'))
361
375
self.assertResponse('test', 'bar')
362
376
self.assertError('no, foo alias test') # alias loop
364
def testAliasChannelSpecific(self):
378
def _testAliasChannelSpecific(self):
365
379
self.assertNotError('foo#channel:bar in #channel')
366
380
self.assertResponse('test alias foo#channel', reply('created', 'test→foo#channel'))
367
381
self.assertResponse('test', 'bar in #channel')
457
471
self.assertNotError('foo#test:bar')
458
472
self.assertRegexp('foo --info', r'@foo#test')
460
def testGetFactDisabled(self):
474
def _testGetFactDisabled(self):
461
475
self.assertNotError('foo:bar')
462
476
self.assertResponse('foo', 'bar')
463
477
self.assertNotError('borrar foo')
501
515
self.assertNotError('no, slap:slaps ${1} with a ${2}')
502
516
self.assertResponse('slap | m4v fish', 'slaps m4v with a fish')
504
def testFactSubstitute(self):
518
def _testFactSubstitute(self):
505
519
self.assertNotError('foo:bar')
506
520
self.assertNotError('moo: foo says %foo%')
507
521
self.assertResponse('moo', 'foo says bar')
555
569
m = self.getMsg('foo', frm='user!test@test.com')
556
570
self.assertEqual(m.args[0], 'user')
558
def testFactModeAlert(self):
572
def _testFactModeAlert(self):
559
573
self.assertNotError('foo:bar')
560
574
self.assertNotError('bar#test:bar')
561
575
self.assertNotError('boo alias foo')
762
776
self.assertNotError('rehacer test')
763
777
self.assertResponse('test', 'bar')
765
def testHistRestart(self):
779
def _testHistRestart(self):
766
780
self.assertNotError('foo:bar')
767
781
self.assertNotError('no, foo:bar1')
768
782
self.assertNotError('no, foo:bar2')
783
797
self.assertNotError('deshacer foo')
784
798
self.assertResponse('foo', 'bar')
786
def testHistRecord(self):
800
def _testHistRecord(self):
787
801
self.assertNotError('foo:bar')
788
802
self.assertNotError('no, foo:bar1')
789
803
self.assertNotError('no, foo:bar2')
832
846
self.assertNotError('rehacer foo')
833
847
self.assertResponse('foo', 'bar2')
849
def _testQuery(self):
836
850
self.assertResponse('foo:bar', reply('created', 'foo'), private=True)
837
851
self.assertResponse('foo', 'bar', private=True)
838
852
self.assertResponse('@bar:bar', reply('created', 'bar'), private=True)
839
853
self.assertResponse('@bar', 'bar', private=True)
841
def testNotices(self):
855
def _testNotices(self):
842
856
self.prefix = 'user!user@test.c'
843
857
Fconf.noticeInChannels.set('#notice')