Exemplo n.º 1
0
    def test_spec_validation(self):

        # pylint: disable=E1101
        with pytest.raises(ValueError):
            mod.SpecProcessor('3', 'bad spec')
        with pytest.raises(ValueError):
            mod.SpecProcessor('3', 'bad spec')
Exemplo n.º 2
0
    def test_negative_check(self):
        # check simplest spec
        self.spec_processor = mod.SpecProcessor(['3'], 'rec_incl_spec')
        self.assertFalse(self.spec_processor.has_negatives)

        # check more complex spec
        sp2 = mod.SpecProcessor(['3:5', '0', '18:', ':'], 'rec_incl_spec')
        self.assertFalse(sp2.has_negatives)

        # check negative spec
        sp2 = mod.SpecProcessor(['3:5'], 'rec_incl_spec')
        sp3 = mod.SpecProcessor(['-1'], 'rec_incl_spec')
        self.assertTrue(sp3.has_negatives)
Exemplo n.º 3
0
    def test_adjust_one_spec(self):

        self.sp = mod.SpecProcessor(['5'], 'rec_inc_spec')
        self.sp.spec_adjuster(loc_max=80)
        self.assertEqual(self.sp.adj_spec, self.sp.orig_spec)
        self.sp.spec_adjuster()
        self.assertEqual(self.sp.adj_spec, self.sp.orig_spec)

        self.sp = mod.SpecProcessor(['5:15'], 'rec_inc_spec')
        self.sp.spec_adjuster(loc_max=80)
        self.assertEqual(self.sp.adj_spec, self.sp.orig_spec)

        self.sp = mod.SpecProcessor(['5:9', '10:'], 'rec_inc_spec')
        self.sp.spec_adjuster(loc_max=80)
        self.assertEqual(self.sp.adj_spec, self.sp.orig_spec)

        self.sp = mod.SpecProcessor([':'], 'rec_inc_spec')
        self.sp.spec_adjuster(loc_max=80)
        self.assertEqual(self.sp.adj_spec, self.sp.orig_spec)

        self.sp = mod.SpecProcessor(['-1'], 'rec_inc_spec')
        self.sp.spec_adjuster(loc_max=80)
        self.assertEqual(self.sp.adj_spec, ['80'])

        self.sp = mod.SpecProcessor(['-20:-10'], 'rec_inc_spec')
        self.sp.spec_adjuster(loc_max=80)
        self.assertEqual(self.sp.adj_spec, ['61:71'])

        self.sp = mod.SpecProcessor(['-100:'], 'rec_inc_spec')
        self.sp.spec_adjuster(loc_max=1234567890)
        self.assertEqual(self.sp.adj_spec, ['1234567791:'])
Exemplo n.º 4
0
    def simple_runner(self, spec, loc):
        """ Creates the Spec Processor object with default settings for the
            specification and record length.
        """
        spec_name = 'foo'
        loc_max = 4  # max length - based on 0 offset

        self.sp = mod.SpecProcessor(spec, spec_name)
        self.sp.spec_adjuster(loc_max)
        return self.sp.spec_evaluator(loc)
Exemplo n.º 5
0
 def test_spec_validator(self):
     sp5 = mod.SpecProcessor(['3:5'], 'rec_incl_spec')
     self.assertTrue(sp5._spec_validator(['3']))
     self.assertTrue(sp5._spec_validator(['3:8']))
     self.assertTrue(sp5._spec_validator([':']))
     self.assertTrue(sp5._spec_validator(['3:5', '7', '10:', ':', ':19']))
     self.assertRaises(ValueError, sp5._spec_validator, [''])
     self.assertRaises(ValueError, sp5._spec_validator, 'a')
     self.assertRaises(ValueError, sp5._spec_validator, ['a'])
     self.assertRaises(ValueError, sp5._spec_validator, ['-'])
     self.assertRaises(ValueError, sp5._spec_validator, [''])
     self.assertRaises(ValueError, sp5._spec_validator, ['5:1'])
     self.assertRaises(ValueError, sp5._spec_validator, ['1:10:20'])
Exemplo n.º 6
0
 def test_spec_validator(self):
     sp5 = mod.SpecProcessor(['3:5'], 'rec_incl_spec')
     assert sp5._spec_validator(['3'])
     assert sp5._spec_validator(['3:8'])
     assert sp5._spec_validator([':'])
     assert sp5._spec_validator(['3:5', '7', '10:', ':', ':19'])
     # pylint: disable=E1101
     with pytest.raises(ValueError):
         sp5._spec_validator([''])
     with pytest.raises(ValueError):
         sp5._spec_validator('a')
     with pytest.raises(ValueError):
         sp5._spec_validator(['a'])
     with pytest.raises(ValueError):
         sp5._spec_validator(['-'])
     with pytest.raises(ValueError):
         sp5._spec_validator([''])
     with pytest.raises(ValueError):
         sp5._spec_validator(['5:1'])
     with pytest.raises(ValueError):
         sp5._spec_validator(['1:10:20'])
Exemplo n.º 7
0
 def test_spec_evaluator(self):
     sp4 = mod.SpecProcessor(['3:5'], 'rec_incl_spec')
Exemplo n.º 8
0
 def simple_setup(self, spec, spec_name, loc_max):
     self.sp = mod.SpecProcessor(spec, spec_name)
     self.sp.spec_adjuster(loc_max)
Exemplo n.º 9
0
 def setUp(self):
     self.sp = mod.SpecProcessor([':'], 'foo')
Exemplo n.º 10
0
 def setUp(self):
     self.sp = mod.SpecProcessor(['3'], 'rec_inc_spec')
Exemplo n.º 11
0
 def setup_method(self, method):
     self.sp = mod.SpecProcessor(['3'], 'rec_inc_spec')
Exemplo n.º 12
0
 def setup_method(self, method):
     self.sp = mod.SpecProcessor([':'], 'foo')