Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions rainfall/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,11 @@ def generate_eno_files(data_dir_path, site_id):
cover_alt_text='no alt text given' if release.artwork else None,
description=release.description)

eno_path = os.path.join(release_path(data_dir_path, release), 'release.eno')
f = io.BytesIO(release_eno.encode('utf-8'))
object_storage.put_object(eno_path, f, 'text/plain')
path = release_path(data_dir_path, release)
os.makedirs(path, exist_ok=True)
eno_path = os.path.join(path, 'release.eno')
with open(eno_path, 'w', encoding='utf-8') as f:
f.write(release_eno)


def cleanup_site(data_dir_path, preview_dir_path, site_id):
Expand Down
22 changes: 19 additions & 3 deletions rainfall/site_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
from rainfall.db import db
from rainfall.models import File, User
from rainfall.site import (build_dir, cache_dir, catalog_dir, delete_file,
generate_site, get_zip_file, public_dir,
release_path, rename_release_dir, rename_site_dir,
secure_filename, site_exists, site_path)
generate_eno_files, generate_site, get_zip_file,
public_dir, release_path, rename_release_dir,
rename_site_dir, secure_filename, site_exists,
site_path)


@pytest.fixture
Expand Down Expand Up @@ -261,3 +262,18 @@ def test_rename_site_dir_new_exists(self, app, releases_user):

with pytest.raises(FileExistsError):
rename_site_dir(app.config['DATA_DIR'], site, old_name)

def test_generate_eno_files(self, app, releases_user):
with app.app_context():
db.session.add(releases_user)
site = releases_user.sites[0]

generate_eno_files(app.config['DATA_DIR'], str(site.id))

# Empty release, no eno file.
assert not os.path.exists(
f'{app.config["DATA_DIR"]}/06543f11-12b6-71ea-8000-e026c63c22e2/Cool Site 1/Site 0 Release 1/release.eno'
)
assert os.path.exists(
f'{app.config["DATA_DIR"]}/06543f11-12b6-71ea-8000-e026c63c22e2/Cool Site 1/Site 0 Release 2/release.eno'
)
Loading