Example #1
0
def test_fetch_package_should_update_existing_package(pypi_stub):
    repository = RepositoryFactory(upstream_pypi_url=pypi_stub.url)
    package = PackageFactory(repository=repository, name='minibar')
    ReleaseFactory(package=package, version='0.1')
    ReleaseFactory(package=package, version='0.2')

    fetch_package(repository.pk, 'minibar')

    package = repository.packages.filter(name='minibar').first()

    assert package
    assert package.name == 'minibar'
    assert not package.is_local
    assert package.releases.count() == 3

    release_1, release_2, release_3 = package.releases.all()

    assert release_1.version == '0.4.0'
    assert release_2.version == '0.2'
    assert release_3.version == '0.1'

    assert release_3.author == 'Cesar Canassa'
    assert release_3.author_email == '*****@*****.**'
    assert release_3.description == 'Minibar'
    assert release_3.download_url == 'UNKNOWN'
    assert release_3.home_page == 'https://github.com/canassa/minibar'
    assert release_3.license == 'MIT'
    assert release_3.metadata_version == '1.0'
    assert release_3.summary == 'Simple text progress bar library'
Example #2
0
    def test_save_add(self):
        repository = RepositoryFactory()

        data = {
            'label': 'all',
            'cidr': '0/0',
            'require_credentials': '1',
        }
        form = forms.AccessControlForm(data, repository=repository)
        assert form.is_valid()
        form.save()
        assert repository.cidr_list.count() == 1
Example #3
0
    def test_save_add(self):
        team = TeamFactory()
        repository = RepositoryFactory()

        data = {
            'team': team.pk,
        }
        form = forms.RepositoryTeamForm(data, repository=repository)
        assert form.is_valid()
        form.save()

        assert repository.teams.count() == 1
Example #4
0
def test_search_repos(test_client, repo_fixture: Repository, event_loop):
    event_loop.run_until_complete(RepositoryFactory.create(
        owner=repo_fixture.owner,
        name='test'
    ))
    response = test_client.get('/api/repos', params={'name': repo_fixture.name})
    data = response.json()

    assert response.status_code == 200
    assert data['data'] == {
        'repos': [
            repo_data(repo_fixture)
        ]
    }
    def test_history_of(self):
        date_metric_result = DateMetricResultFactory.build()
        kalibro_module = KalibroModuleFactory.build(id = 2)
        native_metric = NativeMetricFactory.build()
        repository = RepositoryFactory.build(id = 3)

        metric_result_history_of_hash = {'metric_result_history_of': [date_metric_result._asdict()]}
        with patch.object(Repository, 'request', return_value=metric_result_history_of_hash) as request_mock:
            assert_equal(TreeMetricResult.history_of(native_metric.name, kalibro_module.id,
                                                 repository.id),
                         [date_metric_result])
            request_mock.assert_called_once_with(action=':id/metric_result_history_of',
                                                 params={'metric_name': native_metric.name,
                                                         'kalibro_module_id': kalibro_module.id,
                                                         'id': repository.id})
Example #6
0
def test_get_all_repos(test_client, event_loop, repo_fixture: Repository):
    repo1 = event_loop.run_until_complete(RepositoryFactory.create(
        owner=repo_fixture.owner,
        name='test'
    ))

    response = test_client.get('/api/repos')
    data = response.json()

    assert response.status_code == 200
    assert data['data'] == {
        'repos': [
            repo_data(repo_fixture),
            repo_data(repo1)
        ]
    }
Example #7
0
def test_get_some_repos_by_owner(test_client, event_loop, repo_fixture: Repository):
    event_loop.run_until_complete(RepositoryFactory.create(
        owner=repo_fixture.owner,
        name='test'
    ))
    response = test_client.get(
        f'/api/repos/owner/{repo_fixture.owner_id}',
        params={'name': repo_fixture.name}
    )
    data = response.json()

    assert response.status_code == 200
    assert data['data'] == {
        'repos': [
            repo_data(repo_fixture)
        ]
    }
