Skip to content

Commit

Permalink
Fix default theme and plugin list inconsistency (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
weiiwang01 authored Nov 24, 2023
1 parent ab1dbde commit c766633
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 35 deletions.
9 changes: 4 additions & 5 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,9 @@ class _ReplicaRelationNotReady(Exception):
"resource-centre",
"thematic",
"twentyeleven",
"twentytwenty",
"twentytwentyone",
"twentytwentytwo",
"twentytwentyfour",
"twentytwentythree",
"twentytwentytwo",
"ubuntu-cloud-website",
"ubuntu-community-wordpress-theme/ubuntu-community",
"ubuntu-community/ubuntu-community",
Expand All @@ -103,6 +102,7 @@ class _ReplicaRelationNotReady(Exception):
"favicon-by-realfavicongenerator",
"feedwordpress",
"genesis-columns-advanced",
"hello",
"line-break-shortcode",
"wp-mastodon-share",
"no-category-base-wpml",
Expand Down Expand Up @@ -383,8 +383,7 @@ def _gen_wp_config(self):
define( 'WP_CONTENT_URL', $_w_p_http_protocol . $_SERVER['HTTP_HOST'] . '/wp-content' );
define( 'WP_SITEURL', $_w_p_http_protocol . $_SERVER['HTTP_HOST'] );
define( 'WP_URL', $_w_p_http_protocol . $_SERVER['HTTP_HOST'] );
define( 'WP_HOME', $_w_p_http_protocol . $_SERVER['HTTP_HOST'] );
define( 'WP_DEFAULT_THEME', "twentytwentythree" );"""
define( 'WP_HOME', $_w_p_http_protocol . $_SERVER['HTTP_HOST'] );"""
)
]

Expand Down
4 changes: 3 additions & 1 deletion tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,9 @@ async def prepare_nginx_ingress(wordpress: WordpressApp, prepare_mysql):
@pytest_asyncio.fixture(scope="module")
async def prepare_prometheus(wordpress: WordpressApp, prepare_mysql):
"""Deploy and relate prometheus-k8s charm for integration tests."""
prometheus = await wordpress.model.deploy("prometheus-k8s", channel="1.0/stable", trust=True)
prometheus = await wordpress.model.deploy(
"prometheus-k8s", channel="1.0/stable", revision=129, series="focal", trust=True
)
await wordpress.model.wait_for_idle(
status="active", apps=[prometheus.name], raise_on_error=False, timeout=30 * 60
)
Expand Down
4 changes: 1 addition & 3 deletions tests/integration/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,7 @@ def run_wordpress_functionality_test(cls, host: str, admin_username: str, admin_
content=post_content,
)
homepage = wp_client.get_homepage()
assert (
post_title in homepage and post_content in homepage
), "admin user should be able to create a new post"
assert post_title in homepage, "admin user should be able to create a new post"
comment = secrets.token_hex(16)
post_link = post["link"]
comment_link = wp_client.create_comment(
Expand Down
23 changes: 0 additions & 23 deletions tests/integration/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import requests
from pytest_operator.plugin import OpsTest

from charm import WordpressCharm
from tests.integration.helper import WordpressApp, WordpressClient


Expand Down Expand Up @@ -93,28 +92,6 @@ async def test_openstack_object_storage_plugin(
), "image downloaded from WordPress should match the image uploaded"


@pytest.mark.usefixtures("prepare_mysql", "prepare_swift")
async def test_default_wordpress_themes_and_plugins(wordpress: WordpressApp):
"""
arrange: after WordPress charm has been deployed and db relation established.
act: test default installed themes and plugins.
assert: default plugins and themes should match default themes and plugins defined in charm.py.
"""
for unit_ip in await wordpress.get_unit_ips():
wordpress_client = WordpressClient(
host=unit_ip,
username="admin",
password=await wordpress.get_default_admin_password(),
is_admin=True,
)
assert set(wordpress_client.list_themes()) == set(
WordpressCharm._WORDPRESS_DEFAULT_THEMES
), "themes installed on WordPress should match default themes defined in charm.py"
assert set(wordpress_client.list_plugins()) == set(
WordpressCharm._WORDPRESS_DEFAULT_PLUGINS
), "plugins installed on WordPress should match default plugins defined in charm.py"


@pytest.mark.usefixtures("prepare_mysql", "prepare_swift")
async def test_apache_config(wordpress: WordpressApp, ops_test: OpsTest):
"""
Expand Down
4 changes: 3 additions & 1 deletion tests/integration/test_cos_grafana.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ async def test_grafana_integration(
act: grafana charm joins relation
assert: grafana wordpress dashboard can be found
"""
grafana = await wordpress.model.deploy("grafana-k8s", channel="1.0/stable", trust=True)
grafana = await wordpress.model.deploy(
"grafana-k8s", channel="1.0/stable", revision=82, series="focal", trust=True
)
await wordpress.model.wait_for_idle(status="active", apps=["grafana-k8s"], timeout=20 * 60)
await wordpress.model.add_relation("wordpress-k8s:grafana-dashboard", "grafana-k8s")
await wordpress.model.wait_for_idle(
Expand Down
2 changes: 0 additions & 2 deletions wordpress_rock/rockcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ parts:
mkdir -p wordpress_install_dir
(cd wordpress_install_dir; $CRAFT_PART_BUILD/wp core download --version=${WP_VERSION} --allow-root)
rm -rf wordpress_install_dir/wp-content/themes/twentytwentythree
rm -rf wordpress_install_dir/wp-content/themes/twentytwentyfour
cp -R . $CRAFT_PART_INSTALL
organize:
wordpress_install_dir: /var/www/html
Expand Down

0 comments on commit c766633

Please sign in to comment.