Ejemplo n.º 1
0
def pytest_runtest_teardown():
    """
    This method is executed always in the end of each test, even if it fails or raises exception in
    prepare stage.
    """
    if TestRun.outcome == "skipped":
        return

    TestRun.LOGGER.end_all_groups()

    with TestRun.LOGGER.step("Cleanup after test"):
        try:
            if TestRun.executor:
                if TestRun.executor.is_active():
                    TestRun.executor.wait_for_connection()
                Udev.enable()
                unmount_cas_devices()
                casadm.stop_all_caches()
        except Exception as ex:
            TestRun.LOGGER.warning(
                f"Exception occured during platform cleanup.\n"
                f"{str(ex)}\n{traceback.format_exc()}")

        if 'test_wrapper' in sys.modules:
            try:
                test_wrapper.cleanup()
            except Exception as ex:
                TestRun.LOGGER.warning(
                    f"Exception occured during test wrapper cleanup.\n{str(ex)}"
                    f"\n{traceback.format_exc()}")

    TestRun.LOGGER.end()
    if TestRun.executor:
        TestRun.LOGGER.get_additional_logs()
    Log.destroy()
Ejemplo n.º 2
0
def pytest_runtest_teardown():
    """
    This method is executed always in the end of each test, even if it fails or raises exception in
    prepare stage.
    """
    TestRun.LOGGER.end_all_groups()

    with TestRun.LOGGER.step("Cleanup after test"):
        try:
            if TestRun.executor:
                if not TestRun.executor.is_active():
                    TestRun.executor.wait_for_connection()
                Udev.enable()
                kill_all_io()
                unmount_cas_devices()
                if installer.check_if_installed():
                    casadm.remove_all_detached_cores()
                    casadm.stop_all_caches()
                    from api.cas.init_config import InitConfig
                    InitConfig.create_default_init_config()
                DeviceMapper.remove_all()
        except Exception as ex:
            TestRun.LOGGER.warning(f"Exception occurred during platform cleanup.\n"
                                   f"{str(ex)}\n{traceback.format_exc()}")

    TestRun.LOGGER.end()
    for dut in TestRun.duts:
        with TestRun.use_dut(dut):
            if TestRun.executor:
                os.makedirs(os.path.join(TestRun.LOGGER.base_dir, "dut_info", dut.ip),
                            exist_ok=True)
                TestRun.LOGGER.get_additional_logs()
    Log.destroy()
    TestRun.teardown()
Ejemplo n.º 3
0
    def runtest_teardown():
        TestRun.LOGGER.end_all_groups()

        with TestRun.LOGGER.step("Cleanup after test"):
            try:
                if TestRun.executor.is_active():
                    TestRun.executor.wait_for_connection()
            except Exception:
                TestRun.LOGGER.warning("Exception occured during platform cleanup.")

        TestRun.LOGGER.end()
        if TestRun.executor:
            TestRun.LOGGER.get_additional_logs()
        Log.destroy()
        TestRun.teardown()
def pytest_runtest_teardown():
    """
    This method is executed always in the end of each test,
    even if it fails or raises exception in prepare stage.
    """

    TestRun.LOGGER.end_all_groups()

    with TestRun.LOGGER.step("Cleanup after test"):
        try:
            if TestRun.executor.is_active():
                TestRun.executor.wait_for_connection()

        except Exception:
            TestRun.LOGGER.warning(
                "Exception occured during platform cleanup.")

    dut_cleanup()
    TestRun.LOGGER.end()
    Log.destroy()
Ejemplo n.º 5
0
class DiaMarketScraping(SuperMarketScraping):
    """Class represents DiaMarketScraping fields: market, logger & url"""

    market: str = "DIA"
    logger: Log = Log().get_logger(__name__)
    url: str = "https://diaonline.supermercadosdia.com.ar/especial-ofertas"

    def get_products_from_markets(self) -> list:
        product_list: list[SupermarketProduct] = []
        response = get_response_by_url(url=self.url)

        self.logger.info(
            f"*********************[ SCRAPING STARTED ]*********************")

        for market_value in response.find_all("li"):
            try:
                product_name, product_price = get_title_product_and_product_value(
                    supermarket=self.market, value=market_value)

                new_product: SupermarketProduct = SupermarketProductSchema(
                ).load({
                    "market": self.market,
                    "product": product_name,
                    "price": product_price,
                })

                product_list.append(new_product)

                self.logger.info(
                    f'* The product was correctly extracted: "{new_product.__str__()}"'
                )

            except:
                pass

        self.logger.info(
            f"*********************[ SCRAPING FINISHED ]*********************")

        return product_list
Ejemplo n.º 6
0
from schemas.cryptoCurrencyPrices_schema import CryptoCurrencyPricesSchema
from model.cryptoCurrencyPrices_model import CryptoCurrencyPrices
from model.cryptoCurrency_model import CryptoCurrency
from datetime import datetime
from log.logger import Log
import requests

# GLOBAL VALUES #
logger = Log().getLogger(__name__)
time_out = 20


def get_crypto_name_by_url(url: str) -> str:
    """Returns the name of the exchange in uppercase"""
    return url.split("/")[4].upper()


def get_str_time_now() -> str:
    """Return the current date in String format"""
    return datetime.now().strftime("%H:%M:%S %d-%m-%Y")


def get_str_payload(payload: dict) -> str:
    """Return the parameter payload in string format depending on: '/'

    :param payload: dict
    :return: str
    """
    try:
        payload_str = ""
        for p in payload: