-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #106 from launchableinc/go-test-test
Replace mock with responses
- Loading branch information
Showing
5 changed files
with
45 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
from pathlib import Path | ||
from unittest import mock | ||
|
||
import responses | ||
import json | ||
import gzip | ||
from tests.cli_test_case import CliTestCase | ||
|
||
|
||
class GradleTest(CliTestCase): | ||
test_files_dir = Path(__file__).parent.joinpath('../data/gradle/recursion').resolve() | ||
result_file_path = test_files_dir.joinpath('expected.json') | ||
|
||
@mock.patch('requests.request') | ||
def test_record_test_gradle(self, mock_post): | ||
@responses.activate | ||
def test_record_test_gradle(self): | ||
result = self.cli('record', 'tests', '--session', self.session, 'gradle', str(self.test_files_dir) + "/**/reports") | ||
self.assertEqual(result.exit_code, 0) | ||
|
||
payload = self.gzipped_json_payload(mock_post) | ||
expected = self.load_json_from_file(self.result_file_path) | ||
payload = json.loads(gzip.decompress( | ||
b''.join(responses.calls[0].request.body)).decode()) | ||
|
||
expected = self.load_json_from_file(self.result_file_path) | ||
self.assert_json_orderless_equal(expected, payload) |
13 changes: 8 additions & 5 deletions
13
tests/commands/test_record_tests_minitest.py → tests/test_runners/test_minitest.py
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,18 +1,21 @@ | ||
from pathlib import Path | ||
from unittest import mock | ||
|
||
import responses | ||
import json | ||
import gzip | ||
from tests.cli_test_case import CliTestCase | ||
|
||
|
||
class MinitestTest(CliTestCase): | ||
test_files_dir = Path(__file__).parent.joinpath('../data/minitest/').resolve() | ||
result_file_path = test_files_dir.joinpath('record_test_result.json') | ||
|
||
@mock.patch('requests.request') | ||
def test_record_test_minitest(self, mock_post): | ||
@responses.activate | ||
def test_record_test_minitest(self): | ||
result = self.cli('record', 'tests', '--session', self.session, 'minitest', str(self.test_files_dir) + "/") | ||
self.assertEqual(result.exit_code, 0) | ||
|
||
payload = self.gzipped_json_payload(mock_post) | ||
payload = json.loads(gzip.decompress( | ||
b''.join(responses.calls[0].request.body)).decode()) | ||
|
||
expected = self.load_json_from_file(self.result_file_path) | ||
self.assert_json_orderless_equal(expected, payload) |