def test_distribution_exists(self):
        # Build a recipe.
        meta = self.write_meta('test_recipe_1', """
                    package:
                        name: test_recipe_1
                        version: 'determined_at_build_time'
                    build:
                        script: echo "v0.1.0.dev1" > __conda_version__.txt
                    """)
        meta = build(meta)

        # Check distribution exists returns false when there is no distribution.
        self.assertFalse(distribution_exists(CLIENT, OWNER, meta))

        # upload the distribution 
        upload(CLIENT, meta, OWNER, channels=['testing'])

        # Check the distribution exists. Notice there is no channel being supplied here.
        self.assertTrue(distribution_exists(CLIENT, OWNER, meta))

        # Check the distribution is on testing but not on main.
        self.assertTrue(distribution_exists_on_channel(CLIENT, OWNER, meta, channel='testing'))
        self.assertFalse(distribution_exists_on_channel(CLIENT, OWNER, meta, channel='main'))

        add_distribution_to_channel(CLIENT, OWNER, meta, channel='main')
        # Check that the distribution has been added.
        self.assertTrue(distribution_exists_on_channel(CLIENT, OWNER, meta, channel='main'))
    def test_distribution_exists(self):
        # Build a recipe.
        meta = self.write_meta(
            'test_recipe_1', """
                    package:
                        name: test_recipe_1
                        version: 'determined_at_build_time'
                    build:
                        script: echo "v0.1.0.dev1" > __conda_version__.txt
                    """)
        meta = build(meta)
        if hasattr(conda_build, 'api'):
            build_config = conda_build.api.Config()
        else:
            build_config = conda_build.config.config

        # Check distribution exists returns false when there is no distribution.
        self.assertFalse(distribution_exists(CLIENT, OWNER, meta))

        # upload the distribution
        upload(CLIENT, meta, OWNER, channels=['testing'], config=build_config)

        # Check the distribution exists. Notice there is no channel being supplied here.
        self.assertTrue(distribution_exists(CLIENT, OWNER, meta))

        # Check the distribution is on testing but not on main.
        self.assertTrue(
            distribution_exists_on_channel(CLIENT,
                                           OWNER,
                                           meta,
                                           channel='testing'))
        self.assertFalse(
            distribution_exists_on_channel(CLIENT, OWNER, meta,
                                           channel='main'))

        add_distribution_to_channel(CLIENT, OWNER, meta, channel='main')
        # Check that the distribution has been added.
        self.assertTrue(
            distribution_exists_on_channel(CLIENT, OWNER, meta,
                                           channel='main'))

        # Add the meta for a recipe known to exist on conda-forge
        meta2 = self.write_meta(
            'conda_build_all', """
                                package:
                                    name: conda-build-all
                                    version: 0.12.0
                                """)
        copy_distribution_to_owner(CLIENT,
                                   'conda-forge',
                                   OWNER,
                                   meta2,
                                   channel='main')
        self.assertTrue(distribution_exists_on_channel(CLIENT, OWNER, meta2))
    def test(self):
        # Build a recipe.
        py2 = self.write_meta('py1', """
                    package:
                        name: python
                        version: 1.2.3
                    """)
        py2 = self.write_meta('py2', """
                    package:
                        name: python
                        version: 2.1.10
                    """)
        a = self.write_meta('a', """
                    package:
                        name: a
                        version: 3.1.4
                    requirements:
                        build:
                            - python
                        run:
                            - python
                    """)

        a_py12 = ResolvedDistribution(a, (('python', '12', ), ))
        a_py21 = ResolvedDistribution(a, (('python', '21', ), ))
        a_py99 = ResolvedDistribution(a, (('python', '99', ), ))

        testing_channel = '{}/channel/{}'.format(OWNER, 'testing')
        self.call([self.recipes_root_dir, '--upload-channel', testing_channel])

        # Check that we have started on the right footing - the distribution should be on testing,
        # but not on main.
        self.assertTrue(distribution_exists_on_channel(CLIENT, OWNER, py2, channel='testing'))
        self.assertFalse(distribution_exists_on_channel(CLIENT, OWNER, py2, channel='main'))

        # Check that we've had a py21 and py12, but not a py99 for a.
        self.assertTrue(distribution_exists_on_channel(CLIENT, OWNER, a_py12, channel='testing'))
        self.assertTrue(distribution_exists_on_channel(CLIENT, OWNER, a_py21, channel='testing'))
        self.assertFalse(distribution_exists_on_channel(CLIENT, OWNER, a_py99, channel='testing'))

        # Remove the built distribution, re-run, and assert that we didn't bother re-building.
        dist_path = os.path.join(self.conda_bld_root, conda.config.subdir, a_py21.pkg_fn())
        self.assertTrue(os.path.exists(dist_path))
        os.remove(dist_path)
        self.call([self.recipes_root_dir, '--inspect-channel', testing_channel, '--upload-channel', testing_channel])
        self.assertFalse(os.path.exists(dist_path))

        # Now put a condition in. In this case, only build dists for py<2
        CLIENT.remove_dist(OWNER, a_py21.name(), a_py21.version(), '{}/{}'.format(conda.config.subdir, a_py21.pkg_fn()))
        self.assertFalse(distribution_exists_on_channel(CLIENT, OWNER, a_py21, channel='testing'))
        self.call([self.recipes_root_dir, '--inspect-channel', testing_channel, '--upload-channel', testing_channel,
                   '--matrix-condition', 'python <2'])
        self.assertFalse(distribution_exists_on_channel(CLIENT, OWNER, a_py21, channel='testing'))
        self.assertFalse(os.path.exists(dist_path))

        # Without the condition, we should be re-building the distribution
        self.call([self.recipes_root_dir, '--inspect-channel', testing_channel, '--upload-channel', testing_channel])
        self.assertTrue(os.path.exists(dist_path))
        self.assertTrue(distribution_exists_on_channel(CLIENT, OWNER, a_py21, channel='testing'))
    def test_distribution_exists(self):
        # Build a recipe.
        meta = self.write_meta('test_recipe_1', """
                    package:
                        name: test_recipe_1
                        version: 'determined_at_build_time'
                    build:
                        script: echo "v0.1.0.dev1" > __conda_version__.txt
                    """)
        meta = build(meta)
        if hasattr(conda_build, 'api'):
            build_config = conda_build.api.Config()
        else:
            build_config = conda_build.config.config

        # Check distribution exists returns false when there is no distribution.
        self.assertFalse(distribution_exists(CLIENT, OWNER, meta))

        # upload the distribution 
        upload(CLIENT, meta, OWNER, channels=['testing'], config=build_config)

        # Check the distribution exists. Notice there is no channel being supplied here.
        self.assertTrue(distribution_exists(CLIENT, OWNER, meta))

        # Check the distribution is on testing but not on main.
        self.assertTrue(distribution_exists_on_channel(CLIENT, OWNER, meta, channel='testing'))
        self.assertFalse(distribution_exists_on_channel(CLIENT, OWNER, meta, channel='main'))

        add_distribution_to_channel(CLIENT, OWNER, meta, channel='main')
        # Check that the distribution has been added.
        self.assertTrue(distribution_exists_on_channel(CLIENT, OWNER, meta, channel='main'))

        # Add the meta for a recipe known to exist on conda-forge
        meta2 = self.write_meta('conda_build_all', """
                                package:
                                    name: conda-build-all
                                    version: 0.12.0
                                """)
        copy_distribution_to_owner(CLIENT, 'conda-forge', OWNER, meta2, channel='main')
        self.assertTrue(distribution_exists_on_channel(CLIENT, OWNER, meta2))
    def test_distribution_exists(self):
        # Build a recipe.
        meta = self.write_meta(
            'test_recipe_1', """
                    package:
                        name: test_recipe_1
                        version: 'determined_at_build_time'
                    build:
                        script: echo "v0.1.0.dev1" > __conda_version__.txt
                    """)
        meta = build(meta)

        # Check distribution exists returns false when there is no distribution.
        self.assertFalse(distribution_exists(CLIENT, OWNER, meta))

        # upload the distribution
        upload(CLIENT, meta, OWNER, channels=['testing'])

        # Check the distribution exists. Notice there is no channel being supplied here.
        self.assertTrue(distribution_exists(CLIENT, OWNER, meta))

        # Check the distribution is on testing but not on main.
        self.assertTrue(
            distribution_exists_on_channel(CLIENT,
                                           OWNER,
                                           meta,
                                           channel='testing'))
        self.assertFalse(
            distribution_exists_on_channel(CLIENT, OWNER, meta,
                                           channel='main'))

        add_distribution_to_channel(CLIENT, OWNER, meta, channel='main')
        # Check that the distribution has been added.
        self.assertTrue(
            distribution_exists_on_channel(CLIENT, OWNER, meta,
                                           channel='main'))
