-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
96 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<testsuites name="Tests" time="15.943" tests="1" failures="0"> | ||
<testsuite name="Root Suite" timestamp="2020-10-05T20:41:16" tests="0" file="root-suite.spec.js" failures="0" time="0"> | ||
</testsuite> | ||
<testsuite name="Visual Testing" timestamp="2020-10-05T20:41:16" tests="1" failures="0" time="15.943"> | ||
<testcase name="Test navigation" time="15.943" classname="navigation"> | ||
</testcase> | ||
</testsuite> | ||
</testsuites> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,63 @@ | ||
import time | ||
import uuid | ||
from datetime import datetime | ||
from unittest.mock import MagicMock | ||
from unittest.mock import patch | ||
|
||
import pytest | ||
from ibutsu_server.test import BaseTestCase | ||
|
||
MOCK_RUN_ID = str(uuid.uuid4()) | ||
MOCK_RUN = {"id": MOCK_RUN_ID} | ||
MOCK_RUN = MagicMock(**{"id": MOCK_RUN_ID, "data": {}}) | ||
MOCK_PROJECT = str(uuid.uuid4()) | ||
MOCK_TIME = time.time() | ||
MOCK_RESULTS = [ | ||
{ | ||
"result": "passed", | ||
MagicMock( | ||
**{ | ||
"result": "passed", | ||
"duration": 1.532734345, | ||
"data": {"component": "login", "env": "qa", "project": MOCK_PROJECT}, | ||
"starttime": MOCK_TIME, | ||
} | ||
) | ||
] | ||
UPDATED_RUN = MagicMock( | ||
**{ | ||
"id": MOCK_RUN_ID, | ||
"duration": 1.532734345, | ||
"metadata": {"component": "login", "env": "qa", "project": MOCK_PROJECT}, | ||
"starttime": MOCK_TIME, | ||
"summary": { | ||
"errors": 0, | ||
"failures": 0, | ||
"skips": 0, | ||
"xfailures": 0, | ||
"xpasses": 0, | ||
"tests": 1, | ||
}, | ||
"data": {"component": "login", "env": "qa", "project": MOCK_PROJECT}, | ||
"start_time": MOCK_TIME, | ||
"created": datetime.fromtimestamp(MOCK_TIME).isoformat(), | ||
} | ||
] | ||
UPDATED_RUN = { | ||
"id": MOCK_RUN_ID, | ||
"duration": 1.532734345, | ||
"summary": {"errors": 0, "failures": 0, "skips": 0, "xfailures": 0, "xpasses": 0, "tests": 1}, | ||
"metadata": {"component": "login", "env": "qa", "project": MOCK_PROJECT}, | ||
"start_time": MOCK_TIME, | ||
"created": datetime.fromtimestamp(MOCK_TIME).isoformat(), | ||
} | ||
) | ||
|
||
|
||
@pytest.mark.skip("Currently breaking collection") | ||
class TestRunTasks(BaseTestCase): | ||
def test_update_run(self, mocker): | ||
@patch("ibutsu_server.tasks.runs.Result") | ||
@patch("ibutsu_server.tasks.runs.Run") | ||
@patch("ibutsu_server.tasks.runs.session") | ||
@patch("ibutsu_server.tasks.runs.lock") | ||
def test_update_run(self, mocked_lock, mocked_session, mocked_run, mocked_result): | ||
"""Test updating the run""" | ||
from ibutsu_server.tasks.runs import update_run | ||
|
||
mocker.patch("ibutsu_server.tasks.runs.lock") | ||
mocked_session = mocker.patch("ibutsu_server.tasks.runs.session") | ||
mocked_run = mocker.patch("ibutsu_server.tasks.runs.Run") | ||
mocked_lock.return_value.__enter__.return_value = None | ||
mocked_run.query.get.return_value = MOCK_RUN | ||
mocked_result = mocker.patch("ibutsu_server.tasks.runs.Result") | ||
mocked_result.query.return_value.filter.return_value.all.return_value = MOCK_RESULTS | ||
|
||
update_run = update_run._orig_func | ||
update_run(MOCK_RUN_ID) | ||
|
||
mocked_lock.assert_called_once() | ||
mocked_run.query.get.assert_called_once_with(MOCK_RUN_ID) | ||
mocked_result.query.return_value.filter.assert_called_once() | ||
mocked_result.query.return_value.filter.return_value.all.assert_called_once() | ||
mocked_result.query.filter.assert_called_once() | ||
mocked_result.query.filter.return_value.order_by.return_value.all.assert_called_once() | ||
mocked_session.add.assert_called_once() | ||
mocked_session.commit.assert_called_once() |