Esempio n. 1
0
 def test_get_all_packages(self):
     actor = packagecloud.PackagecloudBase('Unit test action', {})
     actor._packagecloud_client = mock.Mock()
     actor._packagecloud_client.packages().http_get = mock_tornado(
         ALL_PACKAGES_MOCK_RESPONSE)
     all_packages = yield actor._get_all_packages(repo='unittest')
     self.assertEquals(all_packages, ALL_PACKAGES_MOCK_RESPONSE)
Esempio n. 2
0
 def test_filter_packages(self):
     actor = packagecloud.PackagecloudBase('Unit test action', {})
     actor._packagecloud_client = mock.Mock()
     actor._packagecloud_client.packages().http_get = mock_tornado(
         ALL_PACKAGES_MOCK_RESPONSE)
     packages = yield actor._get_all_packages(repo='unittest')
     packages_list_to_delete = actor._filter_packages(regex='unittest',
                                                      packages=packages)
     self.assertEquals(packages_list_to_delete, set(['unittest']))
Esempio n. 3
0
    def test_delete_keep_one(self):
        actor = packagecloud.PackagecloudBase('Unit test action', {})
        actor._packagecloud_client = mock.Mock()
        actor._packagecloud_client.packages().http_get = mock_tornado(
            ALL_PACKAGES_MOCK_RESPONSE)
        actor._packagecloud_client.delete().http_delete = mock_tornado({})

        deleted_packages = yield actor._delete(regex='unittest',
                                               repo='unittest',
                                               number_to_keep=1)

        self.assertEquals(
            deleted_packages,
            [{
                'created_at': datetime.datetime(2014, 7, 7, 20, 27, 18),
                'name': 'unittest',
                'distro_version': 'ubuntu/trusty',
                'filename': 'unittest_0.1-1_all.deb'
            }])
Esempio n. 4
0
    def test_get_package_versions(self):
        actor = packagecloud.PackagecloudBase('Unit test action', {})
        actor._packagecloud_client = mock.Mock()
        actor._packagecloud_client.packages().http_get = mock_tornado(
            ALL_PACKAGES_MOCK_RESPONSE)
        packages = yield actor._get_all_packages(repo='unittest')
        versions = actor._get_package_versions(name='unittest',
                                               packages=packages)

        self.assertEquals(
            versions, [{
                'created_at': datetime.datetime(2014, 7, 7, 20, 27, 18),
                'name': 'unittest',
                'distro_version': 'ubuntu/trusty',
                'filename': 'unittest_0.1-1_all.deb'
            }, {
                'created_at': datetime.datetime(2015, 7, 7, 20, 27, 18),
                'name': 'unittest',
                'distro_version': 'ubuntu/trusty',
                'filename': 'unittest_0.2-1_all.deb'
            }])
Esempio n. 5
0
 def test_init_missing_token(self):
     # Un-set the token and make sure the init fails
     packagecloud.TOKEN = None
     with self.assertRaises(exceptions.InvalidCredentials):
         packagecloud.PackagecloudBase('Unit Test Action', {})
Esempio n. 6
0
 def test_init_missing_account(self):
     # Un-set the account and make sure the init fails
     packagecloud.ACCOUNT = None
     with self.assertRaises(exceptions.InvalidCredentials):
         packagecloud.PackagecloudBase('Unit Test Action', {})