Example #6
0
    def test(self):
        # Build a recipe.
        py2 = self.write_meta(
            'py1', """
                    package:
                        name: python
                        version: 1.2.3
                    """)
        py2 = self.write_meta(
            'py2', """
                    package:
                        name: python
                        version: 2.1.10
                    """)
        a = self.write_meta(
            'a', """
                    package:
                        name: a
                        version: 3.1.4
                    requirements:
                        build:
                            - python
                        run:
                            - python
                    """)

        a_py12 = ResolvedDistribution(a, ((
            'python',
            '12',
        ), ))
        a_py21 = ResolvedDistribution(a, ((
            'python',
            '21',
        ), ))
        a_py99 = ResolvedDistribution(a, ((
            'python',
            '99',
        ), ))

        testing_channel = '{}/channel/{}'.format(OWNER, 'testing')
        self.call([self.recipes_root_dir, '--upload-channel', testing_channel])

        # Check that we have started on the right footing - the distribution should be on testing,
        # but not on main.
        self.assertTrue(
            distribution_exists_on_channel(CLIENT,
                                           OWNER,
                                           py2,
                                           channel='testing'))
        self.assertFalse(
            distribution_exists_on_channel(CLIENT, OWNER, py2, channel='main'))

        # Check that we've had a py21 and py12, but not a py99 for a.
        self.assertTrue(
            distribution_exists_on_channel(CLIENT,
                                           OWNER,
                                           a_py12,
                                           channel='testing'))
        self.assertTrue(
            distribution_exists_on_channel(CLIENT,
                                           OWNER,
                                           a_py21,
                                           channel='testing'))
        self.assertFalse(
            distribution_exists_on_channel(CLIENT,
                                           OWNER,
                                           a_py99,
                                           channel='testing'))

        # Remove the built distribution, re-run, and assert that we didn't bother re-building.
        dist_path = os.path.join(self.conda_bld_root, conda.config.subdir,
                                 a_py21.pkg_fn())
        self.assertTrue(os.path.exists(dist_path))
        os.remove(dist_path)
        self.call([
            self.recipes_root_dir, '--inspect-channel', testing_channel,
            '--upload-channel', testing_channel
        ])
        self.assertFalse(os.path.exists(dist_path))

        # Now put a condition in. In this case, only build dists for py<2
        CLIENT.remove_dist(
            OWNER, a_py21.name(), a_py21.version(),
            '{}/{}'.format(conda.config.subdir, a_py21.pkg_fn()))
        self.assertFalse(
            distribution_exists_on_channel(CLIENT,
                                           OWNER,
                                           a_py21,
                                           channel='testing'))
        self.call([
            self.recipes_root_dir, '--inspect-channel', testing_channel,
            '--upload-channel', testing_channel, '--matrix-condition',
            'python <2'
        ])
        self.assertFalse(
            distribution_exists_on_channel(CLIENT,
                                           OWNER,
                                           a_py21,
                                           channel='testing'))
        self.assertFalse(os.path.exists(dist_path))

        # Without the condition, we should be re-building the distribution
        self.call([
            self.recipes_root_dir, '--inspect-channel', testing_channel,
            '--upload-channel', testing_channel
        ])
        self.assertTrue(os.path.exists(dist_path))
        self.assertTrue(
            distribution_exists_on_channel(CLIENT,
                                           OWNER,
                                           a_py21,
                                           channel='testing'))