Set env variable to skip REST_API tests.

This commit is contained in:
Santiago L 2021-03-31 10:39:47 +02:00
parent e7aabf4799
commit dc722ec17a
5 changed files with 113 additions and 96 deletions

View file

@ -1,22 +1,24 @@
import MySQLdb
import os import os
import socket import socket
import time import time
import unittest
import MySQLdb
from django.conf import settings as djsettings from django.conf import settings as djsettings
from django.core.management.base import CommandError from django.core.management.base import CommandError
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from selenium.webdriver.support.select import Select
from orchestra.admin.utils import change_url from orchestra.admin.utils import change_url
from orchestra.contrib.orchestration.models import Server, Route from orchestra.contrib.orchestration.models import Route, Server
from orchestra.utils.sys import sshrun from orchestra.utils.sys import sshrun
from orchestra.utils.tests import (BaseLiveServerTestCase, random_ascii, save_response_on_error, from orchestra.utils.tests import (BaseLiveServerTestCase, random_ascii,
snapshot_on_error) save_response_on_error, snapshot_on_error)
from selenium.webdriver.support.select import Select
from ... import backends, settings from ... import backends, settings
from ...models import Database, DatabaseUser from ...models import Database, DatabaseUser
TEST_REST_API = int(os.getenv('TEST_REST_API', '0'))
class DatabaseTestMixin(object): class DatabaseTestMixin(object):
MASTER_SERVER = os.environ.get('ORCHESTRA_SECOND_SERVER', 'localhost') MASTER_SERVER = os.environ.get('ORCHESTRA_SECOND_SERVER', 'localhost')
@ -181,6 +183,7 @@ class MySQLControllerMixin(object):
"""mysql mysql -e 'SELECT * FROM user WHERE user="%(username)s";'""" % context, display=False).stdout) """mysql mysql -e 'SELECT * FROM user WHERE user="%(username)s";'""" % context, display=False).stdout)
@unittest.skipUnless(TEST_REST_API, "REST API tests")
class RESTDatabaseMixin(DatabaseTestMixin): class RESTDatabaseMixin(DatabaseTestMixin):
def setUp(self): def setUp(self):
super(RESTDatabaseMixin, self).setUp() super(RESTDatabaseMixin, self).setUp()

View file

@ -1,24 +1,26 @@
import os import os
import smtplib import smtplib
import time import time
import requests import unittest
from email.mime.text import MIMEText from email.mime.text import MIMEText
import requests
from django.conf import settings as djsettings from django.conf import settings as djsettings
from django.core.management.base import CommandError from django.core.management.base import CommandError
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from selenium.webdriver.support.select import Select
from orchestra.admin.utils import change_url from orchestra.admin.utils import change_url
from orchestra.contrib.domains.models import Domain from orchestra.contrib.domains.models import Domain
from orchestra.contrib.orchestration.models import Server, Route from orchestra.contrib.orchestration.models import Route, Server
from orchestra.utils.sys import sshrun from orchestra.utils.sys import sshrun
from orchestra.utils.tests import (BaseLiveServerTestCase, random_ascii, snapshot_on_error, from orchestra.utils.tests import (BaseLiveServerTestCase, random_ascii,
save_response_on_error) save_response_on_error, snapshot_on_error)
from selenium.webdriver.support.select import Select
from ... import backends, settings from ... import backends, settings
from ...models import List from ...models import List
TEST_REST_API = int(os.getenv('TEST_REST_API', '0'))
class ListMixin(object): class ListMixin(object):
MASTER_SERVER = os.environ.get('ORCHESTRA_SLAVE_SERVER', 'localhost') MASTER_SERVER = os.environ.get('ORCHESTRA_SLAVE_SERVER', 'localhost')
@ -158,6 +160,7 @@ class ListMixin(object):
self.validate_delete(name) self.validate_delete(name)
@unittest.skipUnless(TEST_REST_API, "REST API tests")
class RESTListMixin(ListMixin): class RESTListMixin(ListMixin):
def setUp(self): def setUp(self):
super(RESTListMixin, self).setUp() super(RESTListMixin, self).setUp()