Example #8
0
    def test_save_new(self):
        repository = RepositoryFactory()

        data = {
            'comment': 'some key',
            'allow_upload': '',
            'deactivated': '',
        }
        form = forms.CredentialModelForm(data, repository=repository)
        assert form.is_valid()
        form.save()

        assert repository.credentials.count() == 1
        credential = repository.credentials.first()

        assert credential.comment == 'some key'
        assert credential.allow_upload is False
        assert credential.deactivated is None
Example #9
0
    def test_save_update(self):
        repository = RepositoryFactory()
        credential = CredentialFactory(repository=repository,
                                       allow_upload=True)

        data = {
            'comment': 'some key',
            'allow_upload': '1',
            'deactivated': '1',
        }
        form = forms.CredentialModelForm(data,
                                         instance=credential,
                                         repository=repository)
        assert form.is_valid()
        form.save()

        assert repository.credentials.count() == 1
        credential = repository.credentials.first()

        assert credential.comment == 'some key'
        assert credential.allow_upload is True
        assert credential.deactivated is not None
Example #10
0
def test_fetch_package_with_inexistent_package(pypi_stub):
    repository = RepositoryFactory(upstream_pypi_url=pypi_stub.url)
    fetch_package(repository.pk, 'arcoiro')

    assert not repository.packages.filter(name='arcoiro').first()
Example #11
0
def test_fetch_package_with_wrong_separator(pypi_stub):
    repository = RepositoryFactory(upstream_pypi_url=pypi_stub.url)
    fetch_package(repository.pk, 'pyramid-debugtoolbar')

    assert repository.packages.filter(name='pyramid_debugtoolbar').first()
Example #12
0
def test_fetch_package(pypi_stub):
    repository = RepositoryFactory(upstream_pypi_url=pypi_stub.url)
    fetch_package(repository.pk, 'minibar')

    package = repository.packages.filter(name='minibar').first()

    assert package
    assert package.name == 'minibar'
    assert not package.is_local
    assert package.releases.count() == 2

    release_1, release_2 = package.releases.all()

    assert release_1.author == 'Cesar Canassa'
    assert release_1.author_email == '*****@*****.**'
    assert release_1.description == 'Minibar'
    assert release_1.download_url == 'UNKNOWN'
    assert release_1.home_page == 'https://github.com/canassa/minibar'
    assert release_1.license == 'MIT'
    assert release_1.metadata_version == '1.0'
    assert release_1.summary == 'Simple text progress bar library'
    assert release_1.version == '0.4.0'

    assert release_2.author == 'Cesar Canassa'
    assert release_2.author_email == '*****@*****.**'
    assert release_2.description == 'Minibar'
    assert release_2.download_url == 'UNKNOWN'
    assert release_2.home_page == 'https://github.com/canassa/minibar'
    assert release_2.license == 'MIT'
    assert release_2.metadata_version == '1.0'
    assert release_2.summary == 'Simple text progress bar library'
    assert release_2.version == '0.1'

    assert release_1.files.count() == 2

    file_1, file_2 = release_1.files.all()

    assert file_1.size == 5844
    assert file_1.filetype == 'bdist_wheel'
    assert file_1.filename == 'minibar-0.4.0-py2.py3-none-any.whl'
    assert file_1.md5_digest == '0bbdf41e028a4e6c75dfbd59660b6328'
    assert file_1.python_version == '3.4'
    assert file_1.url == 'https://pypi.python.org/packages/3.4/m/minibar/minibar-0.4.0-py2.py3-none-any.whl'

    assert file_2.size == 3956
    assert file_2.filetype == 'sdist'
    assert file_2.filename == 'minibar-0.4.0.tar.gz'
    assert file_2.md5_digest == 'a3768a7f948871d8e47b146053265100'
    assert file_2.python_version == 'source'
    assert file_2.url == 'https://pypi.python.org/packages/source/m/minibar/minibar-0.4.0.tar.gz'

    assert release_2.files.count() == 1

    file_1 = release_2.files.first()

    assert file_1.size == 3461
    assert file_1.filetype == 'sdist'
    assert file_1.filename == 'minibar-0.1.tar.gz'
    assert file_1.md5_digest == 'c935bfa49cb49e4f97fb8e24371105d7'
    assert file_1.python_version == 'source'
    assert file_1.url == 'https://pypi.python.org/packages/source/m/minibar/minibar-0.1.tar.gz'
