Exemplo n.º 1
0
def test_56_add_comment_to_section(john_doe_api_client, default_hearing, get_comments_url_and_data):
    section = default_hearing.sections.first()
    url, data = get_comments_url_and_data(default_hearing, section)
    old_comment_list = get_data_from_response(john_doe_api_client.get(url))

    # If pagination is used the actual data is in "results"
    if 'results' in old_comment_list:
        old_comment_list = old_comment_list['results']

    # set section explicitly
    comment_data = get_comment_data(section=section.pk)
    response = john_doe_api_client.post(url, data=comment_data)

    data = get_data_from_response(response, status_code=201)
    assert 'section' in data
    assert data['section'] == section.pk

    assert 'content' in data
    assert data['content'] == default_comment_content

    assert 'geojson' in data
    assert data['geojson'] == get_geojson()

    # Check that the comment is available in the comment endpoint now
    new_comment_list = get_data_from_response(john_doe_api_client.get(url))

    # If pagination is used the actual data is in "results"
    if 'results' in new_comment_list:
        new_comment_list = new_comment_list['results']

    assert len(new_comment_list) == len(old_comment_list) + 1
    new_comment = [c for c in new_comment_list if c["id"] == data["id"]][0]
    assert_common_keys_equal(new_comment, comment_data)
    assert new_comment["is_registered"] == True
    assert new_comment["author_name"] is None
Exemplo n.º 2
0
def get_comment_data(**extra):
    return dict(
        {
            'content': default_comment_content,
            'geojson': get_geojson(),
            'section': None
        }, **extra)
Exemplo n.º 3
0
def test_56_add_comment_to_section(john_doe_api_client, default_hearing, get_comments_url_and_data):
    section = default_hearing.sections.first()
    url, data = get_comments_url_and_data(default_hearing, section)
    old_comment_list = get_data_from_response(john_doe_api_client.get(url))

    # If pagination is used the actual data is in "results"
    if 'results' in old_comment_list:
        old_comment_list = old_comment_list['results']

    # set section explicitly
    comment_data = get_comment_data(section=section.pk)
    response = john_doe_api_client.post(url, data=comment_data)

    data = get_data_from_response(response, status_code=201)
    assert 'section' in data
    assert data['section'] == section.pk

    assert 'content' in data
    assert data['content'] == default_comment_content

    assert 'geojson' in data
    assert data['geojson'] == get_geojson()

    # Check that the comment is available in the comment endpoint now
    new_comment_list = get_data_from_response(john_doe_api_client.get(url))

    # If pagination is used the actual data is in "results"
    if 'results' in new_comment_list:
        new_comment_list = new_comment_list['results']

    assert len(new_comment_list) == len(old_comment_list) + 1
    new_comment = [c for c in new_comment_list if c["id"] == data["id"]][0]
    assert_common_keys_equal(new_comment, comment_data)
    assert new_comment["is_registered"] == True
    assert new_comment["author_name"] is None
Exemplo n.º 4
0
def test_hearing_geo(api_client, random_hearing):
    random_hearing.geojson = get_geojson()
    random_hearing.save()
    data = get_data_from_response(api_client.get(get_detail_url(random_hearing.id)))
    assert data["geojson"] == random_hearing.geojson
    map_data = get_data_from_response(api_client.get(list_endpoint + "map/"))
    assert map_data['results'][0]["geojson"] == random_hearing.geojson
Exemplo n.º 5
0
def test_hearing_geo(api_client, random_hearing):
    random_hearing.geojson = get_geojson()
    random_hearing.save()
    data = get_data_from_response(api_client.get(get_detail_url(random_hearing.id)))
    assert data["geojson"] == random_hearing.geojson
    map_data = get_data_from_response(api_client.get(list_endpoint + "map/"))
    assert map_data['results'][0]["geojson"] == random_hearing.geojson
Exemplo n.º 6
0
def test_hearing_geo(api_client, random_hearing):
    random_hearing.geojson = get_geojson()
    random_hearing.save()
    data = get_data_from_response(
        api_client.get(get_detail_url(random_hearing.id)))
    assert data["geojson"] == random_hearing.geojson
    geojson_data = get_data_from_response(
        api_client.get(get_detail_url(random_hearing.id),
                       {'format': 'geojson'}))
    assert_common_keys_equal(geojson_data["geometry"],
                             random_hearing.geojson["geometry"])
    assert_common_keys_equal(geojson_data["properties"],
                             random_hearing.geojson["properties"])
    map_data = get_data_from_response(api_client.get(list_endpoint + "map/"))
    assert map_data['results'][0]["geojson"] == random_hearing.geojson
