Exemplo n.º 1
0
    def setUp(self):
        super(TaskApiIntegrationTests, self).setUp()

        self.init_projects()

        campaign = ProjectPhase.objects.get(slug='campaign')

        self.some_user = BlueBottleUserFactory.create()
        self.some_token = "JWT {0}".format(self.some_user.get_jwt_token())
        self.some_project = ProjectFactory.create(owner=self.some_user,
                                                  status=campaign)

        self.another_user = BlueBottleUserFactory.create()
        self.another_token = "JWT {0}".format(
            self.another_user.get_jwt_token())
        self.another_project = ProjectFactory.create(owner=self.another_user)

        self.task = TaskFactory.create(project=self.some_project)

        self.skill1 = SkillFactory.create()
        self.skill2 = SkillFactory.create()
        self.skill3 = SkillFactory.create()
        self.skill4 = SkillFactory.create()

        self.task_url = reverse('task-list')
        self.task_preview_url = reverse('task_preview_list')
        self.task_members_url = reverse('task-member-list')
        self.task_detail_url = reverse('task_detail', args=(self.task.pk, ))
Exemplo n.º 2
0
    def setUp(self):
        super(SkillListApiTests, self).setUp()

        self.skill1 = SkillFactory.create()
        self.skill2 = SkillFactory.create()
        self.skill3 = SkillFactory.create()
        self.skill4 = SkillFactory.create(disabled=True)

        self.skills_url = '/api/bb_tasks/skills/'
Exemplo n.º 3
0
    def test_sort_matching_skill(self):
        skill = SkillFactory.create()
        self.owner.skills.add(skill)
        self.owner.save()

        first = AssignmentFactory.create(status='full')
        ApplicantFactory.create_batch(3, activity=first, status='accepted')

        second = AssignmentFactory.create(status='full', expertise=skill)
        ApplicantFactory.create_batch(3, activity=second, status='accepted')

        third = AssignmentFactory.create(status='open')
        fourth = AssignmentFactory.create(status='open', expertise=skill)

        response = self.client.get(self.url + '?sort=popularity',
                                   user=self.owner)

        data = json.loads(response.content)

        self.assertEqual(data['meta']['pagination']['count'], 4)

        self.assertEqual(data['data'][0]['id'], str(fourth.pk))
        self.assertEqual(data['data'][1]['id'], str(third.pk))
        self.assertEqual(data['data'][2]['id'], str(second.pk))
        self.assertEqual(data['data'][3]['id'], str(first.pk))
Exemplo n.º 4
0
    def setUp(self):
        self.some_user = BlueBottleUserFactory.create()
        self.some_token = "JWT {0}".format(self.some_user.get_jwt_token())

        self.another_user = BlueBottleUserFactory.create()
        self.another_token = "JWT {0}".format(self.another_user.get_jwt_token())

        self.some_project = ProjectFactory.create(owner=self.some_user)
        self.another_project = ProjectFactory.create(owner=self.another_user)

        self.skill1 = SkillFactory.create()
        self.skill2 = SkillFactory.create()
        self.skill3 = SkillFactory.create()
        self.skill4 = SkillFactory.create()

        self.task_url = '/api/bb_tasks/'
        self.task_members_url = '/api/bb_tasks/members/'
Exemplo n.º 5
0
    def setUp(self):
        super(SkillAPITestCase, self).setUp()

        self.client = JSONAPITestClient()
        Skill.objects.all().delete()
        self.user = BlueBottleUserFactory()

        skills = SkillFactory.create_batch(5, disabled=False)
        self.skill = skills[0]
        self.list_url = reverse('assignment-skill-list')
        self.detail_url = reverse('assignment-skill', args=(self.skill.id, ))
Exemplo n.º 6
0
    def setUp(self):
        super(TaskApiIntegrationTests, self).setUp()

        self.init_projects()

        self.some_user = BlueBottleUserFactory.create()
        self.some_token = "JWT {0}".format(self.some_user.get_jwt_token())

        self.another_user = BlueBottleUserFactory.create()
        self.another_token = "JWT {0}".format(self.another_user.get_jwt_token())

        self.some_project = ProjectFactory.create(owner=self.some_user)
        self.another_project = ProjectFactory.create(owner=self.another_user)

        self.skill1 = SkillFactory.create()
        self.skill2 = SkillFactory.create()
        self.skill3 = SkillFactory.create()
        self.skill4 = SkillFactory.create()

        self.task_url = '/api/bb_tasks/'
        self.task_preview_url = '/api/bb_tasks/previews/'
        self.task_members_url = '/api/bb_tasks/members/'
    def setUp(self):
        self.init_projects()
        self.skill = SkillFactory.create()
        self.project = OnePercentProjectFactory.create()
        self.project.owner = BlueBottleUserFactory.create()
        self.project.save()
        self.login(username=self.project.owner.email, password='******')

        self.task1 = {
            'title': 'Hora est labora',
            'description': 'In nec convallis felis. Quisque iaculis augue nec eros convallis, non rutrum velit mattis.',
            'location': 'Vestibulum nisi dui',
            'end_goal': 'World peace',
            'people_needed': 8,
            'time_needed': 4,
            'skill': self.skill.id
        }
