Permalink
Browse files

Flesh out a couple more scenarios for reading and parsing the emails

  • Loading branch information...
1 parent df67c81 commit 1f4c5b762b94e2b71c68078bd223701cc143d0ad @rtyler committed May 8, 2011
Showing with 187 additions and 3 deletions.
  1. +2 −2 features/parse_from.feature
  2. +9 −0 features/read_email.feature
  3. +16 −1 features/step_definitions/parser_steps.rb
  4. +160 −0 fixture/samplemail.txt
View
4 features/parse_from.feature
@@ -1,7 +1,7 @@
-Feature: Parse a readable name from an email
+Feature: Parse a readable name from a "From" header
In order to display a pretty name
As a mail recipient
- I want to parse a raw mail for "From" headers"
+ I want to parse a "From" header
Scenario: Full name in the header
Given a header that reads {From: John Doe <john@example.com>}
View
9 features/read_email.feature
@@ -0,0 +1,9 @@
+Feature: Parse a full email
+ In order to parse a from header from a mail
+ As a mail recipient
+ I want to parse a raw mail for From headers
+
+ Scenario: Read an email file
+ Given a sample email file called "fixture/samplemail.txt"
+ When the file is parsed for a from header
+ Then the from header should be "From: Lance Albertson <lance@osuosl.org>"
View
17 features/step_definitions/parser_steps.rb
@@ -1,14 +1,29 @@
require 'notifier'
+Before do
+ @parser = MailParser.new
+end
+
Given /^a header that reads \{(.*?)\}$/ do |header|
@from = header
end
When /^parsed$/ do
- @parsed = parse_from_header(@from)
+ @parsed = @parser.parse_from_header(@from)
end
Then /^I should see "([^"]*)"$/ do |result|
@parsed.should == result
end
+Given /^a sample email file called "([^"]*)"$/ do |filename|
+ @sample_file = filename
+end
+
+When /^the file is parsed for a from header$/ do
+ @header = @parser.load_file(@sample_file)
+end
+
+Then /^the from header should be "([^"]*)"$/ do |header|
+ @header.should == header
+end
View
160 fixture/samplemail.txt
@@ -0,0 +1,160 @@
+Return-Path: <hosting-bounces@osuosl.org>
+X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on backup01.geekisp.com
+X-Spam-Level:
+X-Spam-Status: No, score=-2.7 required=5.0 tests=AWL,BAYES_00,
+ RCVD_IN_DNSWL_MED,RDNS_NONE,SPF_PASS autolearn=ham version=3.3.1
+Delivered-To: monkeypox.org-tyler@monkeypox.org
+Received: (qmail 26239 invoked by uid 1003); 27 Apr 2011 21:57:47 -0000
+Received: from unknown (HELO fraxinus.osuosl.org) (140.211.166.137)
+ by mail.geekisp.com with SMTP; 27 Apr 2011 21:57:47 -0000
+Received: from localhost (localhost [127.0.0.1])
+ by fraxinus.osuosl.org (Postfix) with ESMTP id A3624FFB95;
+ Wed, 27 Apr 2011 21:57:46 +0000 (UTC)
+X-Virus-Scanned: amavisd-new at osuosl.org
+Received: from fraxinus.osuosl.org ([127.0.0.1])
+ by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)
+ with ESMTP id Ry5GRgd1RkD4; Wed, 27 Apr 2011 21:57:44 +0000 (UTC)
+Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34])
+ by fraxinus.osuosl.org (Postfix) with ESMTP id 2AC32101B92;
+ Wed, 27 Apr 2011 21:57:44 +0000 (UTC)
+X-Original-To: hosting@osuosl.org
+Delivered-To: hosting@osuosl.org
+Received: from fraxinus.osuosl.org (fraxinus.osuosl.org [140.211.166.137])
+ by ash.osuosl.org (Postfix) with ESMTP id EBD888F74B
+ for <hosting@osuosl.org>; Wed, 27 Apr 2011 21:57:42 +0000 (UTC)
+Received: from localhost (localhost [127.0.0.1])
+ by fraxinus.osuosl.org (Postfix) with ESMTP id DD028101BA3
+ for <hosting@osuosl.org>; Wed, 27 Apr 2011 21:57:42 +0000 (UTC)
+X-Virus-Scanned: amavisd-new at osuosl.org
+Received: from fraxinus.osuosl.org ([127.0.0.1])
+ by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)
+ with ESMTP id Ena9HMeypIIC for <hosting@osuosl.org>;
+ Wed, 27 Apr 2011 21:57:41 +0000 (UTC)
+Received: from [140.211.167.27] (zephyr.osuosl.org [140.211.167.27])
+ by fraxinus.osuosl.org (Postfix) with ESMTPSA id BF3BD101AD1
+ for <hosting@osuosl.org>; Wed, 27 Apr 2011 21:57:41 +0000 (UTC)
+Message-ID: <4DB89145.2070603@osuosl.org>
+Date: Wed, 27 Apr 2011 14:57:25 -0700
+From: Lance Albertson <lance@osuosl.org>
+User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US;
+ rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8
+MIME-Version: 1.0
+To: hosting@osuosl.org
+X-Enigmail-Version: 1.1.2
+Subject: [Hosting] MAINTENANCE: production ganeti cluster rebalancing
+X-BeenThere: hosting@osuosl.org
+X-Mailman-Version: 2.1.12
+Precedence: list
+List-Id: <hosting.osuosl.org>
+List-Unsubscribe: <http://lists.osuosl.org/mailman/options/hosting>,
+ <mailto:hosting-request@osuosl.org?subject=unsubscribe>
+List-Archive: <http://lists.osuosl.org/mailman/private/hosting>
+List-Post: <mailto:hosting@osuosl.org>
+List-Help: <mailto:hosting-request@osuosl.org?subject=help>
+List-Subscribe: <http://lists.osuosl.org/mailman/listinfo/hosting>,
+ <mailto:hosting-request@osuosl.org?subject=subscribe>
+Content-Type: multipart/mixed; boundary="===============0793342593321112896=="
+Sender: hosting-bounces@osuosl.org
+Errors-To: hosting-bounces@osuosl.org
+
+This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
+--===============0793342593321112896==
+Content-Type: multipart/signed; micalg=pgp-sha1;
+ protocol="application/pgp-signature";
+ boundary="------------enig77EB91112279ADC5A4E09404"
+
+This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
+--------------enig77EB91112279ADC5A4E09404
+Content-Type: text/plain; charset=ISO-8859-1
+Content-Transfer-Encoding: quoted-printable
+
+We added a new server to our main production ganeti virtualization
+cluster and I need to rebalance the cluster. I'm also implementing a new
+feature so that the kvm processes will now run as an individual non-root
+user.
+
+I don't plan on the rebalancing to cause any outage on your end since
+we'll be doing a live migration between the nodes. If anything the VM
+may pause for a moment. There is a small possibility something may go
+wrong during the migration but I haven't encountered that recently. I'm
+planning on doing this 10 VMs a day for the next couple of days so that
+I can minimize the potential impact.
+
+Please let me know if you what to reschedule your outage. I plan to do
+them during the workday PDT time (somewhere between 9am-5pm). If you
+have any questions please let me know on IRC or via email.
+
+Thanks!
+
+Here's the schedule for the migrations:
+
+Today (4/27)
+ 1. openmrs.osuosl.org
+ 2. stagingvm.drupal.org
+ 3. scratchvm.drupal.org
+ 4. openmrs-java.osuosl.org
+ 5. connectopensource.osuosl.org
+ 6. hudson-java.osuosl.org
+ 7. myrtle.osuosl.org
+ 8. stross.freenode.net
+ 9. yum.osuosl.org
+10. qemu.osuosl.org
+
+Thursday (4/28)
+11. openclipfont.osuosl.org
+12. mozdev-stats.osuosl.org
+13. aqsis1.osuosl.org
+14. inkscape.osuosl.org
+15. twist.osuosl.org
+16. arklinuxvm.osuosl.org
+17. deluge.osuosl.org
+18. maple.osuosl.org
+19. dotkde.osuosl.org
+20. musicbrainzvm.osuosl.org
+
+Friday (4/29)
+21. dspace.osuosl.org
+22. bigleaf.osuosl.org
+23. chiral.oftc.net
+24. parrotvm.osuosl.org
+25. busybox.osuosl.org
+26. pine.osuosl.org
+27. darcsvm.osuosl.org
+28. crisiscommons1.osuosl.org
+29. crisiscommons-web.osuosl.org
+30. aqsis2.osuosl.org
+
+--=20
+Lance Albertson
+Systems Administrator / Architect Open Source Lab
+Network Services Oregon State University
+
+
+--------------enig77EB91112279ADC5A4E09404
+Content-Type: application/pgp-signature; name="signature.asc"
+Content-Description: OpenPGP digital signature
+Content-Disposition: attachment; filename="signature.asc"
+
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.4.10 (GNU/Linux)
+Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
+
+iD8DBQFNuJFFQW+hXSf0t0IRAsbcAKCiVJSvj4JaQ5VsMyDui4AgjoPDpwCfRBm4
+eBnaSMlknk1AXw7z5M3NKaI=
+=vB80
+-----END PGP SIGNATURE-----
+
+--------------enig77EB91112279ADC5A4E09404--
+
+--===============0793342593321112896==
+Content-Type: text/plain; charset="us-ascii"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Content-Disposition: inline
+
+_______________________________________________
+Hosting mailing list
+Hosting@osuosl.org
+http://lists.osuosl.org/mailman/listinfo/hosting
+
+--===============0793342593321112896==--

0 comments on commit 1f4c5b7

Please sign in to comment.