Example #1
0
 def test04_explore(self):
     e = Explorer()
     e.sitemap_name = 'tests/testdata/explore1/caps1.xml'
     with capture_stdout() as capturer:
         # IOError generated from attempt to read stdin
         e.fake_input = 'q'
         e.explore()
     self.assertTrue(re.search(r'resync-explorer done', capturer.result))
Example #2
0
 def test08_head_on_file(self):
     e = Explorer()
     r1 = e.head_on_file('tests/testdata/does_not_exist')
     self.assertEqual(r1.status_code, '404')
     r2 = e.head_on_file('tests/testdata/dir1/file_a')
     self.assertEqual(r2.status_code, '200')
     self.assertTrue(
         re.match(r'^\d\d\d\d\-\d\d\-\d\d', r2.headers['last-modified']))
     self.assertEqual(r2.headers['content-length'], 20)
Example #3
0
 def test08_head_on_file(self):
     e = Explorer()
     r1 = e.head_on_file('tests/testdata/does_not_exist')
     self.assertEqual(r1.status_code, '404')
     r2 = e.head_on_file('tests/testdata/dir1/file_a')
     self.assertEqual(r2.status_code, '200')
     self.assertTrue(re.match(r'^\d\d\d\d\-\d\d\-\d\d',
                              r2.headers['last-modified']))
     self.assertEqual(r2.headers['content-length'], 20)
Example #4
0
 def test05_explore_uri(self):
     e = Explorer()
     with capture_stdout() as capturer:
         e.fake_input = 'q'
         self.assertRaises(ExplorerQuit, e.explore_uri,
                           XResource('tests/testdata/explore1/caps1.xml'))
     self.assertTrue(re.search(r'Reading tests/testdata/explore1/caps1.xml',
                               capturer.result))
     self.assertTrue(re.search(r'Parsed capabilitylist document with 4 entries:',
                               capturer.result))
Example #5
0
 def test02_explore_show_summary(self):
     # Create dummy capabilities object and display
     cl = CapabilityList()
     cl.add( Resource('uri:resourcelist') )
     cl.add( Resource('uri:changelist') )
     e = Explorer()
     with capture_stdout() as capturer:
         e.explore_show_summary(cl,False,[])
     self.assertTrue( re.search(r'Parsed \(unknown capability\) document with 2 entries:',capturer.result) )
     self.assertTrue( re.search(r'\[1\] uri:changelist',capturer.result) )
     self.assertTrue( re.search(r'\[2\] uri:resourcelist',capturer.result) )
Example #6
0
 def test02_explore_show_summary(self):
     # Create dummy capabilities object and display
     cl = CapabilityList()
     cl.add(Resource('uri:resourcelist'))
     cl.add(Resource('uri:changelist'))
     e = Explorer()
     with capture_stdout() as capturer:
         e.explore_show_summary(cl, False, [])
     self.assertTrue(
         re.search(
             r'Parsed \(unknown capability\) document with 2 entries:',
             capturer.result))
     self.assertTrue(re.search(r'\[1\] uri:changelist', capturer.result))
     self.assertTrue(re.search(r'\[2\] uri:resourcelist', capturer.result))
Example #7
0
 def test07_explore_show_head(self):
     e = Explorer()
     # file that exists with matching
     with capture_stdout() as capturer:
         e.explore_show_head(uri='tests/testdata/dir1/file_a',
                             check_headers={
                                 'content-length': 20,
                                 'unknown': 'abc'
                             })
     self.assertTrue(
         re.search(r'HEAD tests/testdata/dir1/file_a', capturer.result))
     self.assertTrue(
         re.search(r'content-length: 20 MATCHES EXPECTED VALUE',
                   capturer.result))
     # same file, bad header check
     with capture_stdout() as capturer:
         e.explore_show_head('tests/testdata/dir1/file_a',
                             check_headers={'content-length': 99})
     self.assertTrue(
         re.search(r'HEAD tests/testdata/dir1/file_a', capturer.result))
     self.assertTrue(
         re.search(r'content-length: 20 EXPECTED 99', capturer.result))
     # file that does not exist
     with capture_stdout() as capturer:
         e.explore_show_head('tests/testdata/does_not_exist')
     self.assertTrue(
         re.search(r'HEAD tests/testdata/does_not_exist', capturer.result))
     self.assertTrue(re.search(r'status: 404', capturer.result))
