Patrick Rein uploaded a new version of NetworkTests to project The Trunk:
http://source.squeak.org/trunk/NetworkTests-pre.54.mcz ==================== Summary ==================== Name: NetworkTests-pre.54 Author: pre Time: 7 December 2017, 12:04:46.893608 pm UUID: 366056e6-74fb-f04b-a77d-20e1be317b8b Ancestors: NetworkTests-pre.53 Updates the tests for MailMessage attachments to take correct care of the content-type and the file name. Also fixes a MailDateAndTimeTest. =============== Diff against NetworkTests-pre.53 =============== Item was changed: ----- Method: MailDateAndTimeTest>>testBasicDate (in category 'as yet unclassified') ----- testBasicDate | date | + date := DateAndTime year: 2017 month: 2 day: 3 hour: 0 minute: 0 second: 0 offset: (Duration hours: 0). + self assert: 'Fri, 03 Feb 2017 00:00:00 +0000' equals: date asMailMessageString! - date := DateAndTime year: 2017 month: 2 day: 3. - self assert: 'Fri, 03 Feb 2017 00:00:00 +0200' equals: date asMailMessageString! Item was added: + ----- Method: MailMessageTest>>testAttachmentsGetTheirOwnContentType (in category 'testing') ----- + testAttachmentsGetTheirOwnContentType + + | message contentType | + message := MailMessage empty + addAttachmentFrom: 'abcxxx' readStream withName: 'aTestingAttachment.pdf'; + body: ((MIMEDocument contentType: 'application/foo' content: 'This is the main text' squeakToUtf8) + charset: 'utf-8'; yourself). + + self assert: message attachments size equals: 1. + + contentType := (message attachments first fieldNamed: 'content-type' ifAbsent: [self fail]) + mainValue. + self assert: contentType equals: 'application/pdf'. + ! Item was changed: ----- Method: MailMessageTest>>testAttachmentsReturnsTheAttachments (in category 'testing') ----- testAttachmentsReturnsTheAttachments | fileName message | message := MailMessage empty addAttachmentFrom: 'abcxxx' readStream withName: 'aTestingAttachment'; body: ((MIMEDocument contentType: 'application/foo' content: 'This is the main text' squeakToUtf8) charset: 'utf-8'; yourself). + self assert: 1 equals: message attachments size. - self assert: message attachments size equals: 1. fileName := (message attachments first fieldNamed: 'content-disposition' ifAbsent: [self fail]) parameterAt: 'filename' ifAbsent: ['']. + self assert: fileName equals: '"aTestingAttachment"'. + + fileName := (message attachments first fieldNamed: 'content-type' ifAbsent: [self fail]) + parameterAt: 'name' ifAbsent: ['']. + + self assert: fileName equals: '"aTestingAttachment"'.! - self assert: fileName equals: 'aTestingAttachment'. - ! Item was added: + ----- Method: MailMessageTest>>testAttachmentsWorkWithVeryLongFilenames (in category 'testing') ----- + testAttachmentsWorkWithVeryLongFilenames + + | fileName message | + message := MailMessage empty + addAttachmentFrom: 'abcxxx' readStream withName: 'aTestingAttachmentWithAVeryVeryVeryVeryVeryVeryVeryVeryLongName.file'; + body: ((MIMEDocument contentType: 'application/foo' content: 'This is the main text' squeakToUtf8) + charset: 'utf-8'; yourself). + + self assert: message attachments size equals: 1. + + fileName := (message attachments first fieldNamed: 'content-disposition' ifAbsent: [self fail]) + parameterAt: 'filename' ifAbsent: ['']. + + self assert: '"aTestingAttachmentWithAVeryVeryVeryVeryVeryVeryVeryVeryLongName.file"' equals: fileName + ! Item was changed: ----- Method: MailMessageTest>>testCreateAReplyForReplyTos (in category 'testing') ----- testCreateAReplyForReplyTos | replyMail startMail | startMail := self fixtureMail setField: 'reply-to' toString: '[hidden email], [hidden email]'; yourself. replyMail := MailMessage replyFor: startMail. + self + assert: {'[hidden email]' . '[hidden email]'} asSet + equals: ((replyMail to findTokens: ',') collect: [:e | e withBlanksTrimmed]) asSet.! - self assert: '[hidden email], [hidden email]' equals: replyMail to.! |
Free forum by Nabble | Edit this page |