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)
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' )
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')
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')
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(), '')
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' )
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(), '' )
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')
def _makeOne(self, id, *args, **kw): return self.site._setObject( id, Link(id, *args, **kw) )
def test_Empty( self ): d = Link( 'foo' ) self.failUnless( d.Title() == '' ) self.failUnless( d.Description() == '' ) self.failUnless( d.getRemoteUrl() == '' )