def test_fetch_wp_logo_url_only_org_logo_by_ad_id():
    app.testing = True
    with app.test_client():
        ad_with_workplace_id = 8417304
        ad_id = str(ad_with_workplace_id)

        found_logo_url = platsannonser.get_correct_logo_url(ad_id)
        print(found_logo_url)
        assert found_logo_url
예제 #2
0
def test_fetch_not_found_ad_by_id():
    print('==================',
          sys._getframe().f_code.co_name, '================== ')

    app.testing = True
    with app.test_client() as testclient:
        headers = {'api-key': test_api_key, 'accept': 'application/json'}
        ad_id = '823069282306928230692823069282306928230692'

        result = testclient.get('/ad/' + ad_id, headers=headers, data={})
        assert result.status_code == 404
예제 #3
0
def test_freetext_query_two_params():
    print('============================',
          sys._getframe().f_code.co_name, '============================ ')

    app.testing = True
    with app.test_client() as testclient:
        headers = {'api-key': test_api_key, 'accept': 'application/json'}
        result = testclient.get('/af/search',
                                headers=headers,
                                data={
                                    'q': 'gymnasielärare lokförare',
                                    'limit': '0'
                                })
        json_response = result.json
        # pprint(json_response)
        hits_total = json_response['total']
        assert int(hits_total) > 0
예제 #4
0
def test_fetch_ad_by_id():
    print('==================',
          sys._getframe().f_code.co_name, '================== ')

    app.testing = True
    with app.test_client() as testclient:
        headers = {'api-key': test_api_key, 'accept': 'application/json'}
        # First do a search and use that ad:s ID to test fetch
        found_ad = testclient.get('/search',
                                  headers=headers,
                                  data={'limit': '1'})
        ad_id = found_ad.json.get("hits")[0].get("id")
        result = testclient.get('/ad/' + ad_id, headers=headers, data={})
        ad_result = result.json
        # pprint(ad_result)

        assert 'id' in ad_result
        assert ad_result['id'] == ad_id
def test_fetch_org_logo_url_by_ad_id():
    app.testing = True
    with app.test_client() as testclient:
        headers = {'api-key': test_api_key, 'accept': 'application/json'}
        # First do a search and use that ad:s ID to test fetch
        found_ads = testclient.get('/search',
                                   headers=headers,
                                   data={'limit': '100'})
        hits = found_ads.json.get("hits")
        # print(hits)
        assert len(hits) > 0

        found_logo_url = False
        for hit in hits:
            ad_id = hit.get("id")
            # print(ad_id)
            logo_url = platsannonser.get_correct_logo_url(ad_id)
            if logo_url:
                found_logo_url = True
                print(logo_url)
                break

        assert found_logo_url
def test_fetch_ad_logo_by_id():
    print('==================',
          sys._getframe().f_code.co_name, '================== ')

    app.testing = True
    with app.test_client() as testclient:

        headers = {'api-key': test_api_key, 'accept': 'application/json'}
        # First do a search and use that ad:s ID to test fetch
        found_ad = testclient.get('/search',
                                  headers=headers,
                                  data={'limit': '100'})
        hits = found_ad.json.get("hits")
        # print(hits)
        assert len(hits) > 0

        found_logo_url_id = 0
        for hit in hits:
            ad_id = hit.get("id")

            logo_url = platsannonser.get_correct_logo_url(ad_id)
            if logo_url:
                found_logo_url_id = ad_id
                # print(logo_url)
                # print(found_logo_url_id)
                break
            # else:
            #     print('Not found', ad_id)

        test_url = '/ad/' + str(found_logo_url_id) + '/logo'
        print(test_url)
        result = testclient.get(test_url, headers=headers, data={})
        # pprint(result.stream)

        assert result is not None
        assert result.stream is not None