<commit_before>import unittest
import sys

from conans.client.conan_api import ConanAPIV1
from conans.model.ref import ConanFileReference

from cpt import __version__ as version

from conans.client import tools
from cpt.test.integration.base import BaseTest, PYPI_TESTING_REPO, CONAN_UPLOAD_URL, \
    CONAN_UPLOAD_PASSWORD, CONAN_LOGIN_UPLOAD
from cpt.packager import ConanMultiPackager


class DockerTest(BaseTest):

    @unittest.skipUnless(sys.platform.startswith("linux"), "Requires Linux")
    def test_docker(self):
        self.deploy_pip()

        conanfile = """from conans import ConanFile
import os

class Pkg(ConanFile):
    settings = "os", "compiler", "build_type", "arch"

"""
        self.save_conanfile(conanfile)
        the_version = version.replace("-", ".")  # Canonical name for artifactory repo
        pip = "--extra-index-url %s/simple conan-package-tools==%s " % (PYPI_TESTING_REPO, the_version)
        with tools.environment_append({"CONAN_USE_DOCKER": "1",
                                       "CONAN_PIP_PACKAGE": pip,
                                       "CONAN_LOGIN_USERNAME": CONAN_LOGIN_UPLOAD,
                                       "CONAN_USERNAME": "lasote",
                                       "CONAN_UPLOAD": CONAN_UPLOAD_URL,
                                       "CONAN_PASSWORD": CONAN_UPLOAD_PASSWORD}):
            self.packager = ConanMultiPackager("--build missing -r conan.io",
                                               channel="mychannel",
                                               gcc_versions=["6"],
                                               archs=["x86", "x86_64"],
                                               build_types=["Release"],
                                               reference="zlib/1.2.2")
            self.packager.add_common_builds()
            self.packager.run()

        # Remove from remote
        self.assertEquals(len(self.api.search_recipes("zlib*", remote="upload_repo")), 1)
        packages = self.api.search_packages(ConanFileReference.loads("zlib/1.2.2@lasote/mychannel"),
                                                       remote="upload_repo")[0]
        self.assertEquals(len(packages), 2)

        self.api.authenticate(name=CONAN_LOGIN_UPLOAD, password=<PASSWORD>,
                         remote="upload_repo")
        self.api.remove("zlib*", remote="upload_repo", force=True)
        self.assertEquals(self.api.search_recipes("zlib*"), [])

        # Try upload only when stable, shouldn't upload anything
        with tools.environment_append({"CONAN_USE_DOCKER": "1",
                                       "CONAN_PIP_PACKAGE": pip,
                                       "CONAN_LOGIN_USERNAME": CONAN_LOGIN_UPLOAD,
                                       "CONAN_USERNAME": "lasote",
                                       "CONAN_UPLOAD": CONAN_UPLOAD_URL,
                                       "CONAN_PASSWORD": <PASSWORD>,
                                       "CONAN_UPLOAD_ONLY_WHEN_STABLE": "1"}):
            self.packager = ConanMultiPackager("--build missing -r conan.io",
                                               channel="mychannel",
                                               gcc_versions=["6"],
                                               archs=["x86", "x86_64"],
                                               build_types=["Release"],
                                               reference="zlib/1.2.2")
            self.packager.add_common_builds()
            self.packager.run()

        self.assertEquals(len(self.api.search_recipes("zlib*", remote="upload_repo")), 0)<commit_msg>Fixed unique refs<commit_after>import unittest
import sys

import time
from conans.client.conan_api import ConanAPIV1
from conans.model.ref import ConanFileReference

from cpt import __version__ as version

from conans.client import tools
from cpt.test.integration.base import BaseTest, PYPI_TESTING_REPO, CONAN_UPLOAD_URL, \
    CONAN_UPLOAD_PASSWORD, CONAN_LOGIN_UPLOAD
from cpt.packager import ConanMultiPackager


class DockerTest(BaseTest):

    @unittest.skipUnless(sys.platform.startswith("linux"), "Requires Linux")
    def test_docker(self):
        self.deploy_pip()
        unique_ref = "zlib/%s" % str(time.time())
        conanfile = """from conans import ConanFile
import os

class Pkg(ConanFile):
    settings = "os", "compiler", "build_type", "arch"

"""
        self.save_conanfile(conanfile)
        the_version = version.replace("-", ".")  # Canonical name for artifactory repo
        pip = "--extra-index-url %s/simple conan-package-tools==%s " % (PYPI_TESTING_REPO, the_version)
        with tools.environment_append({"CONAN_USE_DOCKER": "1",
                                       "CONAN_PIP_PACKAGE": pip,
                                       "CONAN_LOGIN_USERNAME": CONAN_LOGIN_UPLOAD,
                                       "CONAN_USERNAME": "lasote",
                                       "CONAN_UPLOAD": CONAN_UPLOAD_URL,
                                       "CONAN_PASSWORD": <PASSWORD>AN_UPLOAD_PASSWORD}):
            self.packager = ConanMultiPackager("--build missing -r conan.io",
                                               channel="mychannel",
                                               gcc_versions=["6"],
                                               archs=["x86", "x86_64"],
                                               build_types=["Release"],
                                               reference=unique_ref)
            self.packager.add_common_builds()
            self.packager.run()

        search_pattern = "%s*" % unique_ref
        ref = ConanFileReference.loads("%s@lasote/mychannel" % unique_ref)

        # Remove from remote
        self.assertEquals(len(self.api.search_recipes(search_pattern, remote="upload_repo")), 1)
        packages = self.api.search_packages(ref, remote="upload_repo")[0]
        self.assertEquals(len(packages), 2)

        self.api.authenticate(name=CONAN_LOGIN_UPLOAD, password=<PASSWORD>,
                         remote="upload_repo")
        self.api.remove(search_pattern, remote="upload_repo", force=True)
        self.assertEquals(self.api.search_recipes(search_pattern), [])

        # Try upload only when stable, shouldn't upload anything
        with tools.environment_append({"CONAN_USE_DOCKER": "1",
                                       "CONAN_PIP_PACKAGE": pip,
                                       "CONAN_LOGIN_USERNAME": CONAN_LOGIN_UPLOAD,
                                       "CONAN_USERNAME": "lasote",
                                       "CONAN_UPLOAD": CONAN_UPLOAD_URL,
                                       "CONAN_PASSWORD": <PASSWORD>,
                                       "CONAN_UPLOAD_ONLY_WHEN_STABLE": "1"}):
            self.packager = ConanMultiPackager("--build missing -r conan.io",
                                               channel="mychannel",
                                               gcc_versions=["6"],
                                               archs=["x86", "x86_64"],
                                               build_types=["Release"],
                                               reference=unique_ref)
            self.packager.add_common_builds()
            self.packager.run()

        self.assertEquals(len(self.api.search_recipes(search_pattern, remote="upload_repo")), 0)
        self.api.remove(search_pattern, remote="upload_repo", force=True)
{'fraction_non_alphanumeric': 0.10068373776645663, 'fraction_numerical': 0.007105510122000268, 'mean_word_length': 1.5786380919460767, 'pattern_counts': {'":': 26, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 64, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7570493', 'n_tokens_mistral': 2017, 'n_tokens_neox': 1991, 'n_words': 321}