Skip to content

Commit

Permalink
Remove references to CollectionVersion certification flag
Browse files Browse the repository at this point in the history
Closes-Issue: AAH-47

Signed-off-by: Andrew Crosby <acrosby@redhat.com>
  • Loading branch information
awcrosby committed Oct 19, 2020
1 parent 6b91399 commit b44d53a
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 35 deletions.
1 change: 1 addition & 0 deletions CHANGES/47.misc
@@ -0,0 +1 @@
Remove references to CollectionVersion certification flag
2 changes: 0 additions & 2 deletions galaxy_ng/app/api/ui/serializers/__init__.py
Expand Up @@ -5,7 +5,6 @@
CollectionDetailSerializer,
CollectionListSerializer,
CollectionVersionSerializer,
CertificationSerializer,
CollectionVersionDetailSerializer,
CollectionVersionBaseSerializer,
CollectionRemoteSerializer,
Expand Down Expand Up @@ -36,7 +35,6 @@
'CollectionDetailSerializer',
'CollectionListSerializer',
'CollectionVersionSerializer',
'CertificationSerializer',
'CollectionVersionDetailSerializer',
'CollectionVersionBaseSerializer',
'CollectionRemoteSerializer',
Expand Down
9 changes: 0 additions & 9 deletions galaxy_ng/app/api/ui/serializers/collection.py
Expand Up @@ -73,10 +73,6 @@ class CollectionVersionBaseSerializer(Serializer):
name = serializers.CharField()
version = serializers.CharField()
created_at = serializers.DateTimeField(source='pulp_created')
certification = serializers.ChoiceField(
['certified', 'not_certified', 'needs_review'],
required=True
)
metadata = CollectionMetadataSerializer(source='*')
contents = serializers.ListField(ContentSerializer())

Expand All @@ -100,11 +96,6 @@ def get_repository_list(self, collection_version):
return cv_in_repo_latest_version


class CertificationSerializer(Serializer):
certification = serializers.ChoiceField(
['certified', 'not_certified', 'needs_review'])


class CollectionVersionDetailSerializer(CollectionVersionBaseSerializer):
docs_blob = serializers.JSONField()

Expand Down
2 changes: 1 addition & 1 deletion galaxy_ng/app/api/ui/viewsets/collection.py
Expand Up @@ -92,7 +92,7 @@ def repo_filter(self, queryset, name, value):

class Meta:
model = CollectionVersion
fields = ['namespace', 'name', 'version', 'certification', 'repository']
fields = ['namespace', 'name', 'version', 'repository']


class CollectionVersionViewSet(api_base.GenericViewSet):
Expand Down
6 changes: 0 additions & 6 deletions galaxy_ng/app/constants.py
@@ -1,12 +1,6 @@
import enum


class CertificationStatus(enum.Enum):
CERTIFIED = 'certified'
NEEDS_REVIEW = 'needs_review'
NOT_CERTIFIED = 'not_certified'


class DeploymentMode(enum.Enum):
STANDALONE = 'standalone'
INSIGHTS = 'insights'
Expand Down
4 changes: 1 addition & 3 deletions galaxy_ng/app/settings.py
Expand Up @@ -40,9 +40,7 @@
# associated repository, distribution, and distribution base_paths
GALAXY_API_SYNCLIST_NAME_FORMAT = "{account_name}-synclist"

# Require approval for incoming content,
# currently using a certification flag,
# later using a staging repository
# Require approval for incoming content, which uses a staging repository
GALAXY_REQUIRE_CONTENT_APPROVAL = True

# Local rest framework settings
Expand Down
5 changes: 0 additions & 5 deletions galaxy_ng/app/tasks/publishing.py
Expand Up @@ -12,8 +12,6 @@

log = logging.getLogger(__name__)

VERSION_CERTIFIED = "certified"

GOLDEN_NAME = settings.GALAXY_API_DEFAULT_DISTRIBUTION_BASE_PATH
STAGING_NAME = settings.GALAXY_API_STAGING_DISTRIBUTION_BASE_PATH

Expand Down Expand Up @@ -91,9 +89,6 @@ def import_and_auto_approve(temp_file_pk, **kwargs):
created_collection_versions = get_created_collection_versions()

for collection_version in created_collection_versions:
collection_version.certification = VERSION_CERTIFIED
collection_version.save()

