Esempio n. 1
0
    def _package(self):
        package = Package(NAME)
        release = Release(VERSION)
        package.store_release(release)
        release.add_file(File(NAME, None, None))

        return package
Esempio n. 2
0
    def _package(self):
        package = Package(NAME)
        release = Release(VERSION)
        package.store_release(release)
        release.add_file(File(NAME, None, None))

        return package
Esempio n. 3
0
    def test_update_package(self):
        new = Package(NAME)
        self.mapper.store(new)

        new.store_release(Release(VERSION))
        self.mapper.store(new)

        retrieved = self.mapper.get_by_name(NAME)
        assert_that(retrieved, is_(new))
Esempio n. 4
0
    def test_update_package(self):
        new = Package(NAME)
        self.mapper.store(new)

        new.store_release(Release(VERSION))
        self.mapper.store(new)

        retrieved = self.mapper.get_by_name(NAME)
        assert_that(retrieved, is_(new))
Esempio n. 5
0
    def test_get_all_packages(self):
        new = Package(NAME)
        self.mapper.store(new)

        all_packages = self.mapper.all()

        assert_that(list(all_packages), is_([new]))
Esempio n. 6
0
    def test_insert_new_package(self):
        new = Package(NAME)

        self.mapper.store(new)

        retrieved = self.mapper.get_by_name(NAME)
        assert_that(retrieved, is_(new))
Esempio n. 7
0
    def test_upload_file_for_existent_package(self):
        package = Package(NAME)
        package.store_release(Release(VERSION))
        when(self.packages.get_by_name).then_return(package)

        self.command.execute(name=NAME,
                             version=VERSION,
                             filetype=u'sdist',
                             md5_digest=u'06022cad9c65a8aa384ce8df1ce6f6d9',
                             uploaded_file={
                                 'body': FILE_CONTENT,
                                 'content_type': 'application/unknown',
                                 'filename': FILE_NAME,
                             })

        assert_that_method(self.packages.store).was_called()
        assert_that_method(self.files.store).was_called().with_args(
            FILE_NAME, FILE_CONTENT)
Esempio n. 8
0
    def test_update_package_updates_last_updated_on(self):
        new = Package(NAME)
        self.mapper.store(new)

        updated = self.mapper.get_by_name(NAME)
        updated.store_release(Release(VERSION))
        self.mapper.store(updated)

        assert_that(updated.last_updated_on,
                    is_(greater_than(new.last_updated_on)))
    def test_upload_file_for_existent_package(self):
        package = Package(NAME)
        package.store_release(Release(VERSION))
        when(self.packages.get_by_name).then_return(package)

        self.command.execute(
            name=NAME,
            version=VERSION,
            filetype=u'sdist',
            md5_digest=u'06022cad9c65a8aa384ce8df1ce6f6d9',
            uploaded_file={
                'body': FILE_CONTENT,
                'content_type': 'application/unknown',
                'filename': FILE_NAME,
            }
        )

        assert_that_method(self.packages.store).was_called()
        assert_that_method(self.files.store).was_called().with_args(
            FILE_NAME,
            FILE_CONTENT
        )
Esempio n. 10
0
 def _get_or_create_new(self, name):
     try:
         return self.packages.get_by_name(name)
     except errors.NotFoundError:
         return Package(name)
Esempio n. 11
0
 def setup(self):
     self.package = Package(NAME)
