1   
  2   
  3   
  4   
  5   
  6   
  7   
  8   
  9   
 10   
 11   
 12   
 13   
 14   
 15   
 16   
 17   
 18   
 19   
 20   
 21   
 22   
 23  from unittest import TestCase 
 24   
 25   
 26  from prompt.interpreter import Interpreter 
 27  from lib.errors import RelaxError, RelaxBoolError, RelaxNoneIntError, RelaxNoneStrError, RelaxStrError 
 28  from test_suite.unit_tests.sequence_testing_base import Sequence_base_class 
 29   
 30   
 31  from test_suite.unit_tests._prompt.data_types import DATA_TYPES 
 32   
 33   
 35      """Unit tests for the functions of the 'prompt.sequence' module.""" 
 36   
 50   
 51   
 53          """The pipe_from arg test of the sequence.copy() user function.""" 
 54   
 55           
 56          for data in DATA_TYPES: 
 57               
 58              if data[0] == 'None' or data[0] == 'str': 
 59                  continue 
 60   
 61               
 62              self.assertRaises(RelaxNoneStrError, self.sequence_fns.copy, pipe_from=data[1]) 
  63   
 64   
 66          """The pipe_to arg test of the sequence.copy() user function.""" 
 67   
 68           
 69          for data in DATA_TYPES: 
 70               
 71              if data[0] == 'None' or data[0] == 'str': 
 72                  continue 
 73   
 74               
 75              self.assertRaises(RelaxNoneStrError, self.sequence_fns.copy, pipe_to=data[1]) 
  76   
 77   
 79          """The pipe_from and pipe_to arg test of the sequence.copy() user function.""" 
 80   
 81           
 82          self.assertRaises(RelaxError, self.sequence_fns.copy) 
  83   
 84   
 86          """The proper failure of the sequence.display() user function for the sep argument.""" 
 87   
 88           
 89          for data in DATA_TYPES: 
 90               
 91              if data[0] == 'None' or data[0] == 'str': 
 92                  continue 
 93   
 94               
 95              self.assertRaises(RelaxNoneStrError, self.sequence_fns.display, sep=data[1]) 
  96   
 97   
 99          """The proper failure of the sequence.display() user function for the mol_name_flag argument.""" 
100   
101           
102          for data in DATA_TYPES: 
103               
104              if data[0] == 'bool': 
105                  continue 
106   
107               
108              self.assertRaises(RelaxBoolError, self.sequence_fns.display, mol_name_flag=data[1]) 
 109   
110   
112          """The proper failure of the sequence.display() user function for the res_num_flag argument.""" 
113   
114           
115          for data in DATA_TYPES: 
116               
117              if data[0] == 'bool': 
118                  continue 
119   
120               
121              self.assertRaises(RelaxBoolError, self.sequence_fns.display, res_num_flag=data[1]) 
 122   
123   
125          """The proper failure of the sequence.display() user function for the res_name_flag argument.""" 
126   
127           
128          for data in DATA_TYPES: 
129               
130              if data[0] == 'bool': 
131                  continue 
132   
133               
134              self.assertRaises(RelaxBoolError, self.sequence_fns.display, res_name_flag=data[1]) 
 135   
136   
138          """The proper failure of the sequence.display() user function for the spin_num_flag argument.""" 
139   
140           
141          for data in DATA_TYPES: 
142               
143              if data[0] == 'bool': 
144                  continue 
145   
146               
147              self.assertRaises(RelaxBoolError, self.sequence_fns.display, spin_num_flag=data[1]) 
 148   
149   
151          """The proper failure of the sequence.display() user function for the spin_name_flag argument.""" 
152   
153           
154          for data in DATA_TYPES: 
155               
156              if data[0] == 'bool': 
157                  continue 
158   
159               
160              self.assertRaises(RelaxBoolError, self.sequence_fns.display, spin_name_flag=data[1]) 
 161   
162   
164          """Test the proper failure of the sequence.read() user function for the file argument.""" 
165   
166           
167          for data in DATA_TYPES: 
168               
169              if data[0] == 'str': 
170                  continue 
171   
172               
173              self.assertRaises(RelaxStrError, self.sequence_fns.read, file=data[1]) 
 174   
175   
177          """Test the proper failure of the sequence.read() user function for the dir argument.""" 
178   
179           
180          for data in DATA_TYPES: 
181               
182              if data[0] == 'None' or data[0] == 'str': 
183                  continue 
184   
185               
186              self.assertRaises(RelaxNoneStrError, self.sequence_fns.read, file='a', dir=data[1]) 
 187   
188   
190          """The proper failure of the sequence.read() user function for the mol_name_col argument.""" 
191   
192           
193          for data in DATA_TYPES: 
194               
195              if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 
196                  continue 
197   
198               
199              self.assertRaises(RelaxNoneIntError, self.sequence_fns.read, file='a', mol_name_col=data[1]) 
 200   
