def test_read_state_file_failure(self, mock_yaml, mock_logging): """Ensure read() fails when state file is unreadable.""" # pylint: disable=W0613 with self.assertRaises(IOError): state_file.read(self.cfg) mock_logging.assert_called_once()
def test_read_state_file_failure(self, mockobj): """Ensure read() fails when state file is unreadable.""" # pylint: disable=W0613 cfg = self.prep_temporary_state_file() with self.assertRaises(IOError): state_file.read(cfg) os.unlink(cfg['state'])
def test_read_state_file(self): """Ensure read() reads the state file.""" cfg = self.prep_temporary_state_file() test_yaml = state_file.read(cfg) self.assertDictEqual(test_yaml, {'foo': 'bar'}) os.unlink(cfg['state'])
def test_update_state_file(self): """Ensure update() updates the state file.""" # Write some new state new_state = {'foo2': 'bar2'} state_file.update(self.cfg, new_state) # Read in the state file to verify the new state was written state_data = state_file.read(self.cfg) expected_dict = { 'option': 'value', 'foo2': 'bar2', } self.assertDictEqual(state_data, expected_dict)
def test_update_state_file(self): """Ensure update() updates the state file.""" cfg = self.prep_temporary_state_file() # Write some new state new_state = {'foo2': 'bar2'} state_file.update(cfg, new_state) # Read in the state file to verify the new state was written state_data = state_file.read(cfg) expected_dict = { 'foo': 'bar', 'foo2': 'bar2', } self.assertDictEqual(state_data, expected_dict) os.unlink(cfg['state'])
def test_read_state_file_missing(self): """Ensure read() checks to see if the state file exists..""" os.unlink(self.tempstate) test_yaml = state_file.read(self.cfg) self.assertDictEqual(test_yaml, {})
def test_read_state_file(self): """Ensure read() reads the state file.""" test_yaml = state_file.read(self.cfg) self.assertDictEqual(test_yaml, {'option': 'value'})