Skip to content

Commit

Permalink
fix addusers test
Browse files Browse the repository at this point in the history
  • Loading branch information
claire-peters committed Sep 14, 2024
1 parent 873125c commit f648182
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
5 changes: 2 additions & 3 deletions coldfront/core/project/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,15 +384,14 @@ def test_add_users_form_validation(self):
self.client.force_login(self.proj_accessmanager)
# Prepare form data for adding a user
form_data = {
'q': 'search_user',
'search_by': 'username',
'q': self.nonproj_allocation_user.username,
'search_by': 'username_only',
'userform-TOTAL_FORMS': '1',
'userform-INITIAL_FORMS': '0',
'userform-MIN_NUM_FORMS': '0',
'userform-MAX_NUM_FORMS': '1',
'userform-0-selected': 'on',
'userform-0-role': ProjectUserRoleChoice.objects.get(name='User').pk,
'userform-0-username': self.nonproj_allocation_user.username,
'allocationform-allocation': [self.proj_allocation.pk]
}
response = self.client.post(self.url, data=form_data)
Expand Down
7 changes: 2 additions & 5 deletions coldfront/core/project/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,6 @@ def post(self, request, *args, **kwargs):
allocation_form = ProjectAddUsersToAllocationForm(
request.user, project_obj.pk, request.POST, prefix='allocationform'
)

added_users_count = 0

if formset.is_valid() and allocation_form.is_valid():
Expand Down Expand Up @@ -672,7 +671,6 @@ def post(self, request, *args, **kwargs):
'status': projuserstatus_active,
}
)

added_users_count += 1
for allocation in Allocation.objects.filter(
pk__in=allocation_form_data
Expand Down Expand Up @@ -755,14 +753,13 @@ def get(self, request, *args, **kwargs):
signal_response = project_filter_users_to_remove.send(
sender=self.__class__, users_to_remove=users_list, project=project_obj
)
print('signal_response', signal_response)
if signal_response:
user_categories = signal_response[0][1]
users_no_removal = user_categories[0]
users_to_remove = user_categories[1]
else:
users_no_removal = users_list
users_to_remove = []
users_no_removal = []
users_to_remove = users_list

context = {}

Expand Down
2 changes: 1 addition & 1 deletion coldfront/core/test_helpers/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""utility functions for unit and integration testing"""
from beautifulsoup4 import BeautifulSoup
from bs4 import BeautifulSoup

def page_contains_for_user(test_case, user, url, text):
"""Check that page contains text for user"""
Expand Down

0 comments on commit f648182

Please sign in to comment.