def test_get_application_list_pagination(self, test_client, db_session, auth_headers):
        """Should return paginated records"""

        batch_size = PER_PAGE_DEFAULT + 1
        NOWApplicationIdentityFactory.create_batch(size=batch_size)

        get_resp = test_client.get('/now-applications', headers=auth_headers['full_auth_header'])
        assert get_resp.status_code == 200, get_resp.response
        get_data = json.loads(get_resp.data.decode())

        assert len(get_data['records']) == PER_PAGE_DEFAULT
        assert get_data['current_page'] == PAGE_DEFAULT
        assert get_data['total'] == batch_size
    def test_get_mine_application_list_success(self, test_client, db_session,
                                               auth_headers):
        """Should return the records for the mine with a 200 response code"""

        batch_size = 5
        other_applications = NOWApplicationIdentityFactory.create_batch(
            size=batch_size)
        mine = MineFactory(minimal=True)
        now_submission_1 = NOWSubmissionFactory(mine=mine)
        identity_1 = NOWApplicationIdentityFactory(
            now_submission=now_submission_1, mine=mine)
        now_submission_2 = NOWSubmissionFactory(mine=mine)
        identity_2 = NOWApplicationIdentityFactory(
            now_submission=now_submission_2, mine=mine)

        get_resp = test_client.get(
            f'now-applications?mine_guid={mine.mine_guid}',
            headers=auth_headers['full_auth_header'])
        assert get_resp.status_code == 200, get_resp.response
        get_data = json.loads(get_resp.data.decode())

        assert len(get_data['records']) == 2
        assert all(
            str(submission.now_application_guid) not in map(
                lambda x: x['now_application_guid'], get_data['records'])
            for submission in other_applications)
        assert all(
            str(submission.now_application_guid) in map(
                lambda x: x['now_application_guid'], get_data['records'])
            for submission in [now_submission_1, now_submission_1])
    def test_get_now_application_list_success(self, test_client, db_session, auth_headers):
        """Should return the correct records with a 200 response code"""

        batch_size = 5
        submissions = NOWApplicationIdentityFactory.create_batch(size=batch_size)

        get_resp = test_client.get('/now-applications', headers=auth_headers['full_auth_header'])
        assert get_resp.status_code == 200, get_resp.response
        get_data = json.loads(get_resp.data.decode())

        assert len(get_data['records']) == batch_size
        assert get_data['total'] == batch_size
        assert all(
            str(submission.now_application_guid) in map(lambda x: x['now_application_guid'],
                                                        get_data['records'])
            for submission in submissions)