def ensure_filename_reference(self, filename, checksum): logger.debug("Ensuring filename reference %s for file %s" % \ (checksum, filename)) reference_path = self._reference_path_from_filename(filename) ensure_directory(os.path.dirname(reference_path)) with open(reference_path, 'w') as f: f.write(checksum)
def test_ensure_directory_uses_conn_if_provided(self): conn = Mock() conn.modules.os.path.exists.return_value = False ensure_directory('dir', conn) conn.modules.os.path.exists.assert_called_once_with('dir') conn.modules.os.makedirs.assert_called_once_with('dir')
def ensure_directory(self, path): ensure_directory(path, self.rpyc_conn)
def create_host_buffer(host): logger.debug("Creating host buffer for host %s" % host) buffer_path = os.path.join(MESSOR_BUFFER, "hosts", host) ensure_directory(buffer_path)
def test_ensure_directory_not_mks_dir_if_exists(self): self.exists.return_value = True ensure_directory('dir') self.assertEqual(0, len(self.makedirs.mock_calls))
def test_ensure_directory_mks_dir_if_not_exists(self): self.exists.return_value = False ensure_directory('dir') self.makedirs.assert_called_once_with('dir')