Exemplo n.º 8
0
    def test_create_assignment(self):
        skill = SkillFactory.create()
        data = {
            'data': {
                'type': 'activities/assignments',
                'attributes': {
                    'title':
                    'Business plan Young Freddy',
                    'date':
                    str((timezone.now() + timedelta(days=21))),
                    'end_date_type':
                    'deadline',
                    'duration':
                    8,
                    'registration_deadline':
                    str((timezone.now() + timedelta(days=14)).date()),
                    'capacity':
                    2,
                    'description':
                    'Help Young Freddy write a business plan',
                    'is-online':
                    True,
                },
                'relationships': {
                    'initiative': {
                        'data': {
                            'type': 'initiatives',
                            'id': self.initiative.id
                        },
                    },
                    'expertise': {
                        'data': {
                            'type': 'skills',
                            'id': skill.pk
                        },
                    },
                }
            }
        }
        response = self.client.post(self.url, json.dumps(data), user=self.user)

        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        self.assertEqual(response.data['status'], 'draft')
        self.assertEqual(response.data['title'], 'Business plan Young Freddy')
Exemplo n.º 9
0
    def test_fields_appear(self):
        request = self.request_factory.get('/')
        request.user = MockUser()

        for field in ['member_link', 'task_link']:
            self.assertIn(field, self.skill_admin.get_fields(request))

        skill = SkillFactory.create()
        members = BlueBottleUserFactory.create_batch(3)
        for member in members:
            member.skills = [skill]
            member.save()

        TaskFactory.create_batch(2, skill=skill)

        skill_url = reverse('admin:tasks_skill_change', args=(skill.id, ))
        response = self.client.get(skill_url)
        self.assertEqual(response.status_code, 200)

        self.assertContains(response, '3 users')
        self.assertContains(response, '2 tasks')
Exemplo n.º 10
0
    def test_sort_matching_combined(self):
        theme = ProjectThemeFactory.create()
        self.owner.favourite_themes.add(theme)

        skill = SkillFactory.create()
        self.owner.skills.add(skill)

        self.owner.location = LocationFactory.create(position='10.0, 20.0')
        self.owner.save()

        initiative = InitiativeFactory.create(theme=theme)

        first = EventFactory.create(status='open',
                                    initiative=initiative,
                                    is_online=False)
        second = AssignmentFactory.create(
            status='open',
            location=GeolocationFactory.create(position=Point(21.0, 9.0)),
            initiative=initiative,
            is_online=False)
        third = AssignmentFactory.create(
            status='open',
            location=GeolocationFactory.create(position=Point(21.0, 9.0)),
            initiative=initiative,
            expertise=skill,
            is_online=False)

        response = self.client.get(self.url + '?sort=popularity',
                                   user=self.owner)

        data = json.loads(response.content)

        self.assertEqual(data['meta']['pagination']['count'], 3)

        self.assertEqual(data['data'][0]['id'], str(third.pk))
        self.assertEqual(data['data'][1]['id'], str(second.pk))
        self.assertEqual(data['data'][2]['id'], str(first.pk))
Exemplo n.º 11
0
    def test_expertise_based_no_expertise(self):
        skill = SkillFactory.create(expertise=False)
        TaskFactory.create(skill=skill, project=self.project)

        self.assertFalse(self.project.expertise_based)
Exemplo n.º 12
0
    def test_expertise_based(self):
        skill = SkillFactory.create(expertise=True)
        TaskFactory.create(skill=skill, project=self.project)

        self.assertTrue(self.project.expertise_based)
Exemplo n.º 13
0
 def test_detail_disabled(self):
     skill = SkillFactory.create(disabled=True)
     response = self.client.get(
         reverse('assignment-skill', args=(skill.id, )))
     self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
Exemplo n.º 14
0
 def test_list_disabled(self):
     SkillFactory.create(disabled=True)
     response = self.client.get(self.list_url)
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     self.assertEqual(len(response.json()['data']), 5)