Example #8
0
 def test09_allowed_entries(self):
     e = Explorer()
     self.assertEqual(e.allowed_entries('capabilitylistindex'), [])
     self.assertEqual(e.allowed_entries('resourcelistindex'),
                      ['resourcelist'])
     self.assertEqual(e.allowed_entries('changelist-archive'),
                      ['changelist'])
     self.assertEqual(e.allowed_entries('description'), ['capabilitylist'])
     self.assertEqual(len(e.allowed_entries('capabilitylist')), 8)
     self.assertEqual(e.allowed_entries('unknown'), [])
Example #9
0
 def test07_explore_show_head(self):
     e = Explorer()
     # file that exists with matching
     with capture_stdout() as capturer:
         e.explore_show_head(uri='tests/testdata/dir1/file_a',
                             check_headers={'content-length': 20,
                                            'unknown': 'abc'})
     self.assertTrue(
         re.search(r'HEAD tests/testdata/dir1/file_a', capturer.result))
     self.assertTrue(
         re.search(r'content-length: 20 MATCHES EXPECTED VALUE', capturer.result))
     # same file, bad header check
     with capture_stdout() as capturer:
         e.explore_show_head('tests/testdata/dir1/file_a',
                             check_headers={'content-length': 99})
     self.assertTrue(
         re.search(r'HEAD tests/testdata/dir1/file_a', capturer.result))
     self.assertTrue(
         re.search(r'content-length: 20 EXPECTED 99', capturer.result))
     # file that does not exist
     with capture_stdout() as capturer:
         e.explore_show_head('tests/testdata/does_not_exist')
     self.assertTrue(
         re.search(r'HEAD tests/testdata/does_not_exist', capturer.result))
     self.assertTrue(re.search(r'status: 404', capturer.result))
Example #10
0
 def test09_allowed_entries(self):
     e = Explorer()
     self.assertEqual(e.allowed_entries('capabilitylistindex'), [])
     self.assertEqual(e.allowed_entries(
         'resourcelistindex'), ['resourcelist'])
     self.assertEqual(e.allowed_entries(
         'changelist-archive'), ['changelist'])
     self.assertEqual(e.allowed_entries('description'), ['capabilitylist'])
     self.assertEqual(len(e.allowed_entries('capabilitylist')), 8)
     self.assertEqual(e.allowed_entries('unknown'), [])
Example #11
0
 def test04_explore(self):
     e = Explorer()
     e.sitemap_name = 'tests/testdata/explore1/caps1.xml'
     with capture_stdout() as capturer:
         # IOError generated from attempt to read stdin
         e.fake_input = 'q'
         e.explore()
     self.assertTrue(re.search(r'resync-explorer done', capturer.result))
Example #12
0
 def test01_create(self):
     # dumb test that we can create Exporer object
     e = Explorer()
     self.assertTrue(e)
Example #13
0
 def test10_expand_relative_uri(self):
     e = Explorer()
     with capture_stdout() as capturer:
         uri = e.expand_relative_uri('https://example.org/ctx', 'abc')
     self.assertEqual(uri, 'https://example.org/abc')
     self.assertTrue(re.search(r'expanded relative URI', capturer.result))
Example #14
0
 def test10_expand_relative_uri(self):
     e = Explorer()
     with capture_stdout() as capturer:
         uri = e.expand_relative_uri('https://example.org/ctx', 'abc')
     self.assertEqual(uri, 'https://example.org/abc')
     self.assertTrue(re.search(r'expanded relative URI', capturer.result))