Exemplo n.º 7
0
def get_comment_data(**extra):
    return dict({
        'content': default_comment_content,
        'geojson': get_geojson(),
        'section': None
    }, **extra)
Exemplo n.º 8
0
    },
    'main_image_id':
    '45',
    'position':
    '0',
    'title':
    'aksebfq rufmmwszkdkdocanzliys cv',
    'updated_at':
    '2014-11-25T19:01:23.900758'
}

HEARING = {
    '_area':
    'x',
    '_geometry':
    get_geojson(),
    'alternatives': [ALT1, ALT2],
    'body':
    ' gcthqzqrndsutwhoiqiabothsomtjwp',
    'closes_at':
    '2014-12-31',
    'comments': [{
        'body': 'x hisydetgyr tooetpydxmmdg  ylnc',
        'created_at': '2014-12-23T09:30:51.991187',
        'hearing_id': '12',
        'id': '245',
        'is_hidden': 'false',
        'lead': 'rchcvjenxt szclinijw jbabqhzsdna',
        'like_count': '0',
        'likes': [],
        'main_image': None,
Exemplo n.º 9
0
    'position': '1', 'title': 'nox v qj qsndntryubrnhvsbwmgdzmx', 'updated_at': '2014-11-25T19:01:23.900769'}

ALT2 = {'body': 'qixzbjypctfgffvro kjqlangqf ltvp', 'comments': [
    {'alternative_id': '34', 'body': 'jsks njxemfiaqxtsawch vzzmvhwnu ', 'created_at': '2014-12-03T19:22:44.262491',
     'id': '209', 'is_hidden': 'false', 'lead': 'rchcvjenxt szclinijw jbabqhzsdna', 'like_count': '0', 'likes': [],
     'main_image': None, 'title': ' ijiwfhkstq aphhodwirh ncpbuipmb', 'username': '******'},
    {'alternative_id': '34', 'body': 'zpt  fnrdfyhm   irzlmdtghrdzpygt', 'created_at': '2014-11-27T08:25:28.055787',
     'id': '98', 'is_hidden': 'false', 'lead': 'rchcvjenxt szclinijw jbabqhzsdna', 'like_count': '1', 'likes': [LIKE],
     'main_image': None, 'title': 'hzyew gspcp ptpeltsznjgnxr uvcpm', 'username': '******'}],
    'created_at': '2014-11-25T19:01:23.881728', 'hearing_id': '12', 'id': '34',
    'lead': 'kovgskyhbthkdqmzguoyvnwvsenq lqu',
    'main_image': {'caption': 'Vaihtoehdon 1 esimerkkikuva.', 'created_at': '2014-11-25T19:01:23.890566',
                   'filename': 'images/hameentie/alternative_1/main_image.jpg', 'id': '45'}, 'main_image_id': '45',
    'position': '0', 'title': 'aksebfq rufmmwszkdkdocanzliys cv', 'updated_at': '2014-11-25T19:01:23.900758'}

HEARING = {'_area': 'x', '_geometry': get_geojson(), 'alternatives': [ALT1, ALT2],
           'body': ' gcthqzqrndsutwhoiqiabothsomtjwp',
           'closes_at': '2014-12-31', 'comments': [
    {'body': 'x hisydetgyr tooetpydxmmdg  ylnc', 'created_at': '2014-12-23T09:30:51.991187', 'hearing_id': '12',
     'id': '245', 'is_hidden': 'false', 'lead': 'rchcvjenxt szclinijw jbabqhzsdna', 'like_count': '0', 'likes': [],
     'main_image': None, 'title': 'figlxwalwwze pyffyhjywksjlslijkj', 'username': '******'},
    {'body': 'kdrzglteivqdtgfuxiigyjbsezsz urx', 'created_at': '2014-11-27T09:34:56.023891', 'hearing_id': '12',
     'id': '112', 'is_hidden': 'false', 'lead': 'rchcvjenxt szclinijw jbabqhzsdna', 'like_count': '0', 'likes': [],
     'main_image': None, 'title': ' clpcjxkhxw lgaejuywfpwsrikszcqy', 'username': '******'}],
    'created_at': '2014-11-25T19:01:23.859401', 'id': '12', 'lead': 'lipibmupbapezxiloyqjzd jnao knvd',
    'main_image': {
               'caption': 'Liikenne nykyisin Hõmeentiellõ. (Helsingin kaupungin aineistopankki / Seppo Laakso)',
               'created_at': '2014-11-25T19:01:23.898028', 'filename': 'images/hameentie/main_image.jpg',
               'id': '48'}, 'main_image_id': '48', 'opens_at': '2014-11-25', 'published': 'true',
    'sections': [SECTION], 'slug': '', 'title': 'ikwnydbg hjl riffyjsbrq shxv nkl',
    'updated_at': '2015-01-26T10:20:12.869162'}
Exemplo n.º 10
0
def get_comment_data(**extra):
    return dict({
        'content': default_comment_content,
        'geometry': json.dumps(get_geojson()),
        'section': None
    }, **extra)
Exemplo n.º 11
0
    'position': '1', 'title': 'nox v qj qsndntryubrnhvsbwmgdzmx', 'updated_at': '2014-11-25T19:01:23.900769'}

ALT2 = {'body': 'qixzbjypctfgffvro kjqlangqf ltvp', 'comments': [
    {'alternative_id': '34', 'body': 'jsks njxemfiaqxtsawch vzzmvhwnu ', 'created_at': '2014-12-03T19:22:44.262491',
     'id': '209', 'is_hidden': 'false', 'lead': 'rchcvjenxt szclinijw jbabqhzsdna', 'like_count': '0', 'likes': [],
     'main_image': None, 'title': ' ijiwfhkstq aphhodwirh ncpbuipmb', 'username': '******'},
    {'alternative_id': '34', 'body': 'zpt  fnrdfyhm   irzlmdtghrdzpygt', 'created_at': '2014-11-27T08:25:28.055787',
     'id': '98', 'is_hidden': 'false', 'lead': 'rchcvjenxt szclinijw jbabqhzsdna', 'like_count': '1', 'likes': [LIKE],
     'main_image': None, 'title': 'hzyew gspcp ptpeltsznjgnxr uvcpm', 'username': '******'}],
    'created_at': '2014-11-25T19:01:23.881728', 'hearing_id': '12', 'id': '34',
    'lead': 'kovgskyhbthkdqmzguoyvnwvsenq lqu',
    'main_image': {'caption': 'Vaihtoehdon 1 esimerkkikuva.', 'created_at': '2014-11-25T19:01:23.890566',
                   'filename': 'images/hameentie/alternative_1/main_image.jpg', 'id': '45'}, 'main_image_id': '45',
    'position': '0', 'title': 'aksebfq rufmmwszkdkdocanzliys cv', 'updated_at': '2014-11-25T19:01:23.900758'}

HEARING = {'_area': 'x', '_geometry': get_geojson(), 'alternatives': [ALT1, ALT2],
           'body': ' gcthqzqrndsutwhoiqiabothsomtjwp',
           'closes_at': '2014-12-31', 'comments': [
    {'body': 'x hisydetgyr tooetpydxmmdg  ylnc', 'created_at': '2014-12-23T09:30:51.991187', 'hearing_id': '12',
     'id': '245', 'is_hidden': 'false', 'lead': 'rchcvjenxt szclinijw jbabqhzsdna', 'like_count': '0', 'likes': [],
     'main_image': None, 'title': 'figlxwalwwze pyffyhjywksjlslijkj', 'username': '******'},
    {'body': 'kdrzglteivqdtgfuxiigyjbsezsz urx', 'created_at': '2014-11-27T09:34:56.023891', 'hearing_id': '12',
     'id': '112', 'is_hidden': 'false', 'lead': 'rchcvjenxt szclinijw jbabqhzsdna', 'like_count': '0', 'likes': [],
     'main_image': None, 'title': ' clpcjxkhxw lgaejuywfpwsrikszcqy', 'username': '******'}],
    'created_at': '2014-11-25T19:01:23.859401', 'id': '12', 'lead': 'lipibmupbapezxiloyqjzd jnao knvd',
    'main_image': {
               'caption': 'Liikenne nykyisin Hõmeentiellõ. (Helsingin kaupungin aineistopankki / Seppo Laakso)',
               'created_at': '2014-11-25T19:01:23.898028', 'filename': 'images/hameentie/main_image.jpg',
               'id': '48'}, 'main_image_id': '48', 'opens_at': '2014-11-25', 'published': 'true',
    'sections': [SECTION], 'slug': '', 'title': 'ikwnydbg hjl riffyjsbrq shxv nkl',
    'updated_at': '2015-01-26T10:20:12.869162'}