# enqueue task to add collection_version to golden repo
add_task_args = (collection_version.pk, golden_repo.pk)
enqueue_with_reservation(add_content_to_repository, add_locks, args=add_task_args)
Expand Down
51 changes: 42 additions & 9 deletions galaxy_ng/tests/unit/app/test_tasks.py
Expand Up @@ -11,9 +11,16 @@
Collection, CollectionVersion, AnsibleRepository, AnsibleDistribution
)

from galaxy_ng.app.tasks import import_and_auto_approve, import_and_move_to_staging
from galaxy_ng.app.tasks import (
add_content_to_repository,
remove_content_from_repository,
import_and_auto_approve,
import_and_move_to_staging,
)


log = logging.getLogger(__name__)
logging.getLogger().setLevel(logging.DEBUG)

golden_name = settings.GALAXY_API_DEFAULT_DISTRIBUTION_BASE_PATH
staging_name = settings.GALAXY_API_STAGING_DISTRIBUTION_BASE_PATH
Expand Down Expand Up @@ -42,25 +49,52 @@ def setUp(self):
)
content_artifact.save()

def test_add_content_to_repository(self):
repo = AnsibleRepository.objects.get(name=staging_name)
repo_version_number = repo.latest_version().number

self.assertNotIn(
self.collection_version,
CollectionVersion.objects.filter(pk__in=repo.latest_version().content))

add_content_to_repository(self.collection_version.pk, repo.pk)

self.assertEqual(repo_version_number + 1, repo.latest_version().number)
self.assertIn(
self.collection_version,
CollectionVersion.objects.filter(pk__in=repo.latest_version().content))

def test_remove_content_from_repository(self):
repo = AnsibleRepository.objects.get(name=staging_name)
add_content_to_repository(self.collection_version.pk, repo.pk)

repo_version_number = repo.latest_version().number
self.assertIn(
self.collection_version,
CollectionVersion.objects.filter(pk__in=repo.latest_version().content))

remove_content_from_repository(self.collection_version.pk, repo.pk)

self.assertEqual(repo_version_number + 1, repo.latest_version().number)
self.assertNotIn(
self.collection_version,
CollectionVersion.objects.filter(pk__in=repo.latest_version().content))

@mock.patch('galaxy_ng.app.tasks.publishing.get_created_collection_versions')
@mock.patch('galaxy_ng.app.tasks.publishing.import_collection')
@mock.patch('galaxy_ng.app.tasks.publishing.enqueue_with_reservation')
def test_import_and_auto_approve(self, mocked_enqueue, mocked_import, mocked_get_created):
inbound_repo = AnsibleRepository.objects.get(name=staging_name)
golden_repo = AnsibleRepository.objects.create(name=golden_name)

golden_repo = AnsibleRepository.objects.create(name=golden_name)
golden_dist = AnsibleDistribution(name=golden_name, base_path=golden_name)
golden_dist.repository = golden_repo
golden_dist.save()

self.assertTrue(self.collection_version.certification == 'needs_review')

mocked_get_created.return_value = [self.collection_version]

import_and_auto_approve(self.pulp_temp_file.pk, repository_pk=inbound_repo.pk)

self.collection_version.refresh_from_db()
self.assertTrue(self.collection_version.certification == 'certified')
self.assertTrue(mocked_import.call_count == 1)
self.assertTrue(mocked_enqueue.call_count == 2)

Expand All @@ -75,11 +109,10 @@ def test_import_and_auto_approve(self, mocked_enqueue, mocked_import, mocked_get
@mock.patch('galaxy_ng.app.tasks.publishing.import_collection')
@mock.patch('galaxy_ng.app.tasks.publishing.enqueue_with_reservation')
def test_import_and_move_to_staging(self, mocked_enqueue, mocked_import, mocked_get_created):
inbound_name = 'the_incoming_repo'
inbound_repo = AnsibleRepository.objects.create(name=inbound_name)
inbound_repo.save()
staging_repo = AnsibleRepository.objects.get(name=staging_name)

inbound_name = 'the_incoming_repo'
inbound_repo = AnsibleRepository.objects.create(name=inbound_name)
inbound_dist = AnsibleDistribution(name=inbound_name, base_path=inbound_name)
inbound_dist.repository = inbound_repo
inbound_dist.save()
Expand Down

0 comments on commit b44d53a

Please sign in to comment.