Beispiel #1
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')
Beispiel #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')
Beispiel #3
0
    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' )
Beispiel #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' )
Beispiel #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)
Beispiel #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(), '')
Beispiel #7
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 = 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(), '')
Beispiel #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')
Beispiel #9
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)
Beispiel #10
0
 def _makeOne(self, id, *args, **kw):
     return self.site._setObject( id, Link(id, *args, **kw) )
Beispiel #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' )
Beispiel #12
0
 def test_Empty( self ):
     d = Link( 'foo' )
     self.failUnless( d.Title() == '' )
     self.failUnless( d.Description() == '' )
     self.failUnless( d.getRemoteUrl() == '' )
Beispiel #13
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' )
Beispiel #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(), '' )
Beispiel #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')