Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean test fixmes #17599

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions conan/tools/files/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ def chdir(conanfile, newdir):
finally:
os.chdir(old_path)


def unzip(conanfile, filename, destination=".", keep_permissions=False, pattern=None,
strip_root=False, extract_filter=None):
"""
Expand Down Expand Up @@ -350,6 +351,7 @@ def unzip(conanfile, filename, destination=".", keep_permissions=False, pattern=
output.error(f"Error extract {file_.filename}\n{str(e)}", error_type="exception")
output.writeln("")


def untargz(filename, destination=".", pattern=None, strip_root=False, extract_filter=None):
# NOT EXPOSED at `conan.tools.files` but used in tests
import tarfile
Expand Down
8 changes: 4 additions & 4 deletions conans/client/rest/file_uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,19 @@ def _upload_file(self, url, abs_path, headers, auth, ref):


class FileProgress(io.FileIO):
def __init__(self, path: str, msg: str = "Uploading", report_interval: float = 1 , *args, **kwargs):
def __init__(self, path: str, msg: str = "Uploading", interval: float = 1, *args, **kwargs):
super().__init__(path, *args, **kwargs)
self._total_size = os.path.getsize(path)
self._size = os.path.getsize(path)
self._filename = os.path.basename(path)
# Report only on big sizes (>100MB)
self._reporter = TimedOutput(interval=report_interval) if self._total_size > 100_000_000 else None
self._reporter = TimedOutput(interval=interval) if self._size > 100_000_000 else None
self._bytes_read = 0
self.msg = msg

def read(self, size: int = -1) -> bytes:
block = super().read(size)
self._bytes_read += len(block)
if self._reporter:
current_percentage = int(self._bytes_read * 100.0 / self._total_size) if self._total_size != 0 else 0
current_percentage = int(self._bytes_read * 100.0 / self._size) if self._size != 0 else 0
self._reporter.info(f"{self.msg} {self._filename}: {current_percentage}%")
return block
5 changes: 2 additions & 3 deletions test/integration/command/download/test_download_patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

@pytest.mark.artifactory_ready
class TestDownloadPatterns:
# FIXME The fixture is copied from TestUploadPatterns, reuse it
@pytest.fixture(scope="class") # Takes 6 seconds, reuse it
# The fixture is very similar from TestUploadPatterns, but not worth extracting
@pytest.fixture(scope="class")
def client(self):
""" create a few packages, with several recipe revisions, several pids, several prevs
"""
Expand All @@ -32,7 +32,6 @@ def client(self):

@staticmethod
def assert_downloaded(pattern, result, client, only_recipe=False, query=None):
# FIXME: Also common to TestUploadPatterns
def ref_map(r):
rev1 = "ad55a66b62acb63ffa99ea9b75c16b99"
rev2 = "127fb537a658ad6a57153a038960dc53"
Expand Down
11 changes: 3 additions & 8 deletions test/integration/command/test_graph_build_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def test_install_build_single(build_all):
assert "foo/1.0@user/testing: Forced build from source" in build_all.out
assert "bar/1.0@user/testing: Forced build from source" not in build_all.out
assert "foobar/1.0@user/testing: Forced build from source" not in build_all.out
assert "No package matching" not in build_all.out


def test_install_build_double(build_all):
Expand All @@ -63,15 +62,13 @@ def test_install_build_double(build_all):
assert "foo/1.0@user/testing: Forced build from source" in build_all.out
assert "bar/1.0@user/testing: Forced build from source" in build_all.out
assert "foobar/1.0@user/testing: Forced build from source" not in build_all.out
assert "No package matching" not in build_all.out


@pytest.mark.parametrize("build_arg,mode", [
("--build=", "Cache"),
@pytest.mark.parametrize("build_arg,mode", [("--build=", "Cache"),
("--build=*", "Build")])
def test_install_build_only(build_arg, mode, build_all):
""" When only --build is passed, all packages must be built from sources
When only --build= is passed, it's considered an error
""" When only --build is passed wo args, that is a command arg error
When only --build= is passed, it's a no-op, same as not passing any value
When only --build=* is passed, all packages must be built from sources
"""
build_all.run("install --requires=foobar/1.0@user/testing {}".format(build_arg))
Expand All @@ -85,12 +82,10 @@ def test_install_build_only(build_arg, mode, build_all):
assert "foo/1.0@user/testing: Forced build from source" in build_all.out
assert "bar/1.0@user/testing: Forced build from source" in build_all.out
assert "foobar/1.0@user/testing: Forced build from source" in build_all.out
# FIXME assert "No package matching" not in build_all.out
else:
assert "foo/1.0@user/testing: Forced build from source" not in build_all.out
assert "bar/1.0@user/testing: Forced build from source" not in build_all.out
assert "foobar/1.0@user/testing: Forced build from source" not in build_all.out
# FIXME assert "No package matching" in build_all.out


