def create_fake_archive(requests_mock: RequestsMock) -> None: archive_path = Path(tempfile.mkdtemp()) / "archive.zip" with zipfile.ZipFile(archive_path, "w") as archive: archive.writestr("Lean-master/Data/equity/readme.md", "# This is just a test") archive.writestr( "Lean-master/Launcher/config.json", """ { // this configuration file works by first loading all top-level // configuration items and then will load the specified environment // on top, this provides a layering affect. environment names can be // anything, and just require definition in this file. There's // two predefined environments, 'backtesting' and 'live', feel free // to add more! "environment": "backtesting", // "live-paper", "backtesting", "live-interactive", "live-interactive-iqfeed" // data documentation "data-folder": "data" } """.strip()) with open(archive_path, "rb") as archive: requests_mock.assert_all_requests_are_fired = False requests_mock.add( requests_mock.GET, "https://github.com/QuantConnect/Lean/archive/master.zip", archive.read())
def test_is_authenticated_returns_false_when_authenticated_request_fails(requests_mock: RequestsMock) -> None: requests_mock.assert_all_requests_are_fired = False requests_mock.add(requests_mock.GET, re.compile(".*"), body='{ "success": false }') requests_mock.add(requests_mock.POST, re.compile(".*"), body='{ "success": false }') api = APIClient(mock.Mock(), "123", "456") assert not api.is_authenticated()