示例#1
0
文件: test_Link.py 项目: goschtl/zope
 def test_Empty( self ):
     d = Link( 'foo' )
     self.assertEqual( d.Title(), '' )
     self.assertEqual( d.Description(), '' )
     self.assertEqual( d.getRemoteUrl(), '' )
     self.assertEqual( d.format, 'text/url' )
     self.assertEqual( d.URL_FORMAT, 'text/url')
示例#2
0
 def test_Empty(self):
     d = Link('foo')
     self.assertEqual(d.Title(), '')
     self.assertEqual(d.Description(), '')
     self.assertEqual(d.getRemoteUrl(), '')
     self.assertEqual(d.format, 'text/url')
     self.assertEqual(d.URL_FORMAT, 'text/url')
示例#3
0
文件: test_Link.py 项目: goschtl/zope
    def test_StructuredText_w_Continuation( self ):

        d = Link('foo')
        d._writeFromPUT( body=STX_W_CONTINUATION )
        rnlinesplit = re.compile( r'\r?\n?' )
        desc_lines = rnlinesplit.split( d.Description() )
        
        self.assertEqual( d.Title(), 'Zope Community' )
        self.assertEqual( desc_lines[0]
                        , 'Link to the Zope Community website,' )
        self.assertEqual( desc_lines[1]
                        , 'including hundreds of contributed Zope products.' )
        self.assertEqual( len(d.Subject()), 3 )
        self.assertEqual( d.getRemoteUrl(), 'http://www.zope.org' )
示例#4
0
 def test_StructuredText( self ):
     d = Link('foo')
     d._writeFromPUT( body=BASIC_STRUCTUREDTEXT )
     
     self.failUnless( d.Title() == 'Zope Community' )
     self.failUnless(
             d.Description() == 'Link to the Zope Community website.' )
     self.failUnless( len(d.Subject()) == 3 )
     self.failUnless( d.getRemoteUrl() == 'http://www.zope.org' )
示例#5
0
 def canonTest(self, table):
     for orig, wanted in table.items():
         # test with constructor
         d = Link('foo', remote_url=orig)
         self.assertEqual(d.getRemoteUrl(), wanted)
         # test with edit method too
         d = Link('bar')
         d.edit(orig)
         self.assertEqual(d.getRemoteUrl(), wanted)
示例#6
0
    def test_Empty( self ):
        d = Link( 'foo' )
        self.assertEqual( d.Title(), '' )
        self.assertEqual( d.Description(), '' )
        self.assertEqual( d.getRemoteUrl(), '' )
        self.assertEqual( d.format, 'text/url' )
        self.assertEqual( d.URL_FORMAT, 'text/url')

        d = self._makeOne('foo', remote_url='bar')
        d.edit('')
        self.assertEqual(d.getRemoteUrl(), '')

        d = self._makeOne('foo', remote_url='http://')
        self.assertEqual(d.getRemoteUrl(), '')

        d = self._makeOne('foo', remote_url='http:')
        self.assertEqual(d.getRemoteUrl(), '')
示例#7
0
文件: test_Link.py 项目: goschtl/zope
    def test_Empty( self ):
        d = Link( 'foo' )
        self.assertEqual( d.Title(), '' )
        self.assertEqual( d.Description(), '' )
        self.assertEqual( d.getRemoteUrl(), '' )
        self.assertEqual( d.format, 'text/url' )
        self.assertEqual( d.URL_FORMAT, 'text/url')

        d = Link('foo', remote_url='bar')
        d.edit('')
        self.assertEqual(d.getRemoteUrl(), '')

        d = Link('foo', remote_url='http://')
        self.assertEqual(d.getRemoteUrl(), '')

        d = Link('foo', remote_url='http:')
        self.assertEqual(d.getRemoteUrl(), '')
示例#8
0
    def test_StructuredText_w_Continuation(self):

        d = Link('foo')
        d._writeFromPUT(body=STX_W_CONTINUATION)
        rnlinesplit = compile(r'\r?\n?')
        desc_lines = rnlinesplit.split(d.Description())

        self.assertEqual(d.Title(), 'Zope Community')
        self.assertEqual(desc_lines[0], 'Link to the Zope Community website,')
        self.assertEqual(desc_lines[1],
                         'including hundreds of contributed Zope products.')
        self.assertEqual(len(d.Subject()), 3)
        self.assertEqual(d.getRemoteUrl(), 'http://www.zope.org')
示例#9
0
文件: test_Link.py 项目: goschtl/zope
 def canonTest(self, table):
     for orig, wanted in table.items():
         # test with constructor
         d = Link('foo', remote_url=orig)
         self.assertEqual(d.getRemoteUrl(), wanted)
         # test with edit method too
         d = Link('bar')
         d.edit(orig)
         self.assertEqual(d.getRemoteUrl(), wanted)
示例#10
0
 def _makeOne(self, id, *args, **kw):
     return self.site._setObject( id, Link(id, *args, **kw) )
示例#11
0
    def test_fixupMissingScheme( self ):
        d = Link( 'foo' )
        d.edit( 'http://foo.com' )
        self.failUnless( d.getRemoteUrl() == 'http://foo.com' )

        d = Link( 'bar' )
        d.edit( '//bar.com' )
        self.failUnless( d.getRemoteUrl() == 'http://bar.com' )

        d = Link( 'baz' )
        d.edit( 'baz.com' )
        self.failUnless( d.getRemoteUrl() == 'http://baz.com' )
示例#12
0
 def test_Empty( self ):
     d = Link( 'foo' )
     self.failUnless( d.Title() == '' )
     self.failUnless( d.Description() == '' )
     self.failUnless( d.getRemoteUrl() == '' )
示例#13
0
文件: test_Link.py 项目: goschtl/zope
    def test_fixupMissingScheme( self ):
        d = Link( 'foo' )
        d.edit( 'http://foo.com' )
        self.assertEqual( d.getRemoteUrl(), 'http://foo.com' )

        d = Link( 'bar' )
        d.edit( '//bar.com' )
        self.assertEqual( d.getRemoteUrl(), 'http://bar.com' )

        d = Link( 'baz' )
        d.edit( 'baz.com' )
        self.assertEqual( d.getRemoteUrl(), 'http://baz.com' )
示例#14
0
 def test_PutWithoutMetadata(self):
     d = Link( 'foo' )
     d._writeFromPUT( body='' )
     self.assertEqual( d.Title(), '' )
     self.assertEqual( d.Format(), 'text/url' )
     self.assertEqual( d.Description(), '' )
     self.assertEqual( d.Subject(), () )
     self.assertEqual( d.Contributors(), () )
     self.assertEqual( d.EffectiveDate(), 'None' )
     self.assertEqual( d.ExpirationDate(), 'None' )
     self.assertEqual( d.Language(), '' )
     self.assertEqual( d.Rights(), '' )
示例#15
0
    def test_fixupMissingScheme(self):
        d = Link('foo')
        d.edit('http://foo.com')
        self.assertEqual(d.getRemoteUrl(), 'http://foo.com')

        d = Link('bar')
        d.edit('//bar.com')
        self.assertEqual(d.getRemoteUrl(), 'http://bar.com')

        d = Link('baz')
        d.edit('baz.com')
        self.assertEqual(d.getRemoteUrl(), 'http://baz.com')