Ejemplo n.º 1
0
 def test1c_same(self):
     """Same with lastmod instead of direct timestamp"""
     r1 = Resource('a')
     r1.lastmod = '2012-01-02'
     r2 = Resource('a')
     for r2lm in (
             '2012-01-02',
             '2012-01-02T00:00',
             '2012-01-02T00:00:00',
             '2012-01-02 00:00:00',
             '2012-01-02T00:00:00.00',
             '2012-01-02T00:00:00.000000000000',
             '2012-01-02T00:00:00.000000000001',  #below resolution
             '2012-01-02T00:00:00.00Z',
             '2012-01-02T00:00:00.00+0000',
             '2012-01-02T00:00:00.00-0000',
             '2012-01-02T00:00:00.00+00:00',
             '2012-01-02T00:00:00.00-00:00',
             '2012-01-02T00:00:00.00+02:00'  # FIXME - TZ info currently ignored
     ):
         r2.lastmod = r2lm
         self.assertEqual(r1.timestamp, r2.timestamp)
         self.assertEqual(r1.timestamp, r2.timestamp,
                          ('2012-01-02 == %s' % r2lm))
         self.assertEqual(r1, r2)
Ejemplo n.º 2
0
 def test1c_same(self):
     """Same with lastmod instead of direct timestamp"""
     r1 = Resource("a")
     r1lm = "2012-01-01T00:00:00Z"
     r1.lastmod = r1lm
     r2 = Resource("a")
     for r2lm in (
         "2012",
         "2012-01",
         "2012-01-01",
         "2012-01-01T00:00Z",
         "2012-01-01T00:00:00Z",
         "2012-01-01T00:00:00.000000Z",
         "2012-01-01T00:00:00.000000000000Z",
         "2012-01-01T00:00:00.000000000001Z",  # below resolution
         "2012-01-01T00:00:00.00+00:00",
         "2012-01-01T00:00:00.00-00:00",
         "2012-01-01T02:00:00.00-02:00",
         "2011-12-31T23:00:00.00+01:00",
     ):
         r2.lastmod = r2lm
         self.assertEqual(
             r1.timestamp, r2.timestamp, ("%s (%f) == %s (%f)" % (r1lm, r1.timestamp, r2lm, r2.timestamp))
         )
         self.assertEqual(r1, r2)
Ejemplo n.º 3
0
 def test01d_same(self):
     """Same with slight timestamp diff"""
     r1 = Resource('a')
     r1.lastmod = '2012-01-02T01:02:03Z'
     r2 = Resource('a')
     r2.lastmod = '2012-01-02T01:02:03.99Z'
     self.assertNotEqual(r1.timestamp, r2.timestamp)
     self.assertEqual(r1, r2)
Ejemplo n.º 4
0
 def test1d_same(self):
     """Same with slight timestamp diff"""
     r1 = Resource("a")
     r1.lastmod = "2012-01-02T01:02:03Z"
     r2 = Resource("a")
     r2.lastmod = "2012-01-02T01:02:03.99Z"
     self.assertNotEqual(r1.timestamp, r2.timestamp)
     self.assertEqual(r1, r2)
Ejemplo n.º 5
0
 def test01d_same(self):
     """Same with slight timestamp diff"""
     r1 = Resource('a')
     r1.lastmod='2012-01-02T01:02:03Z'
     r2 = Resource('a')
     r2.lastmod='2012-01-02T01:02:03.99Z'
     self.assertNotEqual( r1.timestamp, r2.timestamp )
     self.assertEqual( r1, r2 )
Ejemplo n.º 6
0
 def test05_lastmod_roundtrips(self):
     r = Resource('a')
     r.lastmod = '2012-03-14'
     self.assertEqual(r.lastmod, '2012-03-14T00:00:00Z')
     r.lastmod = '2012-03-14T00:00:00+00:00'
     # print r.timestamp
     self.assertEqual(r.lastmod, '2012-03-14T00:00:00Z')
     r.lastmod = '2012-03-14T00:00:00-00:00'
     # print r.timestamp
     self.assertEqual(r.lastmod, '2012-03-14T00:00:00Z')
     r.lastmod = '2012-03-14T18:37:36Z'
     # print r.timestamp
     self.assertEqual(r.lastmod, '2012-03-14T18:37:36Z')
