Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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()   
Ejemplo n.º 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)   
Ejemplo n.º 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)   
Ejemplo n.º 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')
Ejemplo n.º 7
0
 def test_scale_default(self):
     with patch('sys.argv', ['foo.py']):
         a = m.imageConverter()
     self.assertEqual(a.scale, '')
Ejemplo n.º 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()
Ejemplo n.º 9
0
 def test_process_default(self):
     with patch('sys.argv', ['foo.py']):
         a = m.imageConverter()
     self.assertEqual(a.lowpass, '')
Ejemplo n.º 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() 
Ejemplo n.º 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)
Ejemplo n.º 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()
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)