@pytest.mark.parametrize("build_arg,bar,foo,foobar", [("--build=", "Cache", "Build", "Cache"),
Expand Down
120 changes: 0 additions & 120 deletions test/integration/command/upload/syncronize_test.py

This file was deleted.

1 change: 0 additions & 1 deletion test/integration/command_v2/search_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from conan.test.utils.tools import TestClient, TestServer


# FIXME: we could remove this whenever @conan_alias_command will be implemented
class TestSearch:

@pytest.fixture
Expand Down
27 changes: 8 additions & 19 deletions test/integration/graph/core/graph_manager_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,16 @@ def recipe_cache(self, reference, requires=None, option_shared=None):
conanfile.with_option("shared", [True, False])
conanfile.with_default_option("shared", option_shared)

self._put_in_cache(ref, conanfile)
self._cache_recipe(ref, conanfile)

def recipe_conanfile(self, reference, conanfile):
ref = RecipeReference.loads(reference)
self._put_in_cache(ref, conanfile)
self._cache_recipe(ref, conanfile)

def _put_in_cache(self, ref, conanfile):
ref = RecipeReference.loads("{}#123".format(ref))
ref.timestamp = revision_timestamp_now()
layout = self.cache.create_ref_layout(ref)
save(layout.conanfile(), str(conanfile))
manifest = FileTreeManifest.create(layout.export())
manifest.save(layout.export())

def _cache_recipe(self, ref, test_conanfile, revision=None):
# FIXME: This seems duplicated
def _cache_recipe(self, ref, test_conanfile):
if not isinstance(ref, RecipeReference):
ref = RecipeReference.loads(ref)
ref = RecipeReference.loads(repr(ref) + "#{}".format(revision or 123)) # FIXME: Make access
ref.revision = "123"
ref.timestamp = revision_timestamp_now()
recipe_layout = self.cache.create_ref_layout(ref)
save(recipe_layout.conanfile(), str(test_conanfile))
Expand All @@ -73,7 +64,7 @@ def alias_cache(self, alias, target):
class Alias(ConanFile):
alias = "%s"
""" % target)
self._put_in_cache(ref, conanfile)
self._cache_recipe(ref, conanfile)

@staticmethod
def recipe_consumer(reference=None, requires=None, build_requires=None, tool_requires=None):
Expand Down Expand Up @@ -102,16 +93,14 @@ def consumer_conanfile(conanfile):
save(path, str(conanfile))
return path

def build_graph(self, content, profile_build_requires=None, ref=None, create_ref=None,
install=True, options_build=None):
def build_graph(self, content, profile_build_requires=None, install=True, options_build=None):
path = temp_folder()
path = os.path.join(path, "conanfile.py")
save(path, str(content))
return self.build_consumer(path, profile_build_requires, ref, create_ref, install,
return self.build_consumer(path, profile_build_requires, install,
options_build=options_build)

def build_consumer(self, path, profile_build_requires=None, ref=None, create_ref=None,
install=True, options_build=None):
def build_consumer(self, path, profile_build_requires=None, install=True, options_build=None):
profile_host = Profile()
profile_host.settings["os"] = "Linux"
profile_build = Profile()
Expand Down
34 changes: 8 additions & 26 deletions test/integration/remote/rest_api_test.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
import os
import unittest

from mock import Mock

from conans.client.remote_manager import Remote
from conans.client.rest.auth_manager import ConanApiAuthManager
from conans.client.rest.conan_requester import ConanRequester
from conans.client.rest.rest_client import RestApiClient
from conan.api.model import Remote
from conan.internal.model.conf import ConfDefinition
from conan.test.utils.env import environment_update
from conan.api.input import UserInput
from conan.internal.model.manifest import FileTreeManifest
from conan.internal.model.package_ref import PkgReference
from conan.internal.model.recipe_ref import RecipeReference
from conan.internal.paths import CONANFILE, CONANINFO, CONAN_MANIFEST
from conan.test.assets.genconanfile import GenConanfile
from conan.test.utils.mocks import LocalDBMock
from conan.test.utils.env import environment_update
from conan.test.utils.server_launcher import TestServerLauncher
from conan.test.utils.test_files import temp_folder
from conan.test.utils.tools import get_free_port
from conans.client.rest.conan_requester import ConanRequester
from conans.client.rest.rest_client import RestApiClient
from conans.util.files import md5, save


Expand All @@ -39,25 +34,12 @@ def setUpClass(cls):
write_permissions=write_perms)
cls.server.start()

filename = os.path.join(temp_folder(), "conan.conf")
save(filename, "")
config = ConfDefinition()
requester = ConanRequester(config)
localdb = LocalDBMock()

mocked_user_input = UserInput(non_interactive=False)
mocked_user_input.get_username = Mock(return_value="private_user")
mocked_user_input.get_password = Mock(return_value="private_pass")

# FIXME: Missing mock
cls.auth_manager = ConanApiAuthManager(requester, temp_folder(), localdb, config)
cls.remote = Remote("myremote", "http://127.0.0.1:%s" % str(cls.server.port), True,
True)
cls.api = RestApiClient(cls.remote, localdb.access_token, requester, config)
cls.auth_manager._authenticate(cls.api, cls.remote, user="private_user",
password="private_pass")
# Need to define again with new token
cls.api = RestApiClient(cls.remote, localdb.access_token, requester, config)

remote = Remote("myremote", f"http://127.0.0.1:{cls.server.port}", True, True)
cls.api = RestApiClient(remote, None, requester, config)
cls.api._token = cls.api.authenticate(user="private_user", password="private_pass")

@classmethod
def tearDownClass(cls):
Expand Down
Loading
Loading