Skip to content

Commit

Permalink
add bdd_vars, test_run_identifier and now fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
Davide Moro committed May 26, 2017
1 parent 8b50b24 commit e35b45d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
26 changes: 26 additions & 0 deletions pypom_navigation/plugin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-

import pytest
import uuid
import datetime

from .util import (
get_page_class,
Expand Down Expand Up @@ -179,3 +181,27 @@ def skip_by_skin_names(request, skin):
if request.node.get_marker('skip_skins'):
if skin in request.node.get_marker('skip_skins').args[0]:
pytest.skip('skipped on this skin: {}'.format(skin))


@pytest.fixture
def test_run_identifier(skin):
""" Return a session based random prefixed UUID used for
identifying data created in this test run.
"""
return "QA-{0}-{1}".format(str(uuid.uuid1()), skin)


@pytest.fixture
def now():
""" Now fixture, returns current datetime object """
return datetime.datetime.now()


@pytest.fixture
def bdd_vars(test_run_identifier, skin, now):
""" BDD step vars for test parametrization for dynamic values
such as test_run_identifier or datetime
"""
return {'test_run_identifier': test_run_identifier,
'skin': skin,
'datetime': now.isoformat()}
18 changes: 18 additions & 0 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,21 @@ def test_navigation():
page_mappings,
credentials_mapping,
skin, skin_base_url) is None


def test_test_run_identifier(test_run_identifier, skin):
""" Test run identifier """
assert test_run_identifier.startswith('QA-')
assert test_run_identifier.endswith('-{0}'.format(skin))


def test_now(now):
""" Test now """
assert now.isoformat()


def test_bdd_vars(bdd_vars, skin, now, test_run_identifier):
""" Test bdd_vars """
assert bdd_vars['skin'] == skin
assert bdd_vars['datetime'] == now.isoformat()
assert bdd_vars['test_run_identifier'] == test_run_identifier

0 comments on commit e35b45d

Please sign in to comment.