def test_noarch_python(self):
     a = DummyPackage('pkgA', ['python'])
     a.noarch = 'python'
     self.index.add_pkg('python', '2.7.2')
     self.index.add_pkg('python', '3.5.0')
     r = special_case_version_matrix(a, self.index)
     self.assertEqual(r, set(((), )))
Exemple #2
0
    def test_numpy_xx_only(self):
        # Only a numpy x.x spec.

        # Build an index that contains numpy 1.9 and 1.10 on python 2.7 and
        # 3.5 for a total of 4 numpy/python combinations.
        pythons = ['2.7', '3.5']
        # Only major/minor in the numpy list here because that is what is used
        # for the build matrix.
        numpys = ['1.9', '1.10']
        self.construct_numpy_index(pythons, numpys)

        # Case 1: Only a numpy x.x spec...

        numpy_dep_case = ('numpy x.x', 'python')

        # ...expect all four cases to be in the matrix.
        expect_result = []
        for python in pythons:
            for numpy in numpys:
                expect_result.append((('python', python), ('numpy', numpy)))

        a = DummyPackage('pkgA', numpy_dep_case, numpy_dep_case)

        r = special_case_version_matrix(a, self.index)
        self.assertEqual(set(r),
                         set(expect_result),
                         msg='got: {}\nexpected: {}'.format(r, expect_result))
 def test_no_case(self):
     # No cases should still give us a result with a single case in it.
     a = DummyPackage('pkgA', ['wibble'])
     self.index.add_pkg('python', '2.7.2')
     self.index.add_pkg('wibble', '3.5.0')
     r = special_case_version_matrix(a, self.index)
     self.assertEqual(r, set([()]))
    def test_numpy_xx_and_restrictive_specifcation(self):
        # Case 3:
        #   A numpy x.x spec and a numpy version restriction which does
        #   eliminate one the numpy versions in the DummyIndex.

        # Build an index that contains numpy 1.9 and 1.10 on python 2.7 and
        # 3.5 for a total of 4 numpy/python combinations.
        pythons = ['2.7', '3.5']
        # Only major/minor in the numpy list here because that is what is used
        # for the build matrix.
        numpys = ['1.9', '1.10']
        self.construct_numpy_index(pythons, numpys)

        # A numpy x.x spec and a numpy version restriction which does
        # eliminate one the numpy versions in the DummyIndex.
        numpy_dep_case = ('numpy x.x', 'numpy >=1.10', 'python')

        # Expect only the numpy 1.9 case to survive.
        expect_result = []
        for python in pythons:
            for numpy in numpys[1:]:
                expect_result.append((('python', python), ('numpy', numpy)))

        a = DummyPackage('pkgA', numpy_dep_case, numpy_dep_case)

        r = special_case_version_matrix(a, self.index)
        self.assertEqual(set(r),
                         set(expect_result),
                         msg='got: {}\nexpected: {}'.format(r, expect_result))
Exemple #5
0
 def test_numpy_simplest_case(self):
     a = DummyPackage('pkgA', ['python', 'numpy'])
     self.index.add_pkg('numpy', '1.8.0', 'py27', depends=['python'])
     self.index.add_pkg('python', '2.7.2')
     r = special_case_version_matrix(a, self.index)
     self.assertEqual(r, set([(('python', '2.7'), ('numpy', '1.8')),
                             ])
                      )
Exemple #6
0
 def test_r_matrix(self):
     a = DummyPackage('pkgA', ['r-base'])
     self.index.add_pkg('r-base', '4.5.6')
     self.index.add_pkg('r-base', '4.5.7')
     r = special_case_version_matrix(a, self.index)
     self.assertEqual(r, set(((('r-base', '4.5.6'),),
                              (('r-base', '4.5.7'),),
                             ))
                      )
Exemple #7
0
 def test_constrained_python(self):
     a = DummyPackage('pkgA', ['python <3'])
     self.index.add_pkg('python', '2.7.2')
     self.index.add_pkg('python', '3.5.0')
     r = special_case_version_matrix(a, self.index)
     self.assertEqual(r, set(((('python', '2.7'),
                               ),
                             ))
                      )
 def test_dependency_on_py27(self):
     # If a dependency can't hit the python version, it should not
     # be considered a case.
     a = DummyPackage('pkgA', ['python', 'oldschool'])
     self.index.add_pkg('oldschool', '1.8.0', 'py27', depends=['python <3'])
     self.index.add_pkg('python', '2.7.2')
     self.index.add_pkg('python', '3.5.0')
     r = special_case_version_matrix(a, self.index)
     # TODO: Enable this test.
     return