View file

@ -4,6 +4,7 @@ import poplib
import smtplib import smtplib
import time import time
import textwrap import textwrap
import unittest
from email.mime.text import MIMEText from email.mime.text import MIMEText
from django.apps import apps from django.apps import apps
@ -21,6 +22,8 @@ from orchestra.utils.tests import BaseLiveServerTestCase, random_ascii, snapshot
from ... import backends, settings from ... import backends, settings
from ...models import Mailbox from ...models import Mailbox
TEST_REST_API = int(os.getenv('TEST_REST_API', '0'))
class MailboxMixin(object): class MailboxMixin(object):
MASTER_SERVER = os.environ.get('ORCHESTRA_SLAVE_SERVER', 'localhost') MASTER_SERVER = os.environ.get('ORCHESTRA_SLAVE_SERVER', 'localhost')
@ -235,6 +238,7 @@ class MailboxMixin(object):
# TODO test autoreply # TODO test autoreply
@unittest.skipUnless(TEST_REST_API, "REST API tests")
class RESTMailboxMixin(MailboxMixin): class RESTMailboxMixin(MailboxMixin):
def setUp(self): def setUp(self):
super(RESTMailboxMixin, self).setUp() super(RESTMailboxMixin, self).setUp()

View file

@ -2,6 +2,7 @@ import ftplib
import os import os
import re import re
import time import time
import unittest
from functools import partial from functools import partial
import paramiko import paramiko
@ -21,6 +22,7 @@ from ... import backends
from ...models import SystemUser from ...models import SystemUser
TEST_REST_API = int(os.getenv('TEST_REST_API', '0'))
r = partial(run, silent=True, display=False) r = partial(run, silent=True, display=False)
sshr = partial(sshrun, silent=True, display=False) sshr = partial(sshrun, silent=True, display=False)
@ -185,6 +187,7 @@ class SystemUserMixin(object):
# TODO test resources # TODO test resources
@unittest.skipUnless(TEST_REST_API, "REST API tests")
class RESTSystemUserMixin(SystemUserMixin): class RESTSystemUserMixin(SystemUserMixin):
def setUp(self): def setUp(self):
super(RESTSystemUserMixin, self).setUp() super(RESTSystemUserMixin, self).setUp()

View file

@ -1,16 +1,19 @@
import ftplib import ftplib
import os import os
import unittest
from io import StringIO from io import StringIO
from django.conf import settings as djsettings from django.conf import settings as djsettings
from orchestra.contrib.orchestration.models import Route, Server
from orchestra.contrib.orchestration.models import Server, Route
from orchestra.contrib.systemusers.backends import UNIXUserController from orchestra.contrib.systemusers.backends import UNIXUserController
from orchestra.utils.tests import BaseLiveServerTestCase, random_ascii, snapshot_on_error, save_response_on_error from orchestra.utils.tests import BaseLiveServerTestCase, random_ascii, save_response_on_error, snapshot_on_error
from ... import backends from ... import backends
TEST_REST_API = int(os.getenv('TEST_REST_API', '0'))
class WebAppMixin(object): class WebAppMixin(object):
MASTER_SERVER = os.environ.get('ORCHESTRA_MASTER_SERVER', 'localhost') MASTER_SERVER = os.environ.get('ORCHESTRA_MASTER_SERVER', 'localhost')
DEPENDENCIES = ( DEPENDENCIES = (
@ -74,6 +77,7 @@ class PHPFPMWebAppMixin(StaticWebAppMixin):
) )
@unittest.skipUnless(TEST_REST_API, "REST API tests")
class RESTWebAppMixin(object): class RESTWebAppMixin(object):
def setUp(self): def setUp(self):
super(RESTWebAppMixin, self).setUp() super(RESTWebAppMixin, self).setUp()