Refactor PHP tests dropping legacy controller (backend)
This commit is contained in:
parent
58395147c9
commit
14fbd98e33
|
@ -63,9 +63,9 @@ class StaticWebAppMixin(object):
|
|||
)
|
||||
|
||||
|
||||
class PHPFcidWebAppMixin(StaticWebAppMixin):
|
||||
backend = backends.phpfcgid.PHPFcgidBackend
|
||||
type_value = 'php5.2'
|
||||
class PHPFPMWebAppMixin(StaticWebAppMixin):
|
||||
backend = backends.php.PHPController
|
||||
type_value = 'php5.5'
|
||||
token = random_ascii(100)
|
||||
page = (
|
||||
'index.php',
|
||||
|
@ -74,11 +74,6 @@ class PHPFcidWebAppMixin(StaticWebAppMixin):
|
|||
)
|
||||
|
||||
|
||||
class PHPFPMWebAppMixin(PHPFcidWebAppMixin):
|
||||
backend = backends.phpfpm.PHPFPMBackend
|
||||
type_value = 'php5.5'
|
||||
|
||||
|
||||
class RESTWebAppMixin(object):
|
||||
def setUp(self):
|
||||
super(RESTWebAppMixin, self).setUp()
|
||||
|
@ -120,10 +115,6 @@ class StaticRESTWebAppTest(StaticWebAppMixin, RESTWebAppMixin, WebAppMixin, Base
|
|||
pass
|
||||
|
||||
|
||||
class PHPFcidRESTWebAppTest(PHPFcidWebAppMixin, RESTWebAppMixin, WebAppMixin, BaseLiveServerTestCase):
|
||||
pass
|
||||
|
||||
|
||||
class PHPFPMRESTWebAppTest(PHPFPMWebAppMixin, RESTWebAppMixin, WebAppMixin, BaseLiveServerTestCase):
|
||||
pass
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import requests
|
|||
from orchestra.contrib.domains.models import Domain, Record
|
||||
from orchestra.contrib.domains.backends import Bind9MasterDomainController
|
||||
from orchestra.contrib.orchestration.models import Server, Route
|
||||
from orchestra.contrib.webapps.tests.functional_tests.tests import StaticWebAppMixin, RESTWebAppMixin, WebAppMixin, PHPFcidWebAppMixin, PHPFPMWebAppMixin
|
||||
from orchestra.contrib.webapps.tests.functional_tests.tests import StaticWebAppMixin, RESTWebAppMixin, WebAppMixin, PHPFPMWebAppMixin
|
||||
from orchestra.utils.tests import BaseLiveServerTestCase, random_ascii, save_response_on_error
|
||||
|
||||
from ... import backends
|
||||
|
@ -22,7 +22,7 @@ class WebsiteMixin(WebAppMixin):
|
|||
'orchestra.contrib.webapps',
|
||||
'orchestra.contrib.systemusers',
|
||||
)
|
||||
|
||||
|
||||
def add_route(self):
|
||||
super(WebsiteMixin, self).add_route()
|
||||
server = Server.objects.get()
|
||||
|
@ -30,11 +30,11 @@ class WebsiteMixin(WebAppMixin):
|
|||
Route.objects.get_or_create(backend=backend, match=True, host=server)
|
||||
backend = Bind9MasterDomainController.get_name()
|
||||
Route.objects.get_or_create(backend=backend, match=True, host=server)
|
||||
|
||||
|
||||
def validate_add_website(self, name, domain):
|
||||
url = 'http://%s/%s' % (domain.name, self.page[0])
|
||||
self.assertEqual(self.page[2], requests.get(url).content)
|
||||
|
||||
|
||||
def test_add(self):
|
||||
# TODO domains with "_" bad name!
|
||||
domain_name = '%sdomain.lan' % random_ascii(10)
|
||||
|
@ -55,7 +55,7 @@ class RESTWebsiteMixin(RESTWebAppMixin):
|
|||
@save_response_on_error
|
||||
def save_domain(self, domain):
|
||||
self.rest.domains.retrieve().get().save()
|
||||
|
||||
|
||||
@save_response_on_error
|
||||
def add_website(self, name, domain, webapp, path='/'):
|
||||
domain = self.rest.domains.retrieve(name=domain).get()
|
||||
|
@ -65,11 +65,11 @@ class RESTWebsiteMixin(RESTWebAppMixin):
|
|||
'path': path
|
||||
}]
|
||||
self.rest.websites.create(name=name, domains=[domain], contents=contents)
|
||||
|
||||
|
||||
@save_response_on_error
|
||||
def delete_website(self, name):
|
||||
self.rest.websites.retrieve(name=name).delete()
|
||||
|
||||
|
||||
@save_response_on_error
|
||||
def add_content(self, website, webapp, path):
|
||||
website = self.rest.websites.retrieve(name=website).get()
|
||||
|
@ -101,20 +101,7 @@ class StaticRESTWebsiteTest(RESTWebsiteMixin, StaticWebAppMixin, WebsiteMixin, B
|
|||
self.add_website(website, domain, webapp)
|
||||
self.addCleanup(self.delete_website, website)
|
||||
self.validate_add_website(website, domain)
|
||||
|
||||
self.type_value = PHPFcidWebAppMixin.type_value
|
||||
self.backend = PHPFcidWebAppMixin.backend
|
||||
self.page = PHPFcidWebAppMixin.page
|
||||
self.add_route()
|
||||
webapp = '%s_%s_webapp' % (random_ascii(10), self.type_value)
|
||||
self.add_webapp(webapp)
|
||||
self.addCleanup(self.delete_webapp, webapp)
|
||||
self.upload_webapp(webapp)
|
||||
path = '/%s' % webapp
|
||||
self.add_content(website, webapp, path)
|
||||
url = 'http://%s%s/%s' % (domain.name, path, self.page[0])
|
||||
self.assertEqual(self.page[2], requests.get(url).content)
|
||||
|
||||
|
||||
self.type_value = PHPFPMWebAppMixin.type_value
|
||||
self.backend = PHPFPMWebAppMixin.backend
|
||||
self.page = PHPFPMWebAppMixin.page
|
||||
|
@ -124,14 +111,23 @@ class StaticRESTWebsiteTest(RESTWebsiteMixin, StaticWebAppMixin, WebsiteMixin, B
|
|||
self.addCleanup(self.delete_webapp, webapp)
|
||||
self.upload_webapp(webapp)
|
||||
path = '/%s' % webapp
|
||||
|
||||
self.add_content(website, webapp, path)
|
||||
url = 'http://%s%s/%s' % (domain.name, path, self.page[0])
|
||||
self.assertEqual(self.page[2], requests.get(url).content)
|
||||
|
||||
self.type_value = PHPFPMWebAppMixin.type_value
|
||||
self.backend = PHPFPMWebAppMixin.backend
|
||||
self.page = PHPFPMWebAppMixin.page
|
||||
self.add_route()
|
||||
webapp = '%s_%s_webapp' % (random_ascii(10), self.type_value)
|
||||
self.add_webapp(webapp)
|
||||
self.addCleanup(self.delete_webapp, webapp)
|
||||
self.upload_webapp(webapp)
|
||||
path = '/%s' % webapp
|
||||
|
||||
class PHPFcidRESTWebsiteTest(RESTWebsiteMixin, PHPFcidWebAppMixin, WebsiteMixin, BaseLiveServerTestCase):
|
||||
pass
|
||||
self.add_content(website, webapp, path)
|
||||
url = 'http://%s%s/%s' % (domain.name, path, self.page[0])
|
||||
self.assertEqual(self.page[2], requests.get(url).content)
|
||||
|
||||
|
||||
class PHPFPMRESTWebsiteTest(RESTWebsiteMixin, PHPFPMWebAppMixin, WebsiteMixin, BaseLiveServerTestCase):
|
||||
|
|
Loading…
Reference in New Issue