Exemple #9
0
 def test_numpy_repeated_python27(self):
     # Repeating python 2.7 will result in the latest version being found
     a = DummyPackage('pkgA', ['python', 'numpy'])
     self.index.add_pkg('numpy', '1.8.0', 'py27', depends=['python <3'])
     self.index.add_pkg('python', '2.7.2')
     self.index.add_pkg('python', '2.7.0')
     r = special_case_version_matrix(a, self.index)
     self.assertEqual(r, set([(('python', '2.7'), ('numpy', '1.8')),
                             ])
                      )
Exemple #10
0
 def test_numpy_without_python(self):
     # Conda recipes which do not depend on python, but do on python, do
     # not have the full conda metadata, but still need to be handled.
     a = DummyPackage('pkgA', ['numpy'])
     self.index.add_pkg('numpy', '1.8.0', 'py27', depends=['python'])
     self.index.add_pkg('python', '2.7.2')
     r = special_case_version_matrix(a, self.index)
     self.assertEqual(r, set([(('python', '2.7'), ('numpy', '1.8')),
                             ])
                      )
Exemple #11
0
 def test_already_available_elsewhere(self):
     client, owner, channel = [
         mock.sentinel.client, mock.sentinel.owner, mock.sentinel.channel
     ]
     ad = AnacondaClientChannelDest(mock.sentinel.token, owner, channel)
     ad._cli = client
     meta = DummyPackage('a', '2.1.0')
     for url in ['http://foo.bar/', 'https://foo.bar/wibble']:
         with self.dist_exists_setup(on_owner=False, on_channel=False):
             with self.assertRaises(NotImplementedError):
                 ad.make_available(meta, url, just_built=False)
Exemple #12
0
 def test_dependency_on_py27(self):
     # If a dependency can't hit the python version, it should not
     # be considered a case.
     a = DummyPackage('pkgA', ['python', 'oldschool'])
     self.index.add_pkg('oldschool', '1.8.0', 'py27', depends=['python <3'])
     self.index.add_pkg('python', '2.7.2')
     self.index.add_pkg('python', '3.5.0')
     r = special_case_version_matrix(a, self.index)
     # No python 3 should be here.
     self.assertEqual(r, set([
         (('python', '2.7'), ),
     ]))
 def test_already_available_just_built(self):
     client, owner, channel = [
         mock.sentinel.client, mock.sentinel.owner, mock.sentinel.channel
     ]
     ad = AnacondaClientChannelDest(mock.sentinel.token, owner, channel)
     ad._cli = client
     meta = DummyPackage('a', '2.1.0')
     with self.dist_exists_setup(on_owner=True, on_channel=True):
         ad.make_available(meta, mock.sentinel.dist_path, just_built=True)
     # Nothing happens, we just get a message.
     self.logger.warn.assert_called_once_with(
         "Assuming the distribution we've just built and the one on sentinel.owner/sentinel.channel are the same."
     )
Exemple #14
0
 def test_numpy_repeated_python(self):
     a = DummyPackage('pkgA', ['python', 'numpy'])
     self.index.add_pkg('numpy', '1.8.0', 'py27', depends=['python <3'])
     self.index.add_pkg('numpy', '1.8.0', 'py35', depends=['python'])
     self.index.add_pkg('numpy', '1.9.0', 'py35', depends=['python >=3'])
     self.index.add_pkg('python', '2.7.2')
     self.index.add_pkg('python', '3.5.0')
     r = special_case_version_matrix(a, self.index)
     self.assertEqual(r, set(((('python', '2.7'), ('numpy', '1.8')),
                              (('python', '3.5'), ('numpy', '1.8')),
                              (('python', '3.5'), ('numpy', '1.9')),
                             ))
                      )