Example #13
0
def test_fetch_package_with_wrong_case(pypi_stub):
    repository = RepositoryFactory(upstream_pypi_url=pypi_stub.url)
    fetch_package(repository.pk, 'Minibar')

    assert repository.packages.filter(name='minibar').first()
Example #14
0
def repository(db):
    repo = RepositoryFactory()
    CIDRFactory(repository=repo)
    return repo
 def setUp(self):
     self.subject = RepositoryFactory.build()
     self.date_str = "2015-07-05T22:16:18+00:00"
     self.date = dateutil.parser.parse(self.date_str)
Example #16
0
 def test_init(self):
     repository = RepositoryFactory()
     forms.RepositoryTeamForm(repository=repository)
def test_fetch_package(pypi_stub):
    repository = RepositoryFactory(upstream_pypi_url=pypi_stub)
    fetch_package(repository.pk, 'minibar')

    package = repository.packages.filter(name='minibar').first()

    assert package
    assert package.name == 'minibar'
    assert not package.is_local
    assert package.releases.count() == 2

    release_1, release_2 = package.releases.all()

    assert release_1.author == 'Cesar Canassa'
    assert release_1.author_email == '*****@*****.**'
    assert release_1.description == 'Minibar'
    assert release_1.download_url == 'UNKNOWN'
    assert release_1.home_page == 'https://github.com/canassa/minibar'
    assert release_1.license == 'MIT'
    assert release_1.metadata_version == '1.0'
    assert release_1.summary == 'Simple text progress bar library'
    assert release_1.version == '0.4.0'

    assert release_2.author == 'Cesar Canassa'
    assert release_2.author_email == '*****@*****.**'
    assert release_2.description == 'Minibar'
    assert release_2.download_url == 'UNKNOWN'
    assert release_2.home_page == 'https://github.com/canassa/minibar'
    assert release_2.license == 'MIT'
    assert release_2.metadata_version == '1.0'
    assert release_2.summary == 'Simple text progress bar library'
    assert release_2.version == '0.1'

    assert release_1.files.count() == 2

    file_1, file_2 = release_1.files.all()

    assert file_1.size == 5844
    assert file_1.filetype == 'bdist_wheel'
    assert file_1.filename == 'minibar-0.4.0-py2.py3-none-any.whl'
    assert file_1.md5_digest == '0bbdf41e028a4e6c75dfbd59660b6328'
    assert file_1.python_version == '3.4'
    assert file_1.url == 'https://pypi.python.org/packages/6c/60/8554f591f2a5a830c06070397df765d2cce36277459f3cb4ff2c2fa08369/minibar-0.4.0-py2.py3-none-any.whl'  # noqa

    assert file_2.size == 3956
    assert file_2.filetype == 'sdist'
    assert file_2.filename == 'minibar-0.4.0.tar.gz'
    assert file_2.md5_digest == 'a3768a7f948871d8e47b146053265100'
    assert file_2.python_version == 'source'
    assert file_2.url == 'https://pypi.python.org/packages/57/f3/fecf00ba7ec1989aa55d98be1eccd26a9c38a9cbe3ec70487908a8749ba1/minibar-0.4.0.tar.gz'  # noqa

    assert release_2.files.count() == 1

    file_1 = release_2.files.first()

    assert file_1.size == 3461
    assert file_1.filetype == 'sdist'
    assert file_1.filename == 'minibar-0.1.tar.gz'
    assert file_1.md5_digest == 'c935bfa49cb49e4f97fb8e24371105d7'
    assert file_1.python_version == 'source'
    assert file_1.url == 'https://files.pythonhosted.org/packages/4e/c5/9275972ae0aff6a8102978b677290aae7e7ca1133bc0765b685cc2d5b1f1/minibar-0.1.tar.gz'  # noqa
Example #18
0
 def setUp(self):
     self.project = ProjectFactory.build()
     self.project.id = 1
     self.repository = RepositoryFactory.build()
     self.repositories = [self.repository]