Skip to content

Commit

Permalink
Assign proper sequence numbers to relation members in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhughes committed Oct 18, 2023
1 parent c2b687d commit 428c7c6
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 38 deletions.
16 changes: 8 additions & 8 deletions test/controllers/api/changesets_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -579,9 +579,9 @@ def test_upload_delete
used_relation = create(:relation)
used_way = create(:way)
used_node = create(:node)
create(:relation_member, :relation => super_relation, :member => used_relation)
create(:relation_member, :relation => super_relation, :member => used_way)
create(:relation_member, :relation => super_relation, :member => used_node)
create(:relation_member, :relation => super_relation, :sequence_id => 1, :member => used_relation)
create(:relation_member, :relation => super_relation, :sequence_id => 2, :member => used_way)
create(:relation_member, :relation => super_relation, :sequence_id => 3, :member => used_node)

auth_header = basic_authorization_header changeset.user.display_name, "test"

Expand Down Expand Up @@ -712,8 +712,8 @@ def test_upload_delete_invalid
other_relation = create(:relation)
used_way = create(:way)
used_node = create(:node)
create(:relation_member, :relation => relation, :member => used_way)
create(:relation_member, :relation => relation, :member => used_node)
create(:relation_member, :relation => relation, :sequence_id => 1, :member => used_way)
create(:relation_member, :relation => relation, :sequence_id => 2, :member => used_node)

auth_header = basic_authorization_header changeset.user.email, "test"

Expand Down Expand Up @@ -753,9 +753,9 @@ def test_upload_delete_if_unused
used_relation = create(:relation)
used_way = create(:way)
used_node = create(:node)
create(:relation_member, :relation => super_relation, :member => used_relation)
create(:relation_member, :relation => super_relation, :member => used_way)
create(:relation_member, :relation => super_relation, :member => used_node)
create(:relation_member, :relation => super_relation, :sequence_id => 1, :member => used_relation)
create(:relation_member, :relation => super_relation, :sequence_id => 2, :member => used_way)
create(:relation_member, :relation => super_relation, :sequence_id => 3, :member => used_node)

auth_header = basic_authorization_header changeset.user.email, "test"

Expand Down
12 changes: 6 additions & 6 deletions test/controllers/api/relations_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -645,8 +645,8 @@ def test_tag_modify_bounding_box
node2 = create(:node, :lat => 5, :lon => 5)
way = create(:way)
create(:way_node, :way => way, :node => node1)
create(:relation_member, :relation => relation, :member => way)
create(:relation_member, :relation => relation, :member => node2)
create(:relation_member, :relation => relation, :sequence_id => 1, :member => way)
create(:relation_member, :relation => relation, :sequence_id => 2, :member => node2)
# the relation contains nodes1 and node2 (node1
# indirectly via the way), so the bbox should be [3,3,5,5].
check_changeset_modify(BoundingBox.new(3, 3, 5, 5)) do |changeset_id, auth_header|
Expand Down Expand Up @@ -713,8 +713,8 @@ def test_remove_member_bounding_box
relation = create(:relation)
node1 = create(:node, :lat => 3, :lon => 3)
node2 = create(:node, :lat => 5, :lon => 5)
create(:relation_member, :relation => relation, :member => node1)
create(:relation_member, :relation => relation, :member => node2)
create(:relation_member, :relation => relation, :sequence_id => 1, :member => node1)
create(:relation_member, :relation => relation, :sequence_id => 2, :member => node2)

check_changeset_modify(BoundingBox.new(5, 5, 5, 5)) do |changeset_id, auth_header|
# remove node 5 (5,5) from an existing relation
Expand Down Expand Up @@ -883,8 +883,8 @@ def test_remove_all_members
node2 = create(:node, :lat => 5, :lon => 5)
way = create(:way)
create(:way_node, :way => way, :node => node1)
create(:relation_member, :relation => relation, :member => way)
create(:relation_member, :relation => relation, :member => node2)
create(:relation_member, :relation => relation, :sequence_id => 1, :member => way)
create(:relation_member, :relation => relation, :sequence_id => 2, :member => node2)

check_changeset_modify(BoundingBox.new(3, 3, 5, 5)) do |changeset_id, auth_header|
relation_xml = xml_for_relation(relation)
Expand Down
1 change: 1 addition & 0 deletions test/factories/relation_member.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FactoryBot.define do
factory :relation_member do
sequence_id { 1 }
member_role { "" }

relation
Expand Down
28 changes: 14 additions & 14 deletions test/models/old_relation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ def test_relation_members
member_node = create(:node)
member_way = create(:way)
member_relation = create(:relation)
create(:old_relation_member, :old_relation => old_relation_v1, :member => member_node, :member_role => "some node")
create(:old_relation_member, :old_relation => old_relation_v2, :member => member_node, :member_role => "some changed node")
create(:old_relation_member, :old_relation => old_relation_v3, :member => member_node, :member_role => "some changed node")
create(:old_relation_member, :old_relation => old_relation_v3, :member => member_relation, :member_role => "some relation")
create(:old_relation_member, :old_relation => old_relation_v4, :member => member_node, :member_role => "some node")
create(:old_relation_member, :old_relation => old_relation_v4, :member => member_way, :member_role => "some way")
create(:old_relation_member, :old_relation => old_relation_v4, :member => member_relation, :member_role => "some relation")
create(:old_relation_member, :old_relation => old_relation_v1, :sequence_id => 1, :member => member_node, :member_role => "some node")
create(:old_relation_member, :old_relation => old_relation_v2, :sequence_id => 1, :member => member_node, :member_role => "some changed node")
create(:old_relation_member, :old_relation => old_relation_v3, :sequence_id => 1, :member => member_node, :member_role => "some changed node")
create(:old_relation_member, :old_relation => old_relation_v3, :sequence_id => 2, :member => member_relation, :member_role => "some relation")
create(:old_relation_member, :old_relation => old_relation_v4, :sequence_id => 1, :member => member_node, :member_role => "some node")
create(:old_relation_member, :old_relation => old_relation_v4, :sequence_id => 2, :member => member_way, :member_role => "some way")
create(:old_relation_member, :old_relation => old_relation_v4, :sequence_id => 3, :member => member_relation, :member_role => "some relation")