Ejemplo n.º 7
0
 def test05_lastmod_roundtrips(self):
     r = Resource('a')
     r.lastmod='2012-03-14'
     self.assertEqual( r.lastmod, '2012-03-14T00:00:00Z' )
     r.lastmod='2012-03-14T00:00:00+00:00'
     #print r.timestamp
     self.assertEqual( r.lastmod, '2012-03-14T00:00:00Z' )
     r.lastmod='2012-03-14T00:00:00-00:00'
     #print r.timestamp
     self.assertEqual( r.lastmod, '2012-03-14T00:00:00Z' )
     r.lastmod='2012-03-14T18:37:36Z'
     #print r.timestamp
     self.assertEqual( r.lastmod, '2012-03-14T18:37:36Z' )
Ejemplo n.º 8
0
 def test1c_same(self):
     """Same with lastmod instead of direct timestamp"""
     r1 = Resource('a')
     r1.lastmod = '2012-01-02'
     r2 = Resource('a')
     r2.lastmod = '2012-01-02T00:00:00'
     r3 = Resource('a')
     r3.lastmod = '2012-01-02T00:00:00.00'
     self.assertEqual(r1.timestamp, r2.timestamp)
     self.assertEqual(r1.timestamp, r3.timestamp)
     self.assertEqual(r1, r1)
     self.assertEqual(r1, r2)
     self.assertEqual(r1, r3)
Ejemplo n.º 9
0
 def test1c_same(self):
     """Same with lastmod instead of direct timestamp"""
     r1 = Resource('a')
     r1.lastmod='2012-01-02'
     r2 = Resource('a')
     r2.lastmod='2012-01-02T00:00:00'
     r3 = Resource('a')
     r3.lastmod='2012-01-02T00:00:00.00'
     self.assertEqual( r1.timestamp, r2.timestamp )
     self.assertEqual( r1.timestamp, r3.timestamp )
     self.assertEqual( r1, r1 )
     self.assertEqual( r1, r2 )
     self.assertEqual( r1, r3 )
Ejemplo n.º 10
0
 def test5_lastmod_roundtrips(self):
     r = Resource("a")
     r.lastmod = "2012-03-14"
     self.assertEqual(r.lastmod, "2012-03-14T00:00:00Z")
     r.lastmod = "2012-03-14T00:00:00+00:00"
     print r.timestamp
     self.assertEqual(r.lastmod, "2012-03-14T00:00:00Z")
     r.lastmod = "2012-03-14T00:00:00-00:00"
     print r.timestamp
     self.assertEqual(r.lastmod, "2012-03-14T00:00:00Z")
     r.lastmod = "2012-03-14T18:37:36Z"
     print r.timestamp
     self.assertEqual(r.lastmod, "2012-03-14T18:37:36Z")
Ejemplo n.º 11
0
 def test_01_resource_str(self):
     r1 = Resource("a3")
     r1.lastmod = "2012-01-11T01:02:03"
     self.assertEqual(
         Sitemap().resource_as_xml(r1),
         "<?xml version='1.0' encoding='UTF-8'?>\n<url><loc>a3</loc><lastmod>2012-01-11T01:02:03</lastmod></url>",
     )
Ejemplo n.º 12
0
 def test_01_resource_str(self):
     r1 = Resource('a3')
     r1.lastmod = '2012-01-11T01:02:03Z'
     self.assertEqual(
         Sitemap().resource_as_xml(r1),
         "<?xml version='1.0' encoding='UTF-8'?>\n<url><loc>a3</loc><lastmod>2012-01-11T01:02:03Z</lastmod></url>"
     )
