| |
@@ -23,6 +23,7 @@
|
| |
import tempfile
|
| |
import copy
|
| |
import time
|
| |
+ import pytest
|
| |
|
| |
import resultsdb
|
| |
import resultsdb.cli
|
| |
@@ -863,13 +864,10 @@
|
| |
assert data['data'][1]['testcase']['name'] == self.ref_testcase_name
|
| |
assert data['data'][1]['outcome'] == "FAILED"
|
| |
|
| |
+ @pytest.mark.skipif(not os.getenv('POSTGRES_5432_TCP'),
|
| |
+ reason="Requires PostgreSQL, because DISTINCT ON works differently in SQLite")
|
| |
def test_get_results_latest_distinct_on(self):
|
| |
"""This test requires PostgreSQL, because DISTINCT ON does work differently in SQLite"""
|
| |
- if os.getenv('NO_CAN_HAS_POSTGRES', None):
|
| |
- return
|
| |
- if resultsdb.app.config['SQLALCHEMY_DATABASE_URI'].startswith('sqlite'):
|
| |
- raise Exception("This test requires PostgreSQL to work properly. You can disable it by setting NO_CAN_HAS_POSTGRES env variable to any non-empty value")
|
| |
-
|
| |
self.helper_create_testcase()
|
| |
|
| |
self.helper_create_result(outcome="PASSED", data={'scenario': 'scenario1'}, testcase=self.ref_testcase_name)
|
| |
@@ -886,21 +884,18 @@
|
| |
assert len(data['data']) == 1
|
| |
assert data['data'][0]['data']['scenario'][0] == 'scenario2'
|
| |
|
| |
+ @pytest.mark.skipif(not os.getenv('POSTGRES_5432_TCP'),
|
| |
+ reason="Requires PostgreSQL, because DISTINCT ON works differently in SQLite")
|
| |
def test_get_results_latest_distinct_on_more_specific_cases_1(self):
|
| |
- """This test requires PostgreSQL, because DISTINCT ON does work differently in SQLite"""
|
| |
- if os.getenv('NO_CAN_HAS_POSTGRES', None):
|
| |
- return
|
| |
- if resultsdb.app.config['SQLALCHEMY_DATABASE_URI'].startswith('sqlite'):
|
| |
- raise Exception("This test requires PostgreSQL to work properly. You can disable it by setting NO_CAN_HAS_POSTGRES env variable to any non-empty value")
|
| |
+ """This test requires PostgreSQL, because DISTINCT ON does work differently in SQLite
|
| |
|
| |
- '''
|
| |
| id | testcase | scenario |
|
| |
|----|----------|----------|
|
| |
| 1 | tc_1 | s_1 |
|
| |
| 2 | tc_2 | s_1 |
|
| |
| 3 | tc_2 | s_2 |
|
| |
| 4 | tc_3 | |
|
| |
- '''
|
| |
+ """
|
| |
self.helper_create_result(outcome="PASSED", testcase='tc_1', data={'item': 'grub', 'scenario': 's_1'})
|
| |
self.helper_create_result(outcome="PASSED", testcase='tc_2', data={'item': 'grub', 'scenario': 's_1'})
|
| |
self.helper_create_result(outcome="PASSED", testcase='tc_2', data={'item': 'grub', 'scenario': 's_2'})
|
| |
@@ -911,14 +906,11 @@
|
| |
|
| |
assert len(data['data']) == 4
|
| |
|
| |
+ @pytest.mark.skipif(not os.getenv('POSTGRES_5432_TCP'),
|
| |
+ reason="Requires PostgreSQL, because DISTINCT ON works differently in SQLite")
|
| |
def test_get_results_latest_distinct_on_more_specific_cases_2(self):
|
| |
- """This test requires PostgreSQL, because DISTINCT ON does work differently in SQLite"""
|
| |
- if os.getenv('NO_CAN_HAS_POSTGRES', None):
|
| |
- return
|
| |
- if resultsdb.app.config['SQLALCHEMY_DATABASE_URI'].startswith('sqlite'):
|
| |
- raise Exception("This test requires PostgreSQL to work properly. You can disable it by setting NO_CAN_HAS_POSTGRES env variable to any non-empty value")
|
| |
+ """This test requires PostgreSQL, because DISTINCT ON does work differently in SQLite
|
| |
|
| |
- '''
|
| |
| id | testcase | scenario |
|
| |
|----|----------|----------|
|
| |
| 1 | tc_1 | s_1 |
|
| |
@@ -926,7 +918,7 @@
|
| |
| 3 | tc_2 | s_2 |
|
| |
| 4 | tc_3 | |
|
| |
| 5 | tc_1 | |
|
| |
- '''
|
| |
+ """
|
| |
self.helper_create_result(outcome="PASSED", testcase='tc_1', data={'item': 'grub', 'scenario': 's_1'})
|
| |
self.helper_create_result(outcome="PASSED", testcase='tc_2', data={'item': 'grub', 'scenario': 's_1'})
|
| |
self.helper_create_result(outcome="PASSED", testcase='tc_2', data={'item': 'grub', 'scenario': 's_2'})
|
| |
@@ -938,14 +930,11 @@
|
| |
|
| |
assert len(data['data']) == 5
|
| |
|
| |
+ @pytest.mark.skipif(not os.getenv('POSTGRES_5432_TCP'),
|
| |
+ reason="Requires PostgreSQL, because DISTINCT ON works differently in SQLite")
|
| |
def test_get_results_latest_distinct_on_more_specific_cases_2(self):
|
| |
- """This test requires PostgreSQL, because DISTINCT ON does work differently in SQLite"""
|
| |
- if os.getenv('NO_CAN_HAS_POSTGRES', None):
|
| |
- return
|
| |
- if resultsdb.app.config['SQLALCHEMY_DATABASE_URI'].startswith('sqlite'):
|
| |
- raise Exception("This test requires PostgreSQL to work properly. You can disable it by setting NO_CAN_HAS_POSTGRES env variable to any non-empty value")
|
| |
+ """This test requires PostgreSQL, because DISTINCT ON does work differently in SQLite
|
| |
|
| |
- '''
|
| |
| id | testcase | scenario |
|
| |
|----|----------|----------|
|
| |
| 1 | tc_1 | s_1 |
|
| |
@@ -954,7 +943,7 @@
|
| |
| 4 | tc_3 | |
|
| |
| 5 | tc_1 | |
|
| |
| 6 | tc_1 | s_1 |
|
| |
- '''
|
| |
+ """
|
| |
self.helper_create_result(outcome="PASSED", testcase='tc_1', data={'item': 'grub', 'scenario': 's_1'})
|
| |
self.helper_create_result(outcome="PASSED", testcase='tc_2', data={'item': 'grub', 'scenario': 's_1'})
|
| |
self.helper_create_result(outcome="PASSED", testcase='tc_2', data={'item': 'grub', 'scenario': 's_2'})
|
| |
@@ -971,13 +960,10 @@
|
| |
assert tc_1s[0]['outcome'] == 'INFO'
|
| |
assert tc_1s[1]['outcome'] == 'FAILED'
|
| |
|
| |
+ @pytest.mark.skipif(not os.getenv('POSTGRES_5432_TCP'),
|
| |
+ reason="Requires PostgreSQL, because DISTINCT ON works differently in SQLite")
|
| |
def test_get_results_latest_distinct_on_with_scenario_not_defined(self):
|
| |
"""This test requires PostgreSQL, because DISTINCT ON does work differently in SQLite"""
|
| |
- if os.getenv('NO_CAN_HAS_POSTGRES', None):
|
| |
- return
|
| |
- if resultsdb.app.config['SQLALCHEMY_DATABASE_URI'].startswith('sqlite'):
|
| |
- raise Exception("This test requires PostgreSQL to work properly. You can disable it by setting NO_CAN_HAS_POSTGRES env variable to any non-empty value")
|
| |
-
|
| |
self.helper_create_testcase()
|
| |
self.helper_create_result(outcome="PASSED", testcase=self.ref_testcase_name)
|
| |
self.helper_create_result(outcome="FAILED", testcase=self.ref_testcase_name)
|
| |
This will make tox-docker optional for running the tests. In case
tox-docker is not installed, tox ignores the docker configuration for
the test environment.
When the above happens the POSTGRES_5432_TCP environment variable will
be missing. This can be used as a condition for pytest.mark.skipif to
skip the tests which need PostgreSQL running.
The above should improve developer experience.
Signed-off-by: Hunor Csomortáni csomh@redhat.com