~durga/maus/rel709

« back to all changes in this revision

Viewing changes to src/map/MapCppTrackerDigits/test_map_cpp_tracker_digits.py

  • Committer: Durga Rajaram
  • Date: 2013-08-27 04:36:50 UTC
  • mfrom: (659.1.73 rc)
  • Revision ID: durga@fnal.gov-20130827043650-me0hgsbzlzikdoik
Tags: MAUS-v0.7.0
MAUS-v0.7.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
from Configuration import Configuration
26
26
 
27
27
from MapCppTrackerDigits import MapCppTrackerDigits
 
28
import maus_cpp.globals
28
29
 
29
30
# Disable: Too many public methods
30
31
# pylint: disable-msg=R0904
34
35
# pylint: disable-msg=C0202
35
36
 
36
37
class MapCppTrackerDigitsTestCase(unittest.TestCase):
37
 
    """ The MapCppTrackerDigits test.
38
 
    """
 
38
    """ The MapCppTrackerDigits test."""
 
39
 
 
40
    cfg = json.loads(Configuration().getConfigJSON())
 
41
    cfg['reconstruction_geometry_filename'] = 'Stage6.dat'
 
42
 
39
43
    @classmethod
40
44
    def setUpClass(self):
41
45
        """ Class Initializer.
42
 
            The set up is called before each test function
43
 
            is called.
 
46
            The set up is called before each test function is called.
44
47
        """
45
48
        self.mapper = MapCppTrackerDigits()
46
 
        conf = json.loads(Configuration().getConfigJSON())
47
 
        conf["reconstruction_geometry_filename"] = "Stage6.dat"
48
49
        # Test whether the configuration files were loaded correctly at birth
49
 
        success = self.mapper.birth(json.dumps(conf))
 
50
        if maus_cpp.globals.has_instance():
 
51
            maus_cpp.globals.death()
 
52
        success = self.mapper.birth(json.dumps(self.cfg))
50
53
        if not success:
51
54
            raise Exception('InitializeFail', 'Could not start worker')
52
55
 
54
57
        """ Test to make sure death occurs """
55
58
        self.assertTrue(self.mapper.death())
56
59
 
57
 
    def testEmpty(self):
58
 
        """Check can handle empty configuration and empty data"""
59
 
        result = self.mapper.birth("")
60
 
        self.assertFalse(result)
61
 
        result = self.mapper.process("")
62
 
        spill_out = json.loads(result)
63
 
        self.assertTrue('errors' in spill_out)
64
 
        self.assertTrue("bad_json_document" in spill_out['errors'])
65
 
        self.assertFalse("recon_events" in spill_out)
66
 
 
67
 
    def testBadData(self):
68
 
        """Check can handle nonsense json input data"""
69
 
        result = self.mapper.process("blah")
70
 
        spill_out = json.loads(result)
71
 
        self.assertTrue('errors' in spill_out)
72
 
        self.assertTrue("bad_json_document" in spill_out['errors'])
 
60
    # def testBadData(self):
 
61
    #    """Check can handle nonsense json input data"""
 
62
    #    result = self.mapper.process("blah")
 
63
    #    spill_out = json.loads(result)
 
64
    #    self.assertTrue('errors' in spill_out)
 
65
    #    self.assertTrue("bad_json_document" in spill_out['errors'])
73
66
 
74
67
    def testProcess(self):
75
68
        """ Test of the process function """