def test_len(self):
     subject1 = writable_archive_xml_namespace_settings()
     self.assertEqual(0, len(subject1), "Incorrect # of default mappings")
     subject2 = writable_archive_xml_namespace_settings(x="google.com", aardvark="aardvark.com")
     self.assertEqual(2, len(subject2), "Incorrect # of mappings")
     subject2.update(src="www.sdml.org/srcml/src")
     self.assertEqual(3, len(subject2), "Incorrect # of mappings")
     subject2.remove_by_prefix("src")
     self.assertEqual(2, len(subject2), "Incorrect # of mappings")
 def test_remove(self):
     subject = writable_archive_xml_namespace_settings(x="google.com", aardvark="aardvark.com")
     self.assertEqual(2, len(subject), "Incorrect # of mappings")
     subject.remove(("x", "google.com"))
     self.assertEqual(1, len(subject), "Incorrect # of mappings")
     self.assertFalse(("x", "google.com") in subject, "didn't correctly locate value")
     self.assertTrue(("aardvark", "aardvark.com") in subject, "didn't correctly locate value")
 def test_setitem_update_mapping(self):
     subject = writable_archive_xml_namespace_settings(x="google.com", aardvark="aardvark.com")
     expected_uri = "somthing-new.com"
     subject["x"] = expected_uri
     self.assertEqual(2, len(subject), "Incorrect # of objects")
     self.assertTrue(("x", expected_uri) in subject, "didn't correctly locate value")
     self.assertTrue(("aardvark", "aardvark.com") in subject, "didn't correctly locate mapping")
 def test_constructor_iterable(self):
     subject = writable_archive_xml_namespace_settings(("x","google.com"), ("aardvark", "aardvark.com"))
     # print str(subject)
     self.assertEqual(2, len(subject), "Incorrect # of default namespaces. Actual # of items: {0}".format(len(subject)))
     self.assertTrue("x" in subject, "didn't correctly locate value")
     self.assertTrue("aardvark" in subject, "didn't correctly locate value")
     self.assertTrue(("aardvark", "aardvark.com") in subject, "didn't correctly locate mapping")
 def test_update_iterable_conflicting(self):
     subject = writable_archive_xml_namespace_settings() 
     self.assertEqual(0, len(subject), "Incorrect # of items")
     subject.update(("x", "google.com"), ("g", "something.com"))
     self.assertEqual(2, len(subject), "Incorrect # of items")
     self.assertTrue(subject.contains_mapping(("x", "google.com")), "Incorrect namespace located")
     subject.update(("g", "google.com"))
 def test_update_kwargs_conflicting(self):
     subject = writable_archive_xml_namespace_settings() 
     self.assertEqual(0, len(subject), "Incorrect # of items")
     subject.update(x="google.com", g="something.com")
     self.assertEqual(2, len(subject), "Incorrect # of items. Actual # of items: {0}".format(len(subject)))
     self.assertTrue(subject.contains_mapping(("x", "google.com")), "Incorrect namespace located")
     subject.update(g="google.com")
 def test___contains__mapping(self):
     subject = writable_archive_xml_namespace_settings(x="google.com", aardvark="aardvark.com")
     self.assertTrue("google.com" in subject, "didn't correctly locate value")
     self.assertTrue(("aardvark", "aardvark.com") in subject, "didn't correctly locate mapping")
     self.assertFalse(("aardvark", "somthing") in subject, "didn't correctly locate mapping")
     self.assertFalse(("something", "aardvark.com") in subject, "didn't correctly locate mapping")
     self.assertFalse(("something", "something") in subject, "didn't correctly locate mapping")
 def test_update_iterable_prefix_modifing(self):
     subject = writable_archive_xml_namespace_settings() 
     self.assertEqual(0, len(subject), "Incorrect # of items")
     subject.update(("x", "google.com"))
     self.assertEqual(1, len(subject), "Incorrect # of items")
     self.assertTrue(subject.contains_mapping(("x", "google.com")), "Incorrect namespace located")
     subject.update(("google", "google.com"))
     self.assertEqual(1, len(subject), "Incorrect # of items")
     self.assertTrue(subject.contains_mapping(("google", "google.com")), "Incorrect namespace located")
 def test_update_kwargs_uri_modifying(self):
     subject = writable_archive_xml_namespace_settings() 
     self.assertEqual(0, len(subject), "Incorrect # of items")
     subject.update(x="google.com")
     self.assertEqual(1, len(subject), "Incorrect # of items")
     self.assertTrue(subject.contains_mapping(("x", "google.com")), "Incorrect namespace located")
     subject.update(x="http://www.google.com")
     self.assertEqual(1, len(subject), "Incorrect # of items")
     self.assertTrue(subject.contains_mapping(("x", "http://www.google.com")), "Incorrect namespace located")
 def test_iteruris(self):
     subject = writable_archive_xml_namespace_settings(x="google.com", aardvark="aardvark.com")
     counter = 0
     remaining_namespaces = set(["google.com", "aardvark.com"])
     for uri in subject.iteruris():
         self.assertTrue(uri in remaining_namespaces, "Didn't locate expected prefix: {0}".format(uri))
         remaining_namespaces.remove(uri)
         counter += 1
     self.assertTrue(len(remaining_namespaces)==0,"Didn't visit all namespace mapping: Remaining: {0}".format(remaining_namespaces))
     self.assertEqual(2, counter, "Incorrect # of namespaces iterated over.")
 def test___iter__(self):
     subject = writable_archive_xml_namespace_settings(x="google.com", aardvark="aardvark.com")
     counter = 0
     remaining_namespaces = dict(x="google.com", aardvark="aardvark.com")
     for ns in subject:
         temp = remaining_namespaces[ns[0]]
         self.assertEqual(temp, ns[1], "Didn't receive correct uri")
         del remaining_namespaces[ns[0]]
         counter += 1
     self.assertTrue(len(remaining_namespaces)==0,"Didn't visit all namespace mapping: Remaining: {0}".format(remaining_namespaces))
     self.assertEqual(2, counter, "Incorrect # of namespaces iterated over.")
    def test_contains_mapping(self):
        subject = writable_archive_xml_namespace_settings(x="google.com", aardvark="aardvark.com")
        self.assertTrue(subject.contains_mapping("aardvark", "aardvark.com"), "didn't correctly locate mapping")
        self.assertFalse(subject.contains_mapping("aardvark", "somthing") , "didn't correctly locate mapping")
        self.assertFalse(subject.contains_mapping("something", "aardvark.com"), "didn't correctly locate mapping")
        self.assertFalse(subject.contains_mapping("something", "something"), "didn't correctly locate mapping")

        # with 1 parameter
        self.assertTrue(subject.contains_mapping( ("aardvark", "aardvark.com")), "didn't correctly locate mapping")
        self.assertFalse(subject.contains_mapping(("aardvark", "somthing")) , "didn't correctly locate mapping")
        self.assertFalse(subject.contains_mapping(("something", "aardvark.com")), "didn't correctly locate mapping")
        self.assertFalse(subject.contains_mapping(("something", "something")), "didn't correctly locate mapping")
 def test___contains__mapping_None(self):
     subject = writable_archive_xml_namespace_settings(x="google.com", aardvark="aardvark.com")
     self.assertFalse(None in subject, "didn't correctly locate value")
 def test_copy(self):
     subject = writable_archive_xml_namespace_settings(x="google.com", aardvark="aardvark.com")
     copy_of_subject = subject.copy()
     self.assertTrue(copy_of_subject == subject, "Copy isn't equal to subject")
 def test_setitem_None_value(self):
     subject = writable_archive_xml_namespace_settings(x="google.com", aardvark="aardvark.com")
     subject["src"] = None
 def test_setitem_None_prefix(self):
     subject = writable_archive_xml_namespace_settings(x="google.com", aardvark="aardvark.com")
     subject[None] = "banana"
 def test_update_kwargs_None(self):
     subject = writable_archive_xml_namespace_settings() 
     self.assertEqual(0, len(subject), "Incorrect # of items")
     subject.update(x=None)
 def test_remove_None_mapping(self):
     subject = writable_archive_xml_namespace_settings(x="google.com", aardvark="aardvark.com")
     subject.remove(None)
 def test_constructor_kwargs(self):
     subject = writable_archive_xml_namespace_settings(x="google.com", aardvark="aardvark.com")
     self.assertEqual(2, len(subject), "Incorrect # of default namespaces")
     self.assertTrue("x" in subject, "didn't correctly locate value")
     self.assertTrue("aardvark" in subject, "didn't correctly locate value")
     self.assertTrue(("aardvark", "aardvark.com") in subject, "didn't correctly locate mapping")
 def test_get_by_prefix(self):
     subject = writable_archive_xml_namespace_settings(x="google.com", aardvark="aardvark.com")
     self.assertTupleEqual(("x", "google.com"), subject.get_by_prefix("x"), "Didn't get correct mapping")
 def test_update_iterable_prefix_is_None(self):
     subject = writable_archive_xml_namespace_settings() 
     self.assertEqual(0, len(subject), "Incorrect # of items")
     subject.update((None, "x"))
 def test___delitem__None(self):
     subject = writable_archive_xml_namespace_settings(x="google.com", aardvark="aardvark.com")
     del subject[None]
 def test_get_by_prefix_bad_prefix(self):
     subject = writable_archive_xml_namespace_settings(x="google.com", aardvark="aardvark.com")
     x = subject.get_by_prefix("something")
 def test_clear(self):
     subject = writable_archive_xml_namespace_settings(x="google.com", aardvark="aardvark.com")
     self.assertEqual(2, len(subject), "Incorrect # of items")
     subject.clear()
     self.assertEqual(0, len(subject), "Incorrect # of items")
 def test_remove_by_prefix_None(self):
     subject = writable_archive_xml_namespace_settings(x="google.com", aardvark="aardvark.com")
     subject.remove_by_prefix(None)
 def test_remove_None_uri(self):
     subject = writable_archive_xml_namespace_settings(x="google.com", aardvark="aardvark.com")
     subject.remove(("prefix", None))
 def test_has_uri_None(self):
     subject = writable_archive_xml_namespace_settings(x="google.com", aardvark="aardvark.com")
     self.assertFalse(subject.has_uri(None), "didn't correctly locate value")
 def test_get_by_uri_bad_uri(self):
     subject = writable_archive_xml_namespace_settings(x="google.com", aardvark="aardvark.com")
     x = subject.get_by_uri(None)
 def test_constructor_default(self):
     subject = writable_archive_xml_namespace_settings()
     self.assertEqual(0, len(subject), "Incorrect # of default namespaces")
 def test___ne__(self):
     subject = writable_archive_xml_namespace_settings(x="google.com", aardvark="aardvark.com")
     subject2 = writable_archive_xml_namespace_settings(x="google.com", aardvark="aardvark.com")
     self.assertFalse(subject != subject2, "Incorrect comparison")
     subject3 = writable_archive_xml_namespace_settings(x="google.com", aardvark="aardvark.com", banana="somthing.com")
     self.assertTrue(subject != subject3, "Incorrect comparison")