def populate(session):
- ruben = User("rubenwardy")
- ruben.active = True
- ruben.password = make_flask_user_password("tuckfrump")
- ruben.github_username = "rubenwardy"
- ruben.forums_username = "rubenwardy"
- ruben.rank = UserRank.ADMIN
- session.add(ruben)
+ admin_user = User("rubenwardy")
+ admin_user.active = True
+ admin_user.password = make_flask_user_password("tuckfrump")
+ admin_user.github_username = "rubenwardy"
+ admin_user.forums_username = "rubenwardy"
+ admin_user.rank = UserRank.ADMIN
+ session.add(admin_user)
tags = {}
for tag in ["Inventory", "Mapgen", "Building", \
ez.rank = UserRank.EDITOR
session.add(ez)
- not1 = Notification(ruben, ez, "Awards approved", "/packages/rubenwardy/awards/")
+ not1 = Notification(admin_user, ez, "Awards approved", "/packages/rubenwardy/awards/")
session.add(not1)
jeija = User("Jeija")
mod.name = "alpha"
mod.title = "Alpha Test"
mod.license = licenses["MIT"]
+ mod.media_license = licenses["MIT"]
mod.type = PackageType.MOD
- mod.author = ruben
+ mod.author = admin_user
mod.tags.append(tags["mapgen"])
mod.tags.append(tags["environment"])
mod.repo = "https://github.com/ezhh/other_worlds"
mod1.name = "awards"
mod1.title = "Awards"
mod1.license = licenses["LGPLv2.1"]
+ mod1.media_license = licenses["MIT"]
mod1.type = PackageType.MOD
- mod1.author = ruben
+ mod1.author = admin_user
mod1.tags.append(tags["player_effects"])
mod1.repo = "https://github.com/rubenwardy/awards"
mod1.issueTracker = "https://github.com/rubenwardy/awards/issues"
mod2.tags.append(tags["tools"])
mod2.type = PackageType.MOD
mod2.license = licenses["LGPLv3"]
+ mod2.media_license = licenses["MIT"]
mod2.author = jeija
mod2.repo = "https://github.com/minetest-mods/mesecons/"
mod2.issueTracker = "https://github.com/minetest-mods/mesecons/issues"
mod.name = "handholds"
mod.title = "Handholds"
mod.license = licenses["MIT"]
+ mod.media_license = licenses["MIT"]
mod.type = PackageType.MOD
mod.author = ez
mod.tags.append(tags["player_effects"])
mod.name = "other_worlds"
mod.title = "Other Worlds"
mod.license = licenses["MIT"]
+ mod.media_license = licenses["MIT"]
mod.type = PackageType.MOD
mod.author = ez
mod.tags.append(tags["mapgen"])
mod.name = "food"
mod.title = "Food"
mod.license = licenses["LGPLv2.1"]
+ mod.media_license = licenses["MIT"]
mod.type = PackageType.MOD
- mod.author = ruben
+ mod.author = admin_user
mod.tags.append(tags["player_effects"])
mod.repo = "https://github.com/rubenwardy/food/"
mod.issueTracker = "https://github.com/rubenwardy/food/issues/"
mod.forums = 2960
mod.short_desc = "Adds lots of food and an API to manage ingredients"
mod.desc = "This is the long desc"
- food = mod
session.add(mod)
mod = Package()
mod.name = "food_sweet"
mod.title = "Sweet Foods"
mod.license = licenses["CC0"]
+ mod.media_license = licenses["MIT"]
mod.type = PackageType.MOD
- mod.author = ruben
+ mod.author = admin_user
mod.tags.append(tags["player_effects"])
mod.repo = "https://github.com/rubenwardy/food_sweet/"
mod.issueTracker = "https://github.com/rubenwardy/food_sweet/issues/"
game1.title = "Capture The Flag"
game1.type = PackageType.GAME
game1.license = licenses["LGPLv2.1"]
- game1.author = ruben
+ game1.media_license = licenses["MIT"]
+ game1.author = admin_user
game1.tags.append(tags["pvp"])
game1.tags.append(tags["survival"])
game1.tags.append(tags["multiplayer"])
mod.name = "pixelbox"
mod.title = "PixelBOX Reloaded"
mod.license = licenses["CC0"]
+ mod.media_license = licenses["MIT"]
mod.type = PackageType.TXP
- mod.author = ruben
+ mod.author = admin_user
mod.forums = 14132
mod.short_desc = "This is an update of the original PixelBOX texture pack by the brillant artist Gambit"
mod.desc = "This is the long desc"
rel.approved = True
session.add(rel)
+ session.commit()
+
metas = {}
for package in Package.query.filter_by(type=PackageType.MOD).all():
meta = None
import pytest
from app import app
+from app.default_data import populate_test_data
+from app.models import db, License, Tag, User, UserRank
from utils import client, recreate_db
-def test_homepage_ok(client):
+def test_homepage_empty(client):
"""Start with a blank database."""
- assert app.config["TESTING"]
+ rv = client.get("/")
+ assert b"No packages available" in rv.data and b"packagetile" not in rv.data
+
+
+def test_homepage_with_contents(client):
+ """Start with a test database."""
+
+ licenses = { x.name : x for x in License.query.all() }
+ tags = { x.name : x for x in Tag.query.all() }
+ admin_user = User.query.filter_by(rank=UserRank.ADMIN).first()
+
+ populate_test_data(db.session, licenses, tags, admin_user)
+ db.session.commit()
rv = client.get("/")
- assert b"No packages available" in rv.data
+
+ assert b"No packages available" not in rv.data and b"packagetile" in rv.data