Skip to content

Commit

Permalink
Test SMTP settings
Browse files Browse the repository at this point in the history
Use a new scaffolding that makes sure there's a preexisting database.
  • Loading branch information
yajo committed Jan 24, 2018
1 parent d316d80 commit b75b35c
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,23 @@ def test_addons_filtered(self):
("bash", "-c", 'test "$(addons list -c)" == crm,sale'),
)

def test_settings(self):
"""Test settings are filled OK"""
folder = join(SCAFFOLDINGS_DIR, "settings")
commands = (
# Odoo should install
("--stop-after-init",)
# SMTP settings work
("./custom/scripts/test_smtp_settings.py",),
)
for sub_env in matrix(odoo={"8.0"}):
self.compose_test(
folder, sub_env,
# Odoo 8.0 needs a preexisting DB
("createdb",), *commands)
for sub_env in matrix(odoo_skip={"8.0"}):
self.compose_test(folder, sub_env, *commands)

def test_smallest(self):
"""Tests for the smallest possible environment."""
commands = (
Expand Down
1 change: 1 addition & 0 deletions tests/scaffoldings/settings/10.0.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM tecnativa/odoo-base:10.0
1 change: 1 addition & 0 deletions tests/scaffoldings/settings/11.0.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM tecnativa/odoo-base:11.0
1 change: 1 addition & 0 deletions tests/scaffoldings/settings/8.0.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM tecnativa/odoo-base:8.0
1 change: 1 addition & 0 deletions tests/scaffoldings/settings/9.0.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM tecnativa/odoo-base:9.0
17 changes: 17 additions & 0 deletions tests/scaffoldings/settings/custom/scripts/test_smtp_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/local/bin/python-odoo-shell
from odoo.exceptions import UserError
from odoo.tools import config

assert config.get("email_from") == "[email protected]"
assert config.get("smtp_password") is False
assert config.get("smtp_port") == 1025
assert config.get("smtp_server") == "mailhog"
assert config.get("smtp_ssl") is False
assert config.get("smtp_user") is False

try:
env["ir.mail_server"].test_smtp_connection()
except UserError as msg:
assert "Connection Test Succeeded!" in msg.args[0]
else:
raise Exception("This shouldn't happen :/")
Empty file.
Empty file.
12 changes: 12 additions & 0 deletions tests/scaffoldings/settings/custom/src/repos.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Odoo is always required
./odoo:
defaults:
# Shallow repositores are faster & thinner
depth: $DEPTH_DEFAULT
remotes:
ocb: https://github.com/OCA/OCB.git
odoo: https://github.com/odoo/odoo.git
target:
ocb $ODOO_VERSION
merges:
- ocb $ODOO_VERSION
38 changes: 38 additions & 0 deletions tests/scaffoldings/settings/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
version: "2.1"
services:
odoo:
build:
context: ./
dockerfile: ${ODOO_MINOR}.Dockerfile
args:
AUTO_REQUIREMENTS: "true"
CONFIG_BUILD: 'false'
LOG_LEVEL: DEBUG
tty: true
environment:
EMAIL_FROM: [email protected]
PGUSER: another_odoo
PGPASSWORD: anotherodoopassword
PGHOST: postgresql
PGDATABASE: ${DBNAME:-prod}
SMTP_SERVER: mailhog
SMTP_PORT: 1025 # MailHog default
depends_on:
- postgresql
volumes:
- filestore:/var/lib/odoo:z

postgresql:
image: postgres:${DB_VERSION}-alpine
environment:
POSTGRES_USER: another_odoo
POSTGRES_PASSWORD: anotherodoopassword
volumes:
- db:/var/lib/postgresql/data:z

mailhog:
image: mailhog/mailhog

volumes:
db:
filestore:

0 comments on commit b75b35c

Please sign in to comment.