Skip to content

Commit 8647f7b

Browse files
committed
[tl-tests] added tests for api
+ checkdevkey + gettestprojects
1 parent 4c17ae9 commit 8647f7b

5 files changed

Lines changed: 87 additions & 2 deletions

File tree

pytest.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ addopts =
1010
--benchmark-histogram=tests/reports/benchmarks/benchmark.svg
1111
testpaths = tests
1212
console_output_style = progress
13-
python_files = suite_*_*.py
13+
python_files = suite_*.py
1414
python_classes = Test*
15-
python_functions = test_*_*
15+
python_functions = test_*

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ def read(file_name=None, is_encoding=True, ignore_raises=False):
6868
],
6969
tests_require=[
7070
'pytest',
71+
'pytest-raises',
7172
'pytest-html',
7273
'pytest-dependency',
7374
'pytest-benchmark',

tests/api/__init__.py

Whitespace-only changes.

tests/api/suite_connection.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# -*- coding: utf-8 -*-
2+
"""TODO: doc module"""
3+
4+
5+
import pytest
6+
from testlinktests.core.utils import settings
7+
from qatestlink.core.exceptions.response_exception import ResponseException
8+
from qatestlink.core.testlink_manager import TLManager
9+
10+
11+
CONFIG = settings(
12+
file_path="testlinktests/configs/",
13+
file_name="settings.json"
14+
)
15+
16+
17+
class TestMethods(object):
18+
"""TODO: doc class"""
19+
20+
def setup_method(self, test_method, **kwargs):
21+
"""TODO: doc method"""
22+
23+
if 'skipIf' in dir(test_method) and test_method.skipIf.args[0]:
24+
pytest.skip(test_method.skipIf.args[1])
25+
return
26+
self.tlm = TLManager(settings=CONFIG)
27+
28+
def test_checkdevkey(self):
29+
"""TestCase: test_checkdevkey
30+
Login success with valid config
31+
"""
32+
is_logged = self.tlm.api_login()
33+
if not is_logged:
34+
raise AssertionError(
35+
"API_KEY it's invalid when must be valid")
36+
37+
@pytest.mark.raises(exception=ResponseException)
38+
def test_raises_checkdevkey(self):
39+
"""TestCase: test_raises_checkdevkey"""
40+
is_logged = self.tlm.api_login(dev_key='willfail')
41+
if is_logged:
42+
raise AssertionError(
43+
"API_KEY it's invalid when must be valid")

tests/api/suite_tprojects.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# -*- coding: utf-8 -*-
2+
"""TODO: doc module"""
3+
4+
5+
import pytest
6+
from testlinktests.core.utils import settings
7+
from qatestlink.core.exceptions.response_exception import ResponseException
8+
from qatestlink.core.testlink_manager import TLManager
9+
10+
11+
CONFIG = settings(
12+
file_path="testlinktests/configs/",
13+
file_name="settings.json"
14+
)
15+
16+
17+
class TestMethods(object):
18+
"""TODO: doc class"""
19+
20+
def setup_method(self, test_method, **kwargs):
21+
"""TODO: doc method"""
22+
if 'skipIf' in dir(test_method) and test_method.skipIf.args[0]:
23+
pytest.skip(test_method.skipIf.args[1])
24+
return
25+
self.tlm = TLManager(settings=CONFIG)
26+
27+
def test_get_tprojects_minimal_one(self):
28+
"""TestCase: test_get_tprojects_minimal_one
29+
At least must exist one TestProject
30+
"""
31+
tprojects = self.tlm.api_tprojects()
32+
if len(tprojects) < 1:
33+
raise AssertionError("Not empty Test Projects")
34+
35+
@pytest.mark.skipIf(True, "Issue oneped at qatestlink library, #52")
36+
@pytest.mark.raises(exception=ResponseException)
37+
def test_raises_tprojects_baddevkey(self):
38+
"""TestCase: test_raises_tprojects_baddevkey"""
39+
tprojects = self.tlm.api_tprojects(dev_key='willfail')
40+
if len(tprojects) >= 0:
41+
raise AssertionError("Not empty Test Projects")

0 commit comments

Comments
 (0)