コード例 #1
0
ファイル: test_explorer.py プロジェクト: resync/resync
 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))
コード例 #2
0
ファイル: test_explorer.py プロジェクト: giorgiobasile/resync
 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)
コード例 #3
0
ファイル: test_explorer.py プロジェクト: resync/resync
 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)
コード例 #4
0
ファイル: test_explorer.py プロジェクト: ramonmassip/resync
 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))
コード例 #5
0
ファイル: test_explorer.py プロジェクト: EHRI/resync
 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) )
コード例 #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))
コード例 #7
0
ファイル: test_explorer.py プロジェクト: giorgiobasile/resync
 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))
コード例 #8
0
ファイル: test_explorer.py プロジェクト: giorgiobasile/resync
 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'), [])
コード例 #9
0
ファイル: test_explorer.py プロジェクト: resync/resync
 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))
コード例 #10
0
ファイル: test_explorer.py プロジェクト: resync/resync
 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'), [])
コード例 #11
0
ファイル: test_explorer.py プロジェクト: giorgiobasile/resync
 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))
コード例 #12
0
 def test01_create(self):
     # dumb test that we can create Exporer object
     e = Explorer()
     self.assertTrue(e)
コード例 #13
0
ファイル: test_explorer.py プロジェクト: giorgiobasile/resync
 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))
コード例 #14
0
ファイル: test_explorer.py プロジェクト: resync/resync
 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))