def test_property(self): jc = JobConfig() self.assertIs(None, jc.raw_overlay) raw = {} jc.raw_overlay = raw self.assertIs(raw, jc.raw_overlay) raw['jobConfig'] = {'jobName': 'myjob72'} raw['something'] = {'stuff': 3} self.assertIs(raw, jc.raw_overlay) self.assertEqual('myjob72', jc.raw_overlay['jobConfig']['jobName']) gc = {} jc._add_overlays(gc) #type: ignore self.assertTrue('jobConfigOverlays' in gc) jcol = gc['jobConfigOverlays'] self.assertIsInstance(jcol, list) self.assertEqual(1, len(jcol)) jco = jcol[0] self.assertIsInstance(jco, dict) # Copied as-is self.assertEqual(raw, jco)
def test_property(self): jc = JobConfig() self.assertIs(None, jc.raw_overlay) raw = {} jc.raw_overlay = raw self.assertIs(raw, jc.raw_overlay) raw['jobConfig'] = {'jobName': 'myjob72'} raw['something'] = {'stuff': 3} self.assertIs(raw, jc.raw_overlay) self.assertEqual('myjob72', jc.raw_overlay['jobConfig']['jobName']) gc = {} jc._add_overlays(gc) #type: ignore self.assertTrue('jobConfigOverlays' in gc) jcol = gc['jobConfigOverlays'] self.assertIsInstance(jcol, list) self.assertEqual(1, len(jcol)) jco = jcol[0] self.assertIsInstance(jco, dict) # Copied as-is self.assertEqual(raw, jco)
def test_overwrite(self): jc = JobConfig('Overwrite') raw = {} raw['jobConfig'] = {'jobName': 'myjob72', 'jobGroup': 'gg'} raw['deploymentConfig'] = {'fusionScheme': 'dummy', 'other': 'xx'} raw['unknown'] = {'hasdsd': 32532} jc.raw_overlay = raw jc.target_pe_count = 93 self.assertEqual('Overwrite', jc.job_name) self.assertEqual(93, jc.target_pe_count) gc = {} jc._add_overlays(gc) #type: ignore self.assertTrue('jobConfigOverlays' in gc) jcol = gc['jobConfigOverlays'] self.assertIsInstance(jcol, list) self.assertEqual(1, len(jcol)) jco = jcol[0] self.assertIsInstance(jco, dict) self.assertEqual(3, len(jco)) # test unknown value copied as-is self.assertTrue('unknown' in jco) self.assertEqual(jc.raw_overlay['unknown'], jco['unknown']) # test overwrite/merge of job config self.assertTrue('jobConfig' in jco) jjc = jco['jobConfig'] self.assertIsInstance(jjc, dict) self.assertEqual(2, len(jjc)) self.assertEqual('Overwrite', jjc.get('jobName')) self.assertEqual('gg', jjc.get('jobGroup')) # test overwrite/merge of deployment config self.assertTrue('deploymentConfig' in jco) dc = jco['deploymentConfig'] self.assertIsInstance(dc, dict) self.assertEqual(3, len(dc)) self.assertEqual('xx', dc.get('other')) self.assertEqual('manual', dc.get('fusionScheme')) self.assertEqual(93, dc.get('fusionTargetPeCount'))
def test_overwrite(self): jc = JobConfig('Overwrite') raw = {} raw['jobConfig'] = {'jobName': 'myjob72', 'jobGroup': 'gg'} raw['deploymentConfig'] = {'fusionScheme': 'dummy', 'other': 'xx'} raw['unknown'] = {'hasdsd': 32532} jc.raw_overlay = raw jc.target_pe_count = 93 self.assertEqual('Overwrite', jc.job_name) self.assertEqual(93, jc.target_pe_count) gc = {} jc._add_overlays(gc) #type: ignore self.assertTrue('jobConfigOverlays' in gc) jcol = gc['jobConfigOverlays'] self.assertIsInstance(jcol, list) self.assertEqual(1, len(jcol)) jco = jcol[0] self.assertIsInstance(jco, dict) self.assertEqual(3, len(jco)) # test unknown value copied as-is self.assertTrue('unknown' in jco) self.assertEqual(jc.raw_overlay['unknown'], jco['unknown']) # test overwrite/merge of job config self.assertTrue('jobConfig' in jco) jjc = jco['jobConfig'] self.assertIsInstance(jjc, dict) self.assertEqual(2, len(jjc)) self.assertEqual('Overwrite', jjc.get('jobName')) self.assertEqual('gg', jjc.get('jobGroup')) # test overwrite/merge of deployment config self.assertTrue('deploymentConfig' in jco) dc = jco['deploymentConfig'] self.assertIsInstance(dc, dict) self.assertEqual(3, len(dc)) self.assertEqual('xx', dc.get('other')) self.assertEqual('manual', dc.get('fusionScheme')) self.assertEqual(93, dc.get('fusionTargetPeCount'))
def test_merge(self): jc = JobConfig(job_name='Merge') jc.target_pe_count = 7 jc.raw_overlay = {'jobConfig': {'jobGroup': 'mygroup82'}} jc.raw_overlay['deploymentConfig'] = {'threadingModel': 'manual'} jc.raw_overlay['other'] = {'xx': 'yyy'} gc = {} jc._add_overlays(gc) #type: ignore self.assertTrue('jobConfigOverlays' in gc) jcol = gc['jobConfigOverlays'] self.assertIsInstance(jcol, list) self.assertEqual(1, len(jcol)) jco = jcol[0] self.assertIsInstance(jco, dict) self.assertEqual(3, len(jco)) # test unknown value copied as-is self.assertTrue('other' in jco) self.assertEqual(jc.raw_overlay['other'], jco['other']) # test merge of job config self.assertTrue('jobConfig' in jco) jjc = jco['jobConfig'] self.assertIsInstance(jjc, dict) self.assertEqual(2, len(jjc)) self.assertEqual('Merge', jjc.get('jobName')) self.assertEqual('mygroup82', jjc.get('jobGroup')) # test merge of deployment config self.assertTrue('deploymentConfig' in jco) dc = jco['deploymentConfig'] self.assertIsInstance(dc, dict) self.assertEqual(3, len(dc)) self.assertEqual('manual', dc.get('threadingModel')) self.assertEqual('manual', dc.get('fusionScheme')) self.assertEqual(7, dc.get('fusionTargetPeCount'))
def test_merge(self): jc = JobConfig(job_name='Merge') jc.target_pe_count = 7 jc.raw_overlay = {'jobConfig': {'jobGroup':'mygroup82'}} jc.raw_overlay['deploymentConfig'] = {'threadingModel':'manual'} jc.raw_overlay['other'] = {'xx':'yyy'} gc = {} jc._add_overlays(gc) #type: ignore self.assertTrue('jobConfigOverlays' in gc) jcol = gc['jobConfigOverlays'] self.assertIsInstance(jcol, list) self.assertEqual(1, len(jcol)) jco = jcol[0] self.assertIsInstance(jco, dict) self.assertEqual(3, len(jco)) # test unknown value copied as-is self.assertTrue('other' in jco) self.assertEqual(jc.raw_overlay['other'], jco['other']) # test merge of job config self.assertTrue('jobConfig' in jco) jjc = jco['jobConfig'] self.assertIsInstance(jjc, dict) self.assertEqual(2, len(jjc)) self.assertEqual('Merge', jjc.get('jobName')) self.assertEqual('mygroup82', jjc.get('jobGroup')) # test merge of deployment config self.assertTrue('deploymentConfig' in jco) dc = jco['deploymentConfig'] self.assertIsInstance(dc, dict) self.assertEqual(3, len(dc)) self.assertEqual('manual', dc.get('threadingModel')) self.assertEqual('manual', dc.get('fusionScheme')) self.assertEqual(7, dc.get('fusionTargetPeCount'))