members = OldRelation.find(old_relation_v1.id).relation_members
assert_equal 1, members.count
Expand Down Expand Up @@ -88,13 +88,13 @@ def test_relations
member_node = create(:node)
member_way = create(:way)
member_relation = create(:relation)
create(:old_relation_member, :old_relation => old_relation_v1, :member => member_node, :member_role => "some node")
create(:old_relation_member, :old_relation => old_relation_v2, :member => member_node, :member_role => "some changed node")
create(:old_relation_member, :old_relation => old_relation_v3, :member => member_node, :member_role => "some changed node")
create(:old_relation_member, :old_relation => old_relation_v3, :member => member_relation, :member_role => "some relation")
create(:old_relation_member, :old_relation => old_relation_v4, :member => member_node, :member_role => "some node")
create(:old_relation_member, :old_relation => old_relation_v4, :member => member_way, :member_role => "some way")
create(:old_relation_member, :old_relation => old_relation_v4, :member => member_relation, :member_role => "some relation")
create(:old_relation_member, :old_relation => old_relation_v1, :sequence_id => 1, :member => member_node, :member_role => "some node")
create(:old_relation_member, :old_relation => old_relation_v2, :sequence_id => 1, :member => member_node, :member_role => "some changed node")
create(:old_relation_member, :old_relation => old_relation_v3, :sequence_id => 1, :member => member_node, :member_role => "some changed node")
create(:old_relation_member, :old_relation => old_relation_v3, :sequence_id => 2, :member => member_relation, :member_role => "some relation")
create(:old_relation_member, :old_relation => old_relation_v4, :sequence_id => 1, :member => member_node, :member_role => "some node")
create(:old_relation_member, :old_relation => old_relation_v4, :sequence_id => 2, :member => member_way, :member_role => "some way")
create(:old_relation_member, :old_relation => old_relation_v4, :sequence_id => 3, :member => member_relation, :member_role => "some relation")

members = OldRelation.find(old_relation_v1.id).members
assert_equal 1, members.count
Expand Down
20 changes: 10 additions & 10 deletions test/models/relation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ def test_relation_members
node = create(:node)
way = create(:way)
other_relation = create(:relation)
create(:relation_member, :relation => relation, :member => node, :member_role => "some node")
create(:relation_member, :relation => relation, :member => way, :member_role => "some way")
create(:relation_member, :relation => relation, :member => other_relation, :member_role => "some relation")
create(:relation_member, :relation => relation, :sequence_id => 1, :member => node, :member_role => "some node")
create(:relation_member, :relation => relation, :sequence_id => 2, :member => way, :member_role => "some way")
create(:relation_member, :relation => relation, :sequence_id => 3, :member => other_relation, :member_role => "some relation")

members = Relation.find(relation.id).relation_members
assert_equal 3, members.count
Expand All @@ -124,9 +124,9 @@ def test_relations
node = create(:node)
way = create(:way)
other_relation = create(:relation)
create(:relation_member, :relation => relation, :member => node, :member_role => "some node")
create(:relation_member, :relation => relation, :member => way, :member_role => "some way")
create(:relation_member, :relation => relation, :member => other_relation, :member_role => "some relation")
create(:relation_member, :relation => relation, :sequence_id => 1, :member => node, :member_role => "some node")
create(:relation_member, :relation => relation, :sequence_id => 2, :member => way, :member_role => "some way")
create(:relation_member, :relation => relation, :sequence_id => 3, :member => other_relation, :member_role => "some relation")

members = Relation.find(relation.id).members
assert_equal 3, members.count
Expand Down Expand Up @@ -185,8 +185,8 @@ def test_update_changeset_bbox_any_relation
relation = create(:relation)
super_relation = create(:relation)
node = create(:node, :longitude => 116, :latitude => 39)
create(:relation_member, :relation => super_relation, :member_type => "Relation", :member_id => relation.id)
node_member = create(:relation_member, :relation => super_relation, :member_type => "Node", :member_id => node.id)
create(:relation_member, :relation => super_relation, :sequence_id => 1, :member_type => "Relation", :member_id => relation.id)
node_member = create(:relation_member, :relation => super_relation, :sequence_id => 2, :member_type => "Node", :member_id => node.id)
user = create(:user)
changeset = create(:changeset, :user => user)
assert_nil changeset.min_lon
Expand All @@ -211,8 +211,8 @@ def test_changeset_bbox_delete_relation
orig_relation = create(:relation)
node1 = create(:node, :longitude => 116, :latitude => 39)
node2 = create(:node, :longitude => 39, :latitude => 116)
create(:relation_member, :relation => orig_relation, :member_type => "Node", :member_id => node1.id)
create(:relation_member, :relation => orig_relation, :member_type => "Node", :member_id => node2.id)
create(:relation_member, :relation => orig_relation, :sequence_id => 1, :member_type => "Node", :member_id => node1.id)
create(:relation_member, :relation => orig_relation, :sequence_id => 2, :member_type => "Node", :member_id => node2.id)
user = create(:user)
changeset = create(:changeset, :user => user)
assert_nil changeset.min_lon
Expand Down

0 comments on commit 428c7c6

Please sign in to comment.