def test_get_with_unknown_key(self): # config.get() returns `None` if the `key` is not known with patch('openquake.commonlib.config.get_section') as mock: mock.return_value = dict(b=1) self.assertTrue(config.get("arghh", "c") is None) self.assertEqual(1, mock.call_count) self.assertEqual([("arghh",), {}], mock.call_args)
def test_get_with_empty_section_data(self): # config.get() returns `None` if the section data dict is empty with patch('openquake.commonlib.config.get_section') as mock: mock.return_value = dict() self.assertTrue(config.get("whatever", "key") is None) self.assertEqual(1, mock.call_count) self.assertEqual([("whatever",), {}], mock.call_args)
def test_get_with_unknown_key(self): """config.get() returns `None` if the `key` is not known.""" with patch('openquake.engine.config.get_section') as mock: mock.return_value = dict(b=1) self.assertTrue(config.get("arghh", "c") is None) self.assertEqual(1, mock.call_count) self.assertEqual([("arghh", ), {}], mock.call_args)
def test_get_with_empty_section_data(self): # config.get() returns `None` if the section data dict is empty with patch('openquake.engine.config.get_section') as mock: mock.return_value = dict() self.assertTrue(config.get("whatever", "key") is None) self.assertEqual(1, mock.call_count) self.assertEqual([("whatever", ), {}], mock.call_args)
def test_get_with_nonempty_section_data_and_known_key(self): # config.get() correctly returns the configuration datum for known # sections/keys with patch('openquake.commonlib.config.get_section') as mock: mock.return_value = dict(a=11) self.assertEqual(11, config.get("hmmm", "a")) self.assertEqual(1, mock.call_count) self.assertEqual([("hmmm",), {}], mock.call_args)
def test_get_with_nonempty_section_data_and_known_key(self): # config.get() correctly returns the configuration datum for known # sections/keys with patch('openquake.engine.config.get_section') as mock: mock.return_value = dict(a=11) self.assertEqual(11, config.get("hmmm", "a")) self.assertEqual(1, mock.call_count) self.assertEqual([("hmmm", ), {}], mock.call_args)