Commit a2fa5009 authored by Giorgos Korfiatis's avatar Giorgos Korfiatis
Browse files

astakos: Fix project identification in test

Test was mistakenly using application id rather than project id in
some occasions.
parent 3d953e61
......@@ -144,13 +144,15 @@ class TestProjects(TestCase):
self.assertContains(r, "The project application has been received")
self.assertRedirects(r, reverse('project_list'))
self.assertEqual(ProjectApplication.objects.count(), 1)
app1_id = ProjectApplication.objects.filter().order_by('pk')[0].pk
app1 = ProjectApplication.objects.filter().order_by('pk')[0]
app1_id = app1.pk
project1_id = app1.chain_id
# create another one
application_data['name'] = 'project2.synnefo.org'
r = self.user_client.post(post_url, data=application_data, follow=True)
app2_id = ProjectApplication.objects.filter().order_by('pk')[1].pk
app2 = ProjectApplication.objects.filter().order_by('pk')[1]
project2_id = app2.chain_id
# no more applications (LIMIT is 2)
r = self.user_client.get(reverse('project_add'), follow=True)
......@@ -170,14 +172,14 @@ class TestProjects(TestCase):
# login
self.member_client.get(reverse("edit_profile"))
# cannot join app2 (not approved yet)
join_url = reverse("project_join", kwargs={'chain_id': app2_id})
# cannot join project2 (not approved yet)
join_url = reverse("project_join", kwargs={'chain_id': project2_id})
r = self.member_client.post(join_url, follow=True)
self.assertEqual(r.status_code, 403)
# can join app1
self.member_client.get(reverse("edit_profile"))
join_url = reverse("project_join", kwargs={'chain_id': app1_id})
join_url = reverse("project_join", kwargs={'chain_id': project1_id})
r = self.member_client.post(join_url, follow=True)
self.assertEqual(r.status_code, 200)
......@@ -186,10 +188,10 @@ class TestProjects(TestCase):
memb_id = memberships[0].id
reject_member_url = reverse('project_reject_member',
kwargs={'chain_id': app1_id, 'memb_id':
kwargs={'chain_id': project1_id, 'memb_id':
memb_id})
accept_member_url = reverse('project_accept_member',
kwargs={'chain_id': app1_id, 'memb_id':
kwargs={'chain_id': project1_id, 'memb_id':
memb_id})
# only project owner is allowed to reject
......@@ -203,10 +205,16 @@ class TestProjects(TestCase):
# user rejoins
self.member_client.get(reverse("edit_profile"))
join_url = reverse("project_join", kwargs={'chain_id': app1_id})
join_url = reverse("project_join", kwargs={'chain_id': project1_id})
r = self.member_client.post(join_url, follow=True)
self.assertEqual(r.status_code, 200)
self.assertEqual(ProjectMembership.objects.count(), 1)
memberships = ProjectMembership.objects.all()
self.assertEqual(len(memberships), 1)
memb_id = memberships[0].id
accept_member_url = reverse('project_accept_member',
kwargs={'chain_id': project1_id, 'memb_id':
memb_id})
# user (owns project) accepts membership
r = self.user_client.post(accept_member_url, follow=True)
......@@ -221,7 +229,7 @@ class TestProjects(TestCase):
self.assertEqual(newlimit, 200)
remove_member_url = reverse('project_remove_member',
kwargs={'chain_id': app1_id, 'memb_id':
kwargs={'chain_id': project1_id, 'memb_id':
membership.id})
r = self.user_client.post(remove_member_url, follow=True)
self.assertEqual(r.status_code, 200)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment