Beispiel #1
0
 def test_applicant_document_by_someone_else(self):
     response = self.client.get(self.participant_url,
                                user=self.someone_else)
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     self.assertEqual(response.data['document'], None)
     with self.assertRaises(IndexError):
         get_included(response, 'documents')
    def test_create_participant(self):
        response = self.client.post(self.participant_url,
                                    json.dumps(self.data),
                                    user=self.participant)

        self.assertEqual(response.status_code, status.HTTP_201_CREATED)

        data = json.loads(response.content)

        self.assertEqual(data['data']['attributes']['status'], 'new')
        self.assertEqual(data['included'][0]['type'], 'activities/events')
        self.assertTrue(data['included'][0]['attributes']['is-follower'])

        response = self.client.get(self.event_url, user=self.participant)
        event_data = json.loads(response.content)
        self.assertEqual(
            len(event_data['data']['relationships']['contributions']['data']),
            1)
        self.assertEqual(event_data['data']['attributes']['stats']['count'], 0)
        self.assertEqual(
            event_data['data']['attributes']['stats']['committed_count'], 1)

        self.assertEqual(
            event_data['data']['relationships']['contributions']['data'][0]
            ['id'], data['data']['id'])
        self.assertEqual(
            event_data['data']['relationships']['contributions']['data'][0]
            ['type'], 'contributions/participants')
        self.assertTrue(event_data['data']['attributes']['is-follower'])

        participant_data = get_included(response, 'contributions/participants')

        self.assertTrue(participant_data['id'], self.participant.pk)
        self.assertTrue('meta' in participant_data)
Beispiel #3
0
    def test_apply_with_document(self):
        with open(self.png_document_path, 'rb') as test_file:
            response = self.client.post(
                self.private_document_url,
                test_file.read(),
                content_type="image/png",
                HTTP_CONTENT_DISPOSITION='attachment; filename="test.rtf"',
                user=self.user)

        self.assertEqual(response.status_code, 201)
        data = json.loads(response.content)
        document_id = data['data']['id']
        self.apply_data['data']['relationships']['document'] = {
            'data': {
                'type': 'private-documents',
                'id': document_id
            }
        }
        response = self.client.post(self.url,
                                    json.dumps(self.apply_data),
                                    user=self.user)
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        data = json.loads(response.content)
        self.assertEqual(
            data['data']['relationships']['document']['data']['id'],
            document_id)
        document = get_included(response, 'private-documents')
        self.assertTrue('.rtf' in document['meta']['filename'])
Beispiel #4
0
    def test_applicant_document_by_user(self):
        response = self.client.get(self.participant_url, user=self.user)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['document']['id'],
                         str(self.applicant.document.id))
        document = get_included(response, 'private-documents')
        document_url = document['attributes']['link']

        response = self.client.get(document_url, user=self.user)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
Beispiel #5
0
    def test_create_bank_account(self):
        response = self.client.post(self.bank_account_url, data=json.dumps(self.data), user=self.user)
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        data = json.loads(response.content)
        self.assertEqual(data['data']['attributes']['account-number'], '123456789')

        response = self.client.get(self.payout_account_url, user=self.user)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        bank_details = get_included(response, 'payout-accounts/pledge-external-accounts')
        self.assertEqual(bank_details['attributes']['account-number'], '123456789')
        self.assertEqual(bank_details['attributes']['account-holder-name'], 'Habari Gani')
    def test_create_bank_account(self):
        response = self.client.post(self.bank_account_url,
                                    data=json.dumps(self.data),
                                    user=self.user)
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        data = json.loads(response.content)
        self.assertEqual(data['data']['attributes']['bank-code'], '044')

        response = self.client.get(self.payout_account_url, user=self.user)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        bank_details = get_included(
            response, 'payout-accounts/flutterwave-external-accounts')
        self.assertEqual(bank_details['attributes']['bank-code'], '044')
    def test_update_event_image(self):

        file_path = './bluebottle/files/tests/files/test-image.png'
        with open(file_path, 'rb') as test_file:
            response = self.client.post(
                reverse('image-list'),
                test_file.read(),
                content_type="image/png",
                HTTP_CONTENT_DISPOSITION='attachment; filename="some_file.png"',
                user=self.event.owner)

        file_data = json.loads(response.content)
        data = {
            'data': {
                'type': 'activities/events',
                'id': self.event.id,
                'relationships': {
                    'image': {
                        'data': {
                            'type': 'images',
                            'id': file_data['data']['id']
                        }
                    }
                }
            }
        }
        response = self.client.patch(self.url,
                                     json.dumps(data),
                                     user=self.event.owner)

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        data = response.json()
        self.assertEqual(data['data']['relationships']['image']['data']['id'],
                         file_data['data']['id'])

        image = get_included(response, 'images')

        response = self.client.get(image['attributes']['links']['large'],
                                   user=self.event.owner)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertTrue(
            response['X-Accel-Redirect'].startswith('/media/cache/'))