Ejemplo n.º 13
0
 def test01c_same(self):
     """Same with lastmod instead of direct timestamp"""
     r1 = Resource('a')
     r1lm = '2012-01-01T00:00:00Z'
     r1.lastmod = r1lm
     r2 = Resource('a')
     for r2lm in ('2012',
                  '2012-01',
                  '2012-01-01',
                  '2012-01-01T00:00Z',
                  '2012-01-01T00:00:00Z',
                  '2012-01-01T00:00:00.000000Z',
                  '2012-01-01T00:00:00.000000000000Z',
                  '2012-01-01T00:00:00.000000000001Z', #below resolution
                  '2012-01-01T00:00:00.00+00:00',
                  '2012-01-01T00:00:00.00-00:00',
                  '2012-01-01T02:00:00.00-02:00',
                  '2011-12-31T23:00:00.00+01:00'
                  ):
         r2.lastmod = r2lm
         self.assertEqual( r1.timestamp, r2.timestamp, ('%s (%f) == %s (%f)' % (r1lm,r1.timestamp,r2lm,r2.timestamp)) )
         self.assertEqual( r1, r2 )
Ejemplo n.º 14
0
 def test01c_same(self):
     """Same with lastmod instead of direct timestamp"""
     r1 = Resource('a')
     r1lm = '2012-01-01T00:00:00Z'
     r1.lastmod = r1lm
     r2 = Resource('a')
     for r2lm in (
             '2012',
             '2012-01',
             '2012-01-01',
             '2012-01-01T00:00Z',
             '2012-01-01T00:00:00Z',
             '2012-01-01T00:00:00.000000Z',
             '2012-01-01T00:00:00.000000000000Z',
             '2012-01-01T00:00:00.000000000001Z',  # below resolution
             '2012-01-01T00:00:00.00+00:00',
             '2012-01-01T00:00:00.00-00:00',
             '2012-01-01T02:00:00.00-02:00',
             '2011-12-31T23:00:00.00+01:00'):
         r2.lastmod = r2lm
         self.assertEqual(r1.timestamp, r2.timestamp,
                          ('%s (%f) == %s (%f)' %
                           (r1lm, r1.timestamp, r2lm, r2.timestamp)))
         self.assertEqual(r1, r2)
Ejemplo n.º 15
0
 def test1c_same(self):
     """Same with lastmod instead of direct timestamp"""
     r1 = Resource("a")
     r1.lastmod = "2012-01-02"
     r2 = Resource("a")
     for r2lm in (
         "2012-01-02",
         "2012-01-02T00:00",
         "2012-01-02T00:00:00",
         "2012-01-02 00:00:00",
         "2012-01-02T00:00:00.00",
         "2012-01-02T00:00:00.000000000000",
         "2012-01-02T00:00:00.000000000001",  # below resolution
         "2012-01-02T00:00:00.00Z",
         "2012-01-02T00:00:00.00+0000",
         "2012-01-02T00:00:00.00-0000",
         "2012-01-02T00:00:00.00+00:00",
         "2012-01-02T00:00:00.00-00:00",
         "2012-01-02T00:00:00.00+02:00",  # FIXME - TZ info currently ignored
     ):
         r2.lastmod = r2lm
         self.assertEqual(r1.timestamp, r2.timestamp)
         self.assertEqual(r1.timestamp, r2.timestamp, ("2012-01-02 == %s" % r2lm))
         self.assertEqual(r1, r2)
Ejemplo n.º 16
0
 def test_01_resource_str(self):
     r1 = Resource('a3')
     r1.lastmod='2012-01-11T01:02:03Z'
     self.assertEqual( Sitemap().resource_as_xml(r1), "<url><loc>a3</loc><lastmod>2012-01-11T01:02:03Z</lastmod></url>" )
Ejemplo n.º 17
0
 def test_01_resource_str(self):
     r1 = Resource('a3')
     r1.lastmod = '2012-01-11T01:02:03Z'
     self.assertEqual(
         Sitemap().resource_as_xml(r1),
         "<url><loc>a3</loc><lastmod>2012-01-11T01:02:03Z</lastmod></url>")