def test_dump(self): ''' Test if it replace the entire datastore with a passed data structure ''' with patch.dict(data.__opts__, {'cachedir': '/'}): with patch('salt.utils.files.fopen', mock_open()): self.assertTrue(data.dump('{"eggs": "spam"}'))
def test_dump(self): """ Test if it replace the entire datastore with a passed data structure """ with patch.dict(data.__opts__, {"cachedir": "/"}): with patch("salt.utils.files.fopen", mock_open()): self.assertTrue(data.dump('{"eggs": "spam"}'))
def test_dump_ioerror(self): ''' Test if it replace the entire datastore with a passed data structure ''' with patch.dict(data.__opts__, {'cachedir': '/'}): mock = MagicMock(side_effect=IOError('')) with patch('salt.utils.files.fopen', mock): self.assertFalse(data.dump('{"eggs": "spam"}'))
def test_dump_ioerror(self): """ Test if it replace the entire datastore with a passed data structure """ with patch.dict(data.__opts__, {"cachedir": "/"}): mock = MagicMock(side_effect=IOError("")) with patch("salt.utils.files.fopen", mock): self.assertFalse(data.dump('{"eggs": "spam"}'))
def test_dump(self): ''' Test if it replace the entire datastore with a passed data structure ''' mock = MagicMock(return_value='/') with patch.dict(data.__opts__, {'cachedir': mock}): with patch('salt.utils.fopen', mock_open()): self.assertTrue(data.dump('{"eggs": "spam"}'))
def test_dump_ioerror(self): ''' Test if it replace the entire datastore with a passed data structure ''' mock = MagicMock(return_value='/') with patch.dict(data.__opts__, {'cachedir': mock}): mock = MagicMock(side_effect=IOError('')) with patch('salt.utils.fopen', mock): self.assertFalse(data.dump('{"eggs": "spam"}'))
def test_dump_isinstance(self): ''' Test if it replace the entire datastore with a passed data structure ''' with patch('ast.literal_eval', MagicMock(return_value='')): self.assertFalse(data.dump('salt'))
def test_dump_isinstance(self): ''' Test if it replace the entire datastore with a passed data structure ''' self.assertFalse(data.dump('salt'))
def test_dump_isinstance(self): """ Test if it replace the entire datastore with a passed data structure """ with patch("ast.literal_eval", MagicMock(return_value="")): self.assertFalse(data.dump("salt"))