Esempio n. 1
0
 def test20_parse_document(self):
     # Key property of the parse_document() method is that it parses the
     # document and identifies its type
     c = Client()
     with capture_stdout() as capturer:
         c.sitemap_name='tests/testdata/examples_from_spec/resourcesync_ex_1.xml'
         c.parse_document()
     self.assertTrue( re.search(r'Parsed resourcelist document with 2 entries',capturer.result) )
     with capture_stdout() as capturer:
         c.sitemap_name='tests/testdata/examples_from_spec/resourcesync_ex_17.xml'
         c.parse_document()
     self.assertTrue( re.search(r'Parsed resourcedump document with 3 entries',capturer.result) )
     with capture_stdout() as capturer:
         c.sitemap_name='tests/testdata/examples_from_spec/resourcesync_ex_19.xml'
         c.parse_document()
     self.assertTrue( re.search(r'Parsed changelist document with 4 entries',capturer.result) )
     with capture_stdout() as capturer:
         c.sitemap_name='tests/testdata/examples_from_spec/resourcesync_ex_22.xml'
         c.parse_document()
     self.assertTrue( re.search(r'Parsed changedump document with 3 entries',capturer.result) )
     # Document that doesn't exist
     c.sitemap_name='/does_not_exist'
     self.assertRaises( ClientFatalError, c.parse_document )
     # and verbose with truncation...
     with capture_stdout() as capturer:
         c.verbose = True
         c.sitemap_name = 'tests/testdata/examples_from_spec/resourcesync_ex_1.xml'
         c.max_sitemap_entries = 1 
         c.parse_document()
     self.assertTrue( re.search(r'Showing first 1 entries', capturer.result ) )
     self.assertTrue( re.search(r'\[0\] ', capturer.result ) )
     self.assertFalse( re.search(r'\[1\] ', capturer.result ) )
Esempio n. 2
0
 def test49_read_reference_resource_list(self):
     c = Client()
     with capture_stdout() as capturer:
         rl = c.read_reference_resource_list('tests/testdata/examples_from_spec/resourcesync_ex_1.xml')
     self.assertEqual( len(rl), 2 )
     self.assertEqual( '', capturer.result )
     c.verbose = True
     with capture_stdout() as capturer:
         rl = c.read_reference_resource_list('tests/testdata/examples_from_spec/resourcesync_ex_1.xml')
     self.assertEqual( len(rl), 2 )
     self.assertTrue( re.search(r'http://example.com/res2', capturer.result) )
     c.verbose = True
     c.max_sitemap_entries = 1
     with capture_stdout() as capturer:
         rl = c.read_reference_resource_list('tests/testdata/examples_from_spec/resourcesync_ex_1.xml')
     self.assertEqual( len(rl), 2 )
     self.assertTrue( re.search(r'http://example.com/res1', capturer.result) )
     self.assertTrue( re.search(r'Showing first 1 entries', capturer.result) )
     self.assertFalse( re.search(r'http://example.com/res2', capturer.result) )
Esempio n. 3
0
 def test20_parse_document(self):
     # Key property of the parse_document() method is that it parses the
     # document and identifies its type
     c = Client()
     with capture_stdout() as capturer:
         c.sitemap_name = 'tests/testdata/examples_from_spec/resourcesync_ex_1.xml'
         c.parse_document()
     self.assertTrue(
         re.search(r'Parsed resourcelist document with 2 entries',
                   capturer.result))
     with capture_stdout() as capturer:
         c.sitemap_name = 'tests/testdata/examples_from_spec/resourcesync_ex_17.xml'
         c.parse_document()
     self.assertTrue(
         re.search(r'Parsed resourcedump document with 3 entries',
                   capturer.result))
     with capture_stdout() as capturer:
         c.sitemap_name = 'tests/testdata/examples_from_spec/resourcesync_ex_19.xml'
         c.parse_document()
     self.assertTrue(
         re.search(r'Parsed changelist document with 4 entries',
                   capturer.result))
     with capture_stdout() as capturer:
         c.sitemap_name = 'tests/testdata/examples_from_spec/resourcesync_ex_22.xml'
         c.parse_document()
     self.assertTrue(
         re.search(r'Parsed changedump document with 3 entries',
                   capturer.result))
     # Document that doesn't exist
     c.sitemap_name = '/does_not_exist'
     self.assertRaises(ClientFatalError, c.parse_document)
     # and verbose with truncation...
     with capture_stdout() as capturer:
         c.verbose = True
         c.sitemap_name = 'tests/testdata/examples_from_spec/resourcesync_ex_1.xml'
         c.max_sitemap_entries = 1
         c.parse_document()
     self.assertTrue(re.search(r'Showing first 1 entries', capturer.result))
     self.assertTrue(re.search(r'\[0\] ', capturer.result))
     self.assertFalse(re.search(r'\[1\] ', capturer.result))
Esempio n. 4
0
 def test49_read_reference_resource_list(self):
     c = Client()
     with capture_stdout() as capturer:
         rl = c.read_reference_resource_list(
             'tests/testdata/examples_from_spec/resourcesync_ex_1.xml')
     self.assertEqual(len(rl), 2)
     self.assertEqual('', capturer.result)
     c.verbose = True
     with capture_stdout() as capturer:
         rl = c.read_reference_resource_list(
             'tests/testdata/examples_from_spec/resourcesync_ex_1.xml')
     self.assertEqual(len(rl), 2)
     self.assertTrue(re.search(r'http://example.com/res2', capturer.result))
     c.verbose = True
     c.max_sitemap_entries = 1
     with capture_stdout() as capturer:
         rl = c.read_reference_resource_list(
             'tests/testdata/examples_from_spec/resourcesync_ex_1.xml')
     self.assertEqual(len(rl), 2)
     self.assertTrue(re.search(r'http://example.com/res1', capturer.result))
     self.assertTrue(re.search(r'Showing first 1 entries', capturer.result))
     self.assertFalse(re.search(r'http://example.com/res2',
                                capturer.result))