Skip to main content

Default conf. files and conf. file generator for `zeo_connector`.

Project description

Introduction

https://badge.fury.io/py/zeo_connector_defaults.png https://img.shields.io/pypi/dm/zeo_connector_defaults.svg https://img.shields.io/pypi/l/zeo_connector_defaults.svg https://img.shields.io/github/issues/Bystroushaak/zeo_connector_defaults.svg

Default configuration files and configuration file generator for zeo_connector.

Documentation

This project provides generators of the testing environment for the ZEO-related tests. It also provides generator, for the basic ZEO configuration files.

zeo_connector_gen_defaults.py

This script simplifies the process of generation of ZEO configuration files.

ZEO tests

Typically, when you test your program which is using the ZEO database, you need to generate the database files, then run new thread with runzeo program, do tests, cleanup and stop the thread.

This module provides two functions, which do exactly this:

  • zeo_connector_defaults.generate_environment()

  • zeo_connector_defaults.cleanup_environment()

generate_environment

This function will create temporary directory in /tmp and copy template files for ZEO client and server into this directory. Then it starts new thread with runzeo program using the temporary server configuration file.

Names of the files may be resolved using tmp_context_name() function.

Note:

This function works best, if added to setup part of your test environment.

cleanup_environment

Function, which stops the running runzeo thread and delete all the temporary files.

Note:

This function works best, if added to setup part of your test environment.

Context functions

There is also two temp environment access functions:

  • tmp_context_name()

  • tmp_context()

Both of them take one fn argument and return name of the file (tmp_context_name()) or content of the file (tmp_context()) in context of random temporary directory.

For example:

tmp_context_name("zeo_client.conf")

returns the absolute path to the file zeo_client.conf, which may be for example /tmp/tmp1r5keh/zeo_client.conf.

You may also call it without the arguments, which will return just the name of the temporary directory:

tmp_context_name()

which should return something like /tmp/tmp1r5keh.

Tests example

Here is the example how your test may look like:

#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
# Interpreter version: python 2.7
#
# Imports =====================================================================
import pytest

from zeo_connector_defaults import generate_environment
from zeo_connector_defaults import cleanup_environment
from zeo_connector_defaults import tmp_context_name


# Setup =======================================================================
def setup_module(module):
    generate_environment()


def teardown_module(module):
    cleanup_environment()


# Fixtures ====================================================================
@pytest.fixture
def zeo_conf_wrapper():
    return ZEOConfWrapper(
        conf_path=tmp_context_name("zeo_client.conf"),
    ...

# Tests =======================================================================
def test_something(zeo_conf_wrapper):
    ...

Installation

Module is hosted at PYPI, and can be easily installed using PIP:

sudo pip install zeo_connector_defaults

Source code

Project is released under the MIT license. Source code can be found at GitHub:

Changelog

0.2.1

  • Switched to complete randomly generated ZEO environment (random name in /tmp, and random ports for ZEO server process).

0.2.0

  • Bugfix of path parsing.

0.1.0

  • Project created.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zeo_connector_defaults-0.2.1.tar.gz (6.6 kB view details)

Uploaded Source

File details

Details for the file zeo_connector_defaults-0.2.1.tar.gz.

File metadata

File hashes

Hashes for zeo_connector_defaults-0.2.1.tar.gz
Algorithm Hash digest
SHA256 ad7d154a911eb911122ce4ee6f5da5972c00c7f64336bc0860094c9019b82760
MD5 bc70c8cf5eef34a9624c2ff6dd6cf3a0
BLAKE2b-256 2fbf31222bc361d5baa123f52381b6946060f3b408038097bdb13e516cb2e9c6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page