Adding a couple of extra unit tests for the parsing of keys
authorShaun McDonald <shaun@shaunmcdonald.me.uk>
Wed, 10 Jun 2009 17:42:29 +0000 (17:42 +0000)
committerShaun McDonald <shaun@shaunmcdonald.me.uk>
Wed, 10 Jun 2009 17:42:29 +0000 (17:42 +0000)
test/unit/relation_test.rb

index 1c46c70122c77e4ba1befeb0be139a83373957b4..a878be8cb0b7645a53c9eeb74a775426c6cb9654 100644 (file)
@@ -66,4 +66,24 @@ class RelationTest < ActiveSupport::TestCase
     }
     assert_match /Must specify a string with one or more characters/, message_update.message
   end
+  
+  def test_from_xml_no_k_v
+    nokv = "<osm><relation id='23' changeset='23' version='23'><tag /></relation></osm>"
+    assert_nothing_raised(OSM::APIBadUserInput, OSM::APIBadXMLError) {
+      Relation.from_xml(nokv, true)
+      Relation.from_xml(nokv, false)
+    }
+  end
+  
+  def test_from_xml_duplicate_k
+    dupk = "<osm><relation id='23' changeset='23' version='23'><tag k='dup' v='test'/><tag k='dup' v='test'/></relation></osm>"
+    message_create = assert_raise(OSM::APIDuplicateTagsError) {
+      Relation.from_xml(dupk, true)
+    }
+    assert_equal "Element relation/ has duplicate tags with key dup", message_create.message
+    message_update = assert_raise(OSM::APIDuplicateTagsError) {
+      Relation.from_xml(dupk, false)
+    }
+    assert_equal "Element relation/23 has duplicate tags with key dup", message_update.message
+  end
 end