def test_get_parent_node_at_location(testing_communities): with session_scope() as session: w_id = get_community_id(session, "Global") # 0 to 100 c1_id = get_community_id(session, "Country 1") # 0 to 50 c1r1_id = get_community_id(session, "Country 1, Region 1") # 0 to 10 c1r1c1_id = get_community_id(session, "Country 1, Region 1, City 1") # 0 to 5 c1r1c2_id = get_community_id(session, "Country 1, Region 1, City 2") # 7 to 10 c1r2_id = get_community_id(session, "Country 1, Region 2") # 20 to 25 c1r2c1_id = get_community_id(session, "Country 1, Region 2, City 1") # 21 to 23 c2_id = get_community_id(session, "Country 2") # 52 to 100 c2r1_id = get_community_id(session, "Country 2, Region 1") # 52 to 71 c2r1c1_id = get_community_id(session, "Country 2, Region 1, City 1") # 53 to 70 assert get_parent_node_at_location(session, create_1d_point(1)).id == c1r1c1_id assert get_parent_node_at_location(session, create_1d_point(3)).id == c1r1c1_id assert get_parent_node_at_location(session, create_1d_point(6)).id == c1r1_id assert get_parent_node_at_location(session, create_1d_point(8)).id == c1r1c2_id assert get_parent_node_at_location(session, create_1d_point(15)).id == c1_id assert get_parent_node_at_location(session, create_1d_point(51)).id == w_id
def test_GetGroup(testing_communities): # implicitly tests visibility and blocking, since all groups have invisible, blocked, and blocking member and admin with session_scope() as session: user2_id, token2 = get_user_id_and_token(session, "user2") w_id = get_community_id(session, "Global") c1_id = get_community_id(session, "Country 1") c2_id = get_community_id(session, "Country 2") c1r2_id = get_community_id(session, "Country 1, Region 2") c2r1_id = get_community_id(session, "Country 2, Region 1") hitchhikers_id = get_group_id(session, "Hitchhikers") c1r2foodies_id = get_group_id(session, "Country 1, Region 2, Foodies") c2r1foodies_id = get_group_id(session, "Country 2, Region 1, Foodies") with groups_session(token2) as api: res = api.GetGroup( groups_pb2.GetGroupReq(group_id=hitchhikers_id, )) assert res.group_id == hitchhikers_id assert res.name == "Hitchhikers" assert res.slug == "hitchhikers" assert res.description == "Description for Hitchhikers" assert len(res.parents) == 2 assert res.parents[0].HasField("community") assert res.parents[0].community.community_id == w_id assert res.parents[0].community.name == "Global" assert res.parents[0].community.slug == "global" assert res.parents[ 0].community.description == "Description for Global" assert res.parents[1].HasField("group") assert res.parents[1].group.group_id == hitchhikers_id assert res.parents[1].group.name == "Hitchhikers" assert res.parents[1].group.slug == "hitchhikers" assert res.parents[ 1].group.description == "Description for Hitchhikers" assert res.main_page.type == pages_pb2.PAGE_TYPE_MAIN_PAGE assert res.main_page.slug == "main-page-for-the-hitchhikers-community" assert res.main_page.last_editor_user_id == 1 assert res.main_page.creator_user_id == 1 assert res.main_page.owner_group_id == hitchhikers_id assert res.main_page.title == "Main page for the Hitchhikers community" assert res.main_page.content == "There is nothing here yet..." assert res.main_page.can_edit assert not res.main_page.can_moderate assert res.main_page.editor_user_ids == [1] assert res.member assert res.admin assert res.member_count == 4 assert res.admin_count == 2 res = api.GetGroup( groups_pb2.GetGroupReq(group_id=c1r2foodies_id, )) assert res.group_id == c1r2foodies_id assert res.name == "Country 1, Region 2, Foodies" assert res.slug == "country-1-region-2-foodies" assert res.description == "Description for Country 1, Region 2, Foodies" assert len(res.parents) == 4 assert res.parents[0].HasField("community") assert res.parents[0].community.community_id == w_id assert res.parents[0].community.name == "Global" assert res.parents[0].community.slug == "global" assert res.parents[ 0].community.description == "Description for Global" assert res.parents[1].HasField("community") assert res.parents[1].community.community_id == c1_id assert res.parents[1].community.name == "Country 1" assert res.parents[1].community.slug == "country-1" assert res.parents[ 1].community.description == "Description for Country 1" assert res.parents[2].HasField("community") assert res.parents[2].community.community_id == c1r2_id assert res.parents[2].community.name == "Country 1, Region 2" assert res.parents[2].community.slug == "country-1-region-2" assert res.parents[ 2].community.description == "Description for Country 1, Region 2" assert res.parents[3].HasField("group") assert res.parents[3].group.group_id == c1r2foodies_id assert res.parents[3].group.name == "Country 1, Region 2, Foodies" assert res.parents[3].group.slug == "country-1-region-2-foodies" assert res.parents[ 3].group.description == "Description for Country 1, Region 2, Foodies" assert res.main_page.type == pages_pb2.PAGE_TYPE_MAIN_PAGE assert res.main_page.slug == "main-page-for-the-country-1-region-2-foodies-community" assert res.main_page.last_editor_user_id == 2 assert res.main_page.creator_user_id == 2 assert res.main_page.owner_group_id == c1r2foodies_id assert res.main_page.title == "Main page for the Country 1, Region 2, Foodies community" assert res.main_page.content == "There is nothing here yet..." assert res.main_page.can_edit assert res.main_page.can_moderate assert res.main_page.editor_user_ids == [2] assert res.member assert res.admin assert res.member_count == 3 assert res.admin_count == 1 res = api.GetGroup( groups_pb2.GetGroupReq(group_id=c2r1foodies_id, )) assert res.group_id == c2r1foodies_id assert res.name == "Country 2, Region 1, Foodies" assert res.slug == "country-2-region-1-foodies" assert res.description == "Description for Country 2, Region 1, Foodies" assert len(res.parents) == 4 assert res.parents[0].HasField("community") assert res.parents[0].community.community_id == w_id assert res.parents[0].community.name == "Global" assert res.parents[0].community.slug == "global" assert res.parents[ 0].community.description == "Description for Global" assert res.parents[1].HasField("community") assert res.parents[1].community.community_id == c2_id assert res.parents[1].community.name == "Country 2" assert res.parents[1].community.slug == "country-2" assert res.parents[ 1].community.description == "Description for Country 2" assert res.parents[2].HasField("community") assert res.parents[2].community.community_id == c2r1_id assert res.parents[2].community.name == "Country 2, Region 1" assert res.parents[2].community.slug == "country-2-region-1" assert res.parents[ 2].community.description == "Description for Country 2, Region 1" assert res.parents[3].HasField("group") assert res.parents[3].group.group_id == c2r1foodies_id assert res.parents[3].group.name == "Country 2, Region 1, Foodies" assert res.parents[3].group.slug == "country-2-region-1-foodies" assert res.parents[ 3].group.description == "Description for Country 2, Region 1, Foodies" assert res.main_page.type == pages_pb2.PAGE_TYPE_MAIN_PAGE assert res.main_page.slug == "main-page-for-the-country-2-region-1-foodies-community" assert res.main_page.last_editor_user_id == 6 assert res.main_page.creator_user_id == 6 assert res.main_page.owner_group_id == c2r1foodies_id assert res.main_page.title == "Main page for the Country 2, Region 1, Foodies community" assert res.main_page.content == "There is nothing here yet..." assert not res.main_page.can_edit assert not res.main_page.can_moderate assert res.main_page.editor_user_ids == [6] assert not res.member assert not res.admin assert res.member_count == 2 assert res.admin_count == 1