Ejemplo n.º 1
0
 def test_03_resource_str_hashes(self):
     r1 = Resource('03hashes',1234.1)
     r1.md5 = 'aaa'
     r1.sha1 = 'bbb'
     self.assertEqual( Sitemap().resource_as_xml(r1), "<url><loc>03hashes</loc><lastmod>1970-01-01T00:20:34.100000Z</lastmod><rs:md hash=\"md5:aaa sha-1:bbb\" /></url>" )
     r1.sha256 = 'ccc'
     self.assertEqual( Sitemap().resource_as_xml(r1), "<url><loc>03hashes</loc><lastmod>1970-01-01T00:20:34.100000Z</lastmod><rs:md hash=\"md5:aaa sha-1:bbb sha-256:ccc\" /></url>" )
     r1.sha1 = None
     self.assertEqual( Sitemap().resource_as_xml(r1), "<url><loc>03hashes</loc><lastmod>1970-01-01T00:20:34.100000Z</lastmod><rs:md hash=\"md5:aaa sha-256:ccc\" /></url>" )
Ejemplo n.º 2
0
 def test_03_resource_str_hashes(self):
     r1 = Resource('03hashes', 1234.1)
     r1.md5 = 'aaa'
     r1.sha1 = 'bbb'
     self.assertEqual(
         Sitemap().resource_as_xml(r1),
         "<url><loc>03hashes</loc><lastmod>1970-01-01T00:20:34.100000Z</lastmod><rs:md hash=\"md5:aaa sha-1:bbb\" /></url>"
     )
     r1.sha256 = 'ccc'
     self.assertEqual(
         Sitemap().resource_as_xml(r1),
         "<url><loc>03hashes</loc><lastmod>1970-01-01T00:20:34.100000Z</lastmod><rs:md hash=\"md5:aaa sha-1:bbb sha-256:ccc\" /></url>"
     )
     r1.sha1 = None
     self.assertEqual(
         Sitemap().resource_as_xml(r1),
         "<url><loc>03hashes</loc><lastmod>1970-01-01T00:20:34.100000Z</lastmod><rs:md hash=\"md5:aaa sha-256:ccc\" /></url>"
     )
Ejemplo n.º 3
0
 def test08_multiple_hashes(self):
     r1 = Resource('abcd')
     r1.md5 = "some_md5"
     r1.sha1 = "some_sha1"
     r1.sha256 = "some_sha256"
     self.assertEqual( r1.md5, "some_md5" )
     self.assertEqual( r1.sha1, "some_sha1" )
     self.assertEqual( r1.sha256, "some_sha256" )
     self.assertEqual( r1.hash, "md5:some_md5 sha-1:some_sha1 sha-256:some_sha256" )
     r2 = Resource('def')
     r2.hash = "md5:ddd"
     self.assertEqual( r2.md5, 'ddd' )
     self.assertEqual( r2.sha1, None )
     r2.hash = "sha-1:eee"
     self.assertEqual( r2.md5, None )
     self.assertEqual( r2.sha1, 'eee' )
     r2.hash = "md5:fff sha-1:eee sha-256:ggg"
     self.assertEqual( r2.md5, 'fff' )
     self.assertEqual( r2.sha1, 'eee' )
     self.assertEqual( r2.sha256, 'ggg' )
Ejemplo n.º 4
0
 def test08_multiple_hashes(self):
     r1 = Resource('abcd')
     r1.md5 = "some_md5"
     r1.sha1 = "some_sha1"
     r1.sha256 = "some_sha256"
     self.assertEqual(r1.md5, "some_md5")
     self.assertEqual(r1.sha1, "some_sha1")
     self.assertEqual(r1.sha256, "some_sha256")
     self.assertEqual(r1.hash,
                      "md5:some_md5 sha-1:some_sha1 sha-256:some_sha256")
     r2 = Resource('def')
     r2.hash = "md5:ddd"
     self.assertEqual(r2.md5, 'ddd')
     self.assertEqual(r2.sha1, None)
     r2.hash = "sha-1:eee"
     self.assertEqual(r2.md5, None)
     self.assertEqual(r2.sha1, 'eee')
     r2.hash = "md5:fff sha-1:eee sha-256:ggg"
     self.assertEqual(r2.md5, 'fff')
     self.assertEqual(r2.sha1, 'eee')
     self.assertEqual(r2.sha256, 'ggg')