Esempio n. 12
0
class TestPackage(object):
    def setup(self):
        self.package = Package(NAME)

    def test_package_has_metadata_when_created(self):
        assert_that(self.package.name, is_(NAME))
        assert_that(self.package.created_on, is_(datetime.datetime))
        assert_that(self.package.last_updated_on, is_(datetime.datetime))
        assert_that(self.package.is_from_pypi, is_(False))

    @raises(errors.NotFoundError)
    def test_getting_inexistent_release_raises_error(self):
        self.package.release(VERSION)

    def test_package_sets_new_release(self):
        release = Release(VERSION)
        self.package.store_release(release)

        assert_that(self.package.release(VERSION), is_(release))

    def test_package_sets_existent_release_replaces_it(self):
        self.package.store_release(Release(VERSION))
        self.package.store_release(Release(VERSION))

        assert_that(self.package.releases(), has_length(1))

    def test_package_has_a_release_if_was_already_stored(self):
        self.package.store_release(Release(VERSION))

        assert_that(self.package.has_release(Release(VERSION)), is_(True))
        assert_that(self.package.has_release(VERSION), is_(True))

    def test_package_hasnt_a_release_if_wasnt_stored(self):
        assert_that(self.package.has_release(Release(VERSION)), is_(False))
        assert_that(self.package.has_release(VERSION), is_(False))

    def test_package_returns_releases_ordered_by_version(self):
        self.package.store_release(Release(VERSION))
        self.package.store_release(Release(NEWER_VERSION))
        self.package.store_release(Release(OLDER_VERSION))

        releases = self.package.releases()

        assert_that(releases[0].version, is_(NEWER_VERSION))
        assert_that(releases[1].version, is_(VERSION))
        assert_that(releases[2].version, is_(OLDER_VERSION))

    def test_package_returns_newer_as_last_version(self):
        self.package.store_release(Release(VERSION))
        self.package.store_release(Release(NEWER_VERSION))
        self.package.store_release(Release(OLDER_VERSION))

        assert_that(self.package.last_release().version, is_(NEWER_VERSION))
Esempio n. 13
0
 def setup(self):
     self.package = Package(NAME)
Esempio n. 14
0
class TestPackage(object):

    def setup(self):
        self.package = Package(NAME)

    def test_package_has_metadata_when_created(self):
        assert_that(self.package.name, is_(NAME))
        assert_that(self.package.created_on, is_(datetime.datetime))
        assert_that(self.package.last_updated_on, is_(datetime.datetime))
        assert_that(self.package.is_from_pypi, is_(False))

    @raises(errors.NotFoundError)
    def test_getting_inexistent_release_raises_error(self):
        self.package.release(VERSION)

    def test_package_sets_new_release(self):
        release = Release(VERSION)
        self.package.store_release(release)

        assert_that(self.package.release(VERSION), is_(release))

    def test_package_sets_existent_release_replaces_it(self):
        self.package.store_release(Release(VERSION))
        self.package.store_release(Release(VERSION))

        assert_that(self.package.releases(), has_length(1))

    def test_package_has_a_release_if_was_already_stored(self):
        self.package.store_release(Release(VERSION))

        assert_that(self.package.has_release(Release(VERSION)), is_(True))
        assert_that(self.package.has_release(VERSION), is_(True))

    def test_package_hasnt_a_release_if_wasnt_stored(self):
        assert_that(self.package.has_release(Release(VERSION)), is_(False))
        assert_that(self.package.has_release(VERSION), is_(False))

    def test_package_returns_releases_ordered_by_version(self):
        self.package.store_release(Release(VERSION))
        self.package.store_release(Release(NEWER_VERSION))
        self.package.store_release(Release(OLDER_VERSION))

        releases = self.package.releases()

        assert_that(releases[0].version, is_(NEWER_VERSION))
        assert_that(releases[1].version, is_(VERSION))
        assert_that(releases[2].version, is_(OLDER_VERSION))


    def test_package_returns_newer_as_last_version(self):
        self.package.store_release(Release(VERSION))
        self.package.store_release(Release(NEWER_VERSION))
        self.package.store_release(Release(OLDER_VERSION))

        assert_that(self.package.last_release().version, is_(NEWER_VERSION))
Esempio n. 15
0
    def test_exists_package(self):
        new = Package(NAME)

        self.mapper.store(new)

        assert_that(self.mapper.exists(NAME))
Esempio n. 16
0
 def test_insert_new_packages_with_same_twice_raises_already_exists_error(
         self):
     self.mapper.store(Package(NAME))
     with assert_raises(errors.AlreadyExistsError):
         self.mapper.store(Package(NAME))