201   
203          """The proper failure of the sequence.read() user function for the res_num_col argument.""" 
204   
205           
206          for data in DATA_TYPES: 
207               
208              if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 
209                  continue 
210   
211               
212              self.assertRaises(RelaxNoneIntError, self.sequence_fns.read, file='a', res_num_col=data[1]) 
 213   
214   
216          """The proper failure of the sequence.read() user function for the res_name_col argument.""" 
217   
218           
219          for data in DATA_TYPES: 
220               
221              if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 
222                  continue 
223   
224               
225              self.assertRaises(RelaxNoneIntError, self.sequence_fns.read, file='a', res_name_col=data[1]) 
 226   
227   
229          """The proper failure of the sequence.read() user function for the spin_num_col argument.""" 
230   
231           
232          for data in DATA_TYPES: 
233               
234              if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 
235                  continue 
236   
237               
238              self.assertRaises(RelaxNoneIntError, self.sequence_fns.read, file='a', spin_num_col=data[1]) 
 239   
240   
242          """The proper failure of the sequence.read() user function for the spin_name_col argument.""" 
243   
244           
245          for data in DATA_TYPES: 
246               
247              if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 
248                  continue 
249   
250               
251              self.assertRaises(RelaxNoneIntError, self.sequence_fns.read, file='a', spin_name_col=data[1]) 
 252   
253   
255          """The proper failure of the sequence.read() user function for the sep argument.""" 
256   
257           
258          for data in DATA_TYPES: 
259               
260              if data[0] == 'None' or data[0] == 'str': 
261                  continue 
262   
263               
264              self.assertRaises(RelaxNoneStrError, self.sequence_fns.read, file='a', sep=data[1]) 
 265   
266   
268          """Test the proper failure of the sequence.write() user function for the file argument.""" 
269   
270           
271          for data in DATA_TYPES: 
272               
273              if data[0] == 'str': 
274                  continue 
275   
276               
277              self.assertRaises(RelaxStrError, self.sequence_fns.write, file=data[1]) 
 278   
279   
281          """Test the proper failure of the sequence.write() user function for the dir argument.""" 
282   
283           
284          for data in DATA_TYPES: 
285               
286              if data[0] == 'None' or data[0] == 'str': 
287                  continue 
288   
289               
290              self.assertRaises(RelaxNoneStrError, self.sequence_fns.write, file='a', dir=data[1]) 
 291   
292   
294          """The proper failure of the sequence.write() user function for the mol_name_flag argument.""" 
295   
296           
297          for data in DATA_TYPES: 
298               
299              if data[0] == 'bool': 
300                  continue 
301   
302               
303              self.assertRaises(RelaxBoolError, self.sequence_fns.write, file='a', mol_name_flag=data[1]) 
 304   
305   
307          """The proper failure of the sequence.write() user function for the res_num_flag argument.""" 
308   
309           
310          for data in DATA_TYPES: 
311               
312              if data[0] == 'bool': 
313                  continue 
314   
315               
316              self.assertRaises(RelaxBoolError, self.sequence_fns.write, file='a', res_num_flag=data[1]) 
 317   
318   
320          """The proper failure of the sequence.write() user function for the res_name_flag argument.""" 
321   
322           
323          for data in DATA_TYPES: 
324               
325              if data[0] == 'bool': 
326                  continue 
327   
328               
329              self.assertRaises(RelaxBoolError, self.sequence_fns.write, file='a', res_name_flag=data[1]) 
 330   
331   
333          """The proper failure of the sequence.write() user function for the spin_num_flag argument.""" 
334   
335           
336          for data in DATA_TYPES: 
337               
338              if data[0] == 'bool': 
339                  continue 
340   
341               
342              self.assertRaises(RelaxBoolError, self.sequence_fns.write, file='a', spin_num_flag=data[1]) 
 343   
344   
346          """The proper failure of the sequence.write() user function for the spin_name_flag argument.""" 
347   
348           
349          for data in DATA_TYPES: 
350               
351              if data[0] == 'bool': 
352                  continue 
353   
354               
355              self.assertRaises(RelaxBoolError, self.sequence_fns.write, file='a', spin_name_flag=data[1]) 
 356   
357   
359          """The proper failure of the sequence.write() user function for the sep argument.""" 
360   
361           
362          for data in DATA_TYPES: 
363               
364              if data[0] == 'None' or data[0] == 'str': 
365                  continue 
366   
367               
368              self.assertRaises(RelaxNoneStrError, self.sequence_fns.write, file='a', sep=data[1]) 
 369   
370   
372          """The force arg test of the sequence.write() user function.""" 
373   
374           
375          for data in DATA_TYPES: 
376               
377              if data[0] == 'bool': 
378                  continue 
379   
380               
381              self.assertRaises(RelaxBoolError, self.sequence_fns.write, file='a', force=data[1]) 
  382