Commit a5afc5bf by Łukasz Nowak

playbook: Add tests for standalone-shared

Those tests are used by deploy-test ERP5TestNode testsuite.
1 parent a50c4470
from setuptools import setup, find_packages
version = '0.0'
name = 'standalone-shared-tests'
setup(name=name,
version=version,
tests_require=['requests'],
test_suite='tests'
)
import requests
import unittest
import os
class TestSiteHttp(unittest.TestCase):
"""Check that configuration generated in the machine works"""
def setUp(self):
self.http_url = os.environ['TEST_ACCESS_URL_HTTP']
self.https_url = os.environ['TEST_ACCESS_URL_HTTPS']
def test_http_erp5_login_form(self):
"""Check that accessing site over HTTP redirects to HTTPS"""
result = requests.get(self.http_url + '/erp5/login_form', verify=False)
self.assertTrue(result.ok)
self.assertTrue(result.is_redirect)
self.assertTrue(result.is_permanent_redirect)
self.assertEqual(result.status_code, 302)
self.assertTrue(result.headers['Location'].endswith('/erp5/login_form'))
self.assertTrue(result.headers['Location'].startswith('https://'))
import requests
import unittest
import os
class TestSiteHttps(unittest.TestCase):
"""Check that configuration generated in the machine works"""
def setUp(self):
self.http_url = os.environ['TEST_ACCESS_URL_HTTP']
self.https_url = os.environ['TEST_ACCESS_URL_HTTPS']
def test_https_erp5_login_form(self):
"""Check that accessing login_form over HTTPS works"""
result = requests.get(self.https_url + '/erp5/login_form', verify=False)
self.assertTrue(result.ok)
self.assertFalse(result.is_redirect)
self.assertFalse(result.is_permanent_redirect)
self.assertEqual(result.status_code, 200)
self.assertTrue('ERP5 Free Open Source ERP and CRM' in result.text)
def test_https_erp5(self):
"""Check that accessing site over HTTPS redirects to login_form"""
result = requests.get(
self.https_url + '/erp5/', verify=False, allow_redirects=False)
self.assertTrue(result.ok)
self.assertTrue(result.is_redirect)
self.assertFalse(result.is_permanent_redirect)
self.assertEqual(result.status_code, 302)
self.assertTrue(result.headers['Location'].endswith('/erp5/login_form'))
import unittest
import os
import json
class TestSiteStatus(unittest.TestCase):
"""Asserts site status"""
def setUp(self):
self.site_status_json = os.environ['TEST_SITE_STATUS_JSON']
self.status_dict = json.load(open(self.site_status_json))
def test_build(self):
"""Checks that site was correctly created"""
# expose output for debugging
print 'Standard output:'
print self.status_dict['stdout']
print 'Standard error:'
print self.status_dict['stderr']
# Assert success
self.assertTrue(self.status_dict['success'])
def test_build_time_less_6h(self):
# Check that site was built in less than 6h
self.assertLess(self.status_dict['duration'], (3600. * 6))
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!