示例#1
0
 def test_i_pattern(self):
     self.tempdir = tempfile.mkdtemp()
     testargs = 'foo.py -i *.mrc -o @.mrc'
     with patch('sys.argv', testargs.split()):
         a = m.imageConverter()
         self.assertEqual(a.i, '*.mrc')
         self.assertEqual(self.files, a.files)
示例#2
0
 def test_process_given_with_A(self):
     testargs = 'foo.py --lowpass 40A'
     with patch('sys.argv', testargs.split()):
         a = m.imageConverter()
         i = 1/40
         exp = '--process filter.lowpass.gauss:cutoff_freq={}'.format(i)
         self.assertAlmostEqual(a.lowpass, exp, 7, 0.001)
示例#3
0
 def test_ncpus_too_many(self):
     testargs = 'foo.py --n_cpus 200000000'
     with patch('sys.argv', testargs.split()):
         with self.assertRaises(SystemExit):
             m.imageConverter()   
示例#4
0
 def test_ncpus_given_and_ok(self):
     testargs = 'foo.py --n_cpus 4'
     with patch('sys.argv', testargs.split()):
         a = m.imageConverter()
         self.assertEqual(a.n_cpus, 4)   
示例#5
0
 def test_ncpus_default(self):
     testargs = 'foo.py'
     cpus = multiprocessing.cpu_count() -1
     with patch('sys.argv', testargs.split()):
         a = m.imageConverter()
         self.assertEqual(a.n_cpus, cpus)   
示例#6
0
 def test_scale_given(self):
     testargs = 'foo.py --scale 4'
     with patch('sys.argv', testargs.split()):
         a = m.imageConverter()
         self.assertEqual(a.scale, '--meanshrink 4')
示例#7
0
 def test_scale_default(self):
     with patch('sys.argv', ['foo.py']):
         a = m.imageConverter()
     self.assertEqual(a.scale, '')
示例#8
0
 def test_process_given_malformed(self):
     testargs = 'foo.py --lowpass forty'
     with patch('sys.argv', testargs.split()):
         with self.assertRaises(SystemExit):
             m.imageConverter()
示例#9
0
 def test_process_default(self):
     with patch('sys.argv', ['foo.py']):
         a = m.imageConverter()
     self.assertEqual(a.lowpass, '')
示例#10
0
 def test_o_given_nonexisting_no_force(self):
     testargs = 'foo.py -o /nonexisting/path'
     with patch('sys.argv', testargs.split()):
         with patch('os.makedirs'):
             with self.assertRaises(SystemExit):
                 m.imageConverter() 
示例#11
0
 def test_o_exists_and_no_force(self):
     testargs = 'foo.py -i {0} -o @_hig -f'.format(self.tempdir)
     with patch('sys.argv', testargs.split()):
         with patch ('os.makedirs') as mock:
             m.imageConverter()
             self.assertTrue(mock.called)
示例#12
0
 def test_o_given_and_same_as_i(self):
     testargs = 'foo.py -i {0} -o {0} -'.format(self.files[0])
     with patch('sys.argv', testargs.split()):
         with self.assertRaises(SystemExit):
             m.imageConverter()
示例#13
0
 def test_o_pattern(self):
     testargs = 'foo.py -i {} -o @.mrc'.format(self.files[0])
     with patch('sys.argv', testargs.split()):
         a = m.imageConverter()
     exp = os.path.join('@.mrc')
     self.assertEqual(exp, a.o)
示例#14
0
 def test_o_single_file(self):
     testargs = 'foo.py -i {} -o testout.mrc'.format(self.files[0])
     with patch('sys.argv', testargs.split()):
         a = m.imageConverter()
     exp = os.path.join(self.tempdir, 'testout.mrc')
     self.assertEqual(exp, a.o)
示例#15
0
 def test_i_single_file(self):
     testargs = 'foo.py -i {} -o @.mrc'.format(self.files[0])
     with patch('sys.argv', testargs):
         print(sys.argv)
         a = m.imageConverter()
     self.assertEqual(self.files[0], a.i)