Exemple #15
0
    def test_perl_and_python_matrix(self):
        a = DummyPackage('pkgA', ['perl', 'python'])
        self.index.add_pkg('perl', '4.5.6')
        self.index.add_pkg('perl', '4.5.7')
        self.index.add_pkg('python', '2.7')
        self.index.add_pkg('python', '3.5')

        r = special_case_version_matrix(a, self.index)
        expected = set(((('python', '3.5'), ('perl', '4.5.7')),
                        (('python', '2.7'), ('perl', '4.5.7')),
                        (('python', '2.7'), ('perl', '4.5.6')),
                        (('python', '3.5'), ('perl', '4.5.6'))))
        self.assertEqual(r, expected)
 def test_not_already_available_just_built(self):
     client, owner, channel = [
         mock.sentinel.client, mock.sentinel.owner, mock.sentinel.channel
     ]
     ad = AnacondaClientChannelDest(mock.sentinel.token, owner, channel)
     ad._cli = client
     meta = DummyPackage('a', '2.1.0')
     with self.dist_exists_setup(on_owner=False, on_channel=False):
         with mock.patch('conda_build_all.build.upload') as upload:
             ad.make_available(meta,
                               mock.sentinel.dist_path,
                               just_built=True)
     upload.assert_called_once_with(client, meta, owner, channels=[channel])
     self.logger.info.assert_called_once_with(
         'Uploading a to the sentinel.channel channel.')
    def test_already_available_not_just_built(self):
        # Note, we exercise the use of get_binstar here too.

        client, owner, channel = [
            mock.sentinel.client, mock.sentinel.owner, mock.sentinel.channel
        ]
        ad = AnacondaClientChannelDest(mock.sentinel.token, owner, channel)
        meta = DummyPackage('a', '2.1.0')
        with self.dist_exists_setup(on_owner=True, on_channel=True):
            with mock.patch('binstar_client.utils.get_binstar') as get_binstar:
                ad.make_available(meta,
                                  mock.sentinel.dist_path,
                                  just_built=False)
        get_binstar.assert_called_once_with(
            Namespace(site=None, token=mock.sentinel.token))
        # Nothing happens, we just get a message.
        self.logger.info.assert_called_once_with(
            'Nothing to be done for a - it is already on sentinel.owner/sentinel.channel.'
        )
 def test_not_already_available_not_just_built(self):
     client, owner, channel = [
         mock.sentinel.client, mock.sentinel.owner, mock.sentinel.channel
     ]
     ad = AnacondaClientChannelDest(mock.sentinel.token, owner, channel)
     ad._cli = client
     meta = DummyPackage('a', '2.1.0')
     with self.dist_exists_setup(on_owner=True, on_channel=False):
         with mock.patch(
                 'conda_build_all.inspect_binstar.add_distribution_to_channel'
         ) as add_to_channel:
             ad.make_available(meta,
                               mock.sentinel.dist_path,
                               just_built=False)
     add_to_channel.assert_called_once_with(client,
                                            owner,
                                            meta,
                                            channel=channel)
     self.logger.info.assert_called_once_with(
         'Adding existing a-0.0-0 to the sentinel.owner/sentinel.channel channel.'
     )
 def test_already_available_elsewhere(self):
     client, owner, channel = [
         mock.sentinel.client, mock.sentinel.owner, mock.sentinel.channel
     ]
     ad = AnacondaClientChannelDest(mock.sentinel.token, owner, channel)
     ad._cli = client
     meta = DummyPackage('a', '2.1.0')
     source_owner = 'fake_owner'
     # The osx-64 subdirectory at the end of the URL is not important to the test.
     for url in [
             'http://foo.bar/{}/osx-64/'.format(source_owner),
             'https://foo.bar/wibble/{}/osx-64/'.format(source_owner),
             'https://foo.bar/wibble/{}/osx-64'.format(source_owner)
     ]:
         with self.dist_exists_setup(on_owner=False, on_channel=False):
             with mock.patch(
                     'conda_build_all.inspect_binstar.copy_distribution_to_owner'
             ) as copy:
                 ad.make_available(meta, url, just_built=False)
         copy.assert_called_once_with(ad._cli,
                                      source_owner,
                                      owner,
                                      meta,
                                      channel=channel)
Exemple #20
0
 def test_python_itself(self):
     a = DummyPackage('python', version="a.b.c")
     r = special_case_version_matrix(a, self.index)
     self.assertEqual(r, set(((('python', 'a.b'),),
                             ))
                      )