diff --git a/tests/test_client.py b/tests/test_client.py index 42353df..9bb43fa 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -4,7 +4,7 @@ from unittest.mock import MagicMock from nose_launchable.case_event import CaseEvent -from nose_launchable.client import LaunchableClientFactory, LaunchableClient +from nose_launchable.client import LaunchableClientFactory, LaunchableClient, TestSessionContext from nose_launchable.version import __version__ @@ -55,13 +55,15 @@ def test_start(self): 'Authorization': 'Bearer token' } - mock_requests.post.assert_called_once_with(expected_url, headers=expected_headers) + mock_requests.post.assert_called_once_with( + expected_url, headers=expected_headers) mock_response.raise_for_status.assert_called_once_with() mock_response.json.assert_called_once_with() - self.assertEqual("test_build_number", client.build_number) + self.assertEqual("test_build_number", + client.build_number) self.assertEqual( - "builds/test_build_number/test_sessions/1", client.test_session_id) + "builds/test_build_number/test_sessions/1", client.test_session_context.get_build_path()) def test_subset_success_with_target(self): mock_output = MagicMock(name="output") @@ -77,12 +79,13 @@ def test_subset_success_with_target(self): client = LaunchableClient( "base_url", "org_name", "wp_name", "token", mock_requests, mock_subprocess) - client.test_session_id = "builds/test_subset_success_with_target/1" + client.test_session_context = TestSessionContext( + build_number="test_subset_success_with_target", test_session_id=1) got = client.subset(["tests/test1.py", "tests/test2.py"], None, "10") expected_command = ['launchable', 'subset', '--session', - 'builds/test_subset_success_with_target/1', '--target', '10%', 'file'] + 'builds/test_subset_success_with_target/test_sessions/1', '--target', '10%', 'file'] expected_input = 'tests/test1.py\ntests/test2.py' mock_subprocess.run.assert_called_once_with( @@ -103,7 +106,8 @@ def test_subset_success_with_options(self): client = LaunchableClient( "base_url", "org_name", "wp_name", "token", mock_requests, mock_subprocess) - client.test_session_id = "builds/test_subset_success_with_options/test_sessions/1" + client.test_session_context = TestSessionContext( + build_number="test_subset_success_with_options", test_session_id=1) got = client.subset( ["tests/test1.py", "tests/test2.py"], '--target 10%', None) @@ -128,8 +132,10 @@ def test_subset_failure(self): mock_requests = MagicMock(name="requests") - client = LaunchableClient("base_url", "org_name", "wp_name", "token", mock_requests, mock_subprocess) - client.test_session_id = 1 + client = LaunchableClient( + "base_url", "org_name", "wp_name", "token", mock_requests, mock_subprocess) + client.test_session_context = TestSessionContext( + build_number="test", test_session_id=1) with self.assertRaises(RuntimeError): client.subset(["tests/test1.py", "tests/test2.py"], None, "10") @@ -155,7 +161,8 @@ def test_upload_events(self): ] client.build_number = 1 - client.test_session_id = 2 + client.test_session_context = TestSessionContext( + build_number=1, test_session_id=2) client.upload_events(events) @@ -200,9 +207,10 @@ def test_finish(self): mock_requests = MagicMock(name="requests") mock_requests.patch.return_value = mock_response - client = LaunchableClient("base_url", "org_name", "wp_name", "token", mock_requests, MagicMock(name="subprecess")) - client.build_number = "test_build_number" - client.test_session_id = "1" + client = LaunchableClient("base_url", "org_name", "wp_name", + "token", mock_requests, MagicMock(name="subprecess")) + client.test_session_context = TestSessionContext( + build_number="test_build_number", test_session_id=1) client.finish()