Пример #1
0
#
##############################################################################

import os
import textwrap
import logging
import tempfile
import time
from six.moves.urllib.parse import urlparse

import requests

from slapos.testing.testcase import makeModuleSetUpAndTestCaseClass

setUpModule, SlapOSInstanceTestCase = makeModuleSetUpAndTestCaseClass(
    os.path.abspath(
        os.path.join(os.path.dirname(__file__), '..', 'software.cfg')))


class TestTheia(SlapOSInstanceTestCase):
    def setUp(self):
        self.theia_url = self.computer_partition.getConnectionParameterDict(
        )['url']

    def test_http_get(self):
        resp = requests.get(self.theia_url, verify=False)
        self.assertEqual(requests.codes.ok, resp.status_code)

        # without login/password, this is unauthorized
        parsed_url = urlparse(self.theia_url)
        resp = requests.get(parsed_url._replace(netloc='[{}]:{}'.format(
Пример #2
0
##############################################################################

import os
import textwrap
import hashlib
from io import BytesIO

from PIL import Image
import requests
import plantuml

from slapos.recipe.librecipe import generateHashFromFiles
from slapos.testing.testcase import makeModuleSetUpAndTestCaseClass

setUpModule, PlantUMLTestCase = makeModuleSetUpAndTestCaseClass(
    os.path.abspath(
        os.path.join(os.path.dirname(__file__), '..', 'software.cfg')))


class TestSimpleDiagram(PlantUMLTestCase):
    def setUp(self):
        self.url = self.computer_partition.getConnectionParameterDict()["url"]
        self.plantuml = plantuml.PlantUML(
            url='{}/png/'.format(self.url),
            http_opts={"disable_ssl_certificate_validation": True})

    def assertImagesSimilar(self, i1, i2, tolerance=5):
        """Assert images difference between images is less than `tolerance` %.
   taken from https://rosettacode.org/wiki/Percentage_difference_between_images
    """
        pairs = zip(i1.getdata(), i2.getdata())
Пример #3
0
from io import BytesIO

import paramiko
import requests
from PIL import Image
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait

from slapos.testing.testcase import makeModuleSetUpAndTestCaseClass
from slapos.testing.utils import findFreeTCPPort

setUpModule, SeleniumServerTestCase = makeModuleSetUpAndTestCaseClass(
    os.path.abspath(
        os.path.join(os.path.dirname(__file__), '..', 'software.cfg')))


class WebServerMixin(object):
    """Mixin class which provides a simple web server reachable at self.server_url
  """
    def setUp(self):
        """Start a minimal web server.
    """
        class TestHandler(BaseHTTPRequestHandler):
            """Request handler for our test server.

      The implemented server is:
       - submit q and you'll get a page with q as title
       - upload a file and the file content will be displayed in div.uploadedfile
Пример #4
0
import json
import time

from six.moves.urllib.parse import urlparse
from six.moves.urllib.parse import quote
from six.moves.urllib.parse import urljoin
from six.moves.configparser import ConfigParser
import requests
import six

from slapos.recipe.librecipe import generateHashFromFiles
from slapos.testing.testcase import makeModuleSetUpAndTestCaseClass
from slapos.util import bytes2str

setUpModule, SlapOSInstanceTestCase = makeModuleSetUpAndTestCaseClass(
    os.path.abspath(
        os.path.join(os.path.dirname(__file__), '..',
                     'software%s.cfg' % ("-py3" if six.PY3 else ""))))


class SlaprunnerTestCase(SlapOSInstanceTestCase):
    # Slaprunner uses unix sockets, so it needs short paths.
    __partition_reference__ = 's'


class SlaprunnerTestCase(SlapOSInstanceTestCase):
    # Slaprunner uses unix sockets, so it needs short paths.
    __partition_reference__ = 's'

    def _openSoftwareRelease(self,
                             software_release="erp5testnode/testsuite/dummy"):
        parameter_dict = self.computer_partition.getConnectionParameterDict()