Example #1
0
    def test_get_application_list_pagination(self, test_client, db_session, auth_headers):
        """Should return paginated records"""

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

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

        assert get_resp.status_code == 200
        assert len(get_data['records']) == PER_PAGE_DEFAULT
        assert get_data['current_page'] == PAGE_DEFAULT
        assert get_data['total'] == batch_size
Example #2
0
    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
        applications = NOWApplicationFactory.create_batch(size=batch_size)

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

        assert get_resp.status_code == 200
        assert len(get_data['records']) == batch_size
        assert get_data['total'] == batch_size
        assert all(
            str(application.application_guid) in map(lambda x: x['application_guid'], get_data['records'])
            for application in applications)
Example #3
0
    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 = NOWApplicationFactory.create_batch(size=batch_size)
        mine = MineFactory(minimal=True)
        application_1 = NOWApplicationFactory(mine=mine)
        application_2 = NOWApplicationFactory(mine=mine)

        get_resp = test_client.get(f'mines/{mine.mine_guid}/now-submissions/applications',
                                   headers=auth_headers['full_auth_header'])
        get_data = json.loads(get_resp.data.decode())

        assert get_resp.status_code == 200
        assert len(get_data['records']) == 2
        assert all(
            str(application.application_guid) not in map(lambda x: x['application_guid'], get_data['records'])
            for application in other_applications)
        assert all(
            str(application.application_guid) in map(lambda x: x['application_guid'], get_data['records'])
            for application in [application_1, application_2])