Skip to content
This repository
Browse code

Merge pull request #23 from minio-sk/portable-tests

Make the tests portable
  • Loading branch information...
commit 28fef697f539dc957d935163d67004aba2b615e1 2 parents 085f5f6 + 6b5901e
Jeremy Ashkenas authored October 03, 2011
26  test/fixtures/corrosion/corrosion_1.txt
... ...
@@ -1,26 +0,0 @@
1  
-  901 Locust Street Suite 462
2  
-Qi' Kansas City, MO 164106-2641
3  
-Pipetine and
4  
-Hazardous Materials Satety
5  
-Administration
6  
-LETTER
7  
-CERTIFIED MAIL - RETURN RECEIPT REQUESTED
8  
-January 21, 2010
9  
-Mr. Terry McGill, President
10  
-Enbridge Energy Partners, L.P.
11  
-1100 Louisiana, Suite 3300 -
12  
-Houston, Texas 77002
13  
-CPF 
14  
-Dear Mr. McGill:
15  
-On October 6-8, 2008, October 28, 2008, and January 21-22, 2009, a representative of the
16  
-Pipeline and Hazardous Materials Safety Administration (PHMSA) pursuant to Chapter 601 of
17  
-49 United States Code inspected your facilities associated With the Griffith Unit in Griffith,
18  
-Indiana, and surrounding locations.
19  
-As a result ofthe inspection, it appears that you have committed a probable violation of the
20  
-Pipeline Safety Regulations, Title 49, Code of Federal Regulations. The items inspected and
21  
-the probable violation(s) are:
22  
-1. 195.579 What must I do to mitigate internal corrosion?
23  
-
24  
-Inhibitors. If you use corrosion inhibitors to mitigate internal corrosion, you
25  
-must--
26  
-
41  test/fixtures/corrosion/corrosion_2.txt
... ...
@@ -1,41 +0,0 @@
1  
-(1) Use inhibitors in sufficient quantity to protect the entire part of the pipeline
2  
-system that the inhibitors are designed to protect;
3  
-(2) Use coupons or other monitoring equipment to determine the effectiveness oi'
4  
-the inhibitors in mitigating internal corrosion; and
5  
-(3) Examine the coupons or other monitoring equipment at least twice each
6  
-calendar year, but with intervals not exceeding 7 1/2 months.
7  
-Internal corrosion monitoring was _discontinued on the tive hydrogen permeation monitors
8  
-(Beta Foils) installed on Line 6B. Two manually-interrogated monitors were discontinued in
9  
-May 2006. One remotely-interrogated monitor was discontinued in January 2006, and the
10  
-other two remotely-interrogated monitors were discontinued in October 2007. Enbridge
11  
-representatives stated the monitoring was discontinued due to
12  
-"communication/instrumentation problems."
13  
-Enbridge is in the process of implementing an alternative method of internal corrosion
14  
-monitoring on Line 6B utilizing a technology referred to as Electrical Resistance Tomography
15  
-(FSM-IT), however, it is not expected to be implemented on Line 6B until sometime during
16  
-the iirst half of 2010. In the interim, Enbridge provided the following information as
17  
-demonstration that the intemal corrosion threat is being properly managed:
18  
-^0 a comprehensive report related to the internal corrosion mitigation and
19  
-monitoring program for their heavy oil pipeline system
20  
-repair sleeve installations (which require circumferential non-destructive
21  
-testing)
22  
-6 inspection of the Line 6B Pig Sending Trap at Griffith Station (which included
23  
-ultrasonic inspection of the trap iloor between the 5:00 and 7:00 positions)
24  
-^0 detailed pipe examinations at in-line inspection indications
25  
-^0 records for a weight loss coupon at the Stockbridge Pumping Station (Line 17),
26  
-which sees only iluid ilow from Line 6B
27  
-The information provided does not demonstrate compliance with the above regulation. Line
28  
-6B has been ect to a batch chemical treatment program to inhibit intemal corrosion for
29  
-several years. As required by Line 6B must have coupons or other monitoring
30  
-equipment to determine the effectiveness of the inhibitor program, and the coupons or other
31  
-monitoring equipment maust be examined at least twice each calendar year, at intervals not to
32  
-exceed 7~l/2 months. PHMSA acknowledges the positive steps being taken to improve
33  
-Enbridge's internal corrosion mitigation and monitoring program. However, the transition
34  
-from one technology to another must be implemented in a manner that ensnres continued
35  
-compliance with the regulations.
36  
-Under 49 United States Code, SS 60122, you are ect to a civil penalty not to exceed
37  
-$100,000 for each violation for each day the violation persists up to a maximum of $1,000,000
38  
-for any related series of violations. We have reviewed the circumstances and supporting
39  
-documents involved in this case, and have decided not to conduct additional enforcement
40  
-2
41  
-
29  test/fixtures/corrosion/corrosion_3.txt
... ...
@@ -1,29 +0,0 @@
1  
-Promote Cultural Diplomacy: American artists, performers and thinkers – representing our values and ideals
2  
-– can inspire people both at home and all over the world. Through efforts like that of the United States
3  
-Information Agency, America’s cultural leaders were deployed around the world during the Cold War as artistic
4  
-ambassadors and helped win the war of ideas by demonstrating to the world the promise of America. Artists
5  
-can be utilized again to help us win the war of ideas against Islamic extremism. Unfortunately, our resources
6  
-for cultural diplomacy are at their lowest level in a decade. Barack Obama will work to reverse this trend and
7  
-improve and expand public-private partnerships to expand cultural and arts exchanges throughout the world.
8  
-Attract Foreign Talent: The flipside to promoting American arts and culture abroad is welcoming members of
9  
-the foreign arts community to America. Opening America’s doors to students and professional artists provides
10  
-the kind of two-way cultural understanding that can break down the barriers that feed hatred and fear. As
11  
-America tightened visa restrictions after 9/11, the world’s most talented students and artists, who used to come
12  
-here, went elsewhere. Barack Obama will streamline the visa process to return America to its rightful place as
13  
-the world’s top destination for artists and art students.
14  
-Provide Health Care to Artists: Finding affordable health coverage has often been one of the most vexing
15  
-obstacles for artists and those in the creative community. Since many artists work independently or have nontraditional employment relationships, employer-based coverage is unavailable and individual policies are
16  
-financially out of reach. Barack Obama’s plan will provide all Americans with quality, affordable health care.
17  
-His plan includes the creation of a new public program that will allow individuals and small businesses to buy
18  
-affordable health care similar to that available to federal employees. His plan also creates a National Health
19  
-Insurance Exchange to reform the private insurance market and allow Americans to enroll in participating
20  
-private plans, which would have to provide comprehensive benefits, issue every applicant a policy, and charge
21  
-fair and stable premiums. For those who still cannot afford coverage, the government will provide a subsidy.
22  
-His health plan will lower costs for the typical American family by up to $2,500 per year.
23  
-Ensure Tax Fairness for Artists: Barack Obama supports the Artist-Museum Partnership Act, introduced by
24  
-Senator Patrick Leahy (D-VT). The Act amends the Internal Revenue Code to allow artists to deduct the fair
25  
-market value of their work, rather than just the costs of the materials, when they make charitable contributions.
26  
-
27  
-Paid for by Obama for America
28  
-
29  
-
18  test/fixtures/corrosion/corrosion_4.txt
... ...
@@ -1,18 +0,0 @@
1  
-action or penalty assessment proceedings at this time. We advise you to correct the item
2  
-identified in this letter. Failure to do so will result in Enbridge being subject to additional
3  
-enforcement action.
4  
-No reply to this letter is required. If you choose to reply, in your correspondence please refer
5  
-to CPF 3-2010-5002W. Be advised that all material you submit in response to this
6  
-enforcement action is subject to being made publicly available. If you believe that any portion
7  
-of your responsive material qualifies for confidential treatment Linder 5 U.S.C. 552(b), along
8  
-with the complete original document you must provide a second copy of the document with the
9  
-portions you believe qualify for confidential treatment redacted and an explanation of Why you
10  
-believe the redacted information qualities for confidential treatment under 5 U.S.C. 552(b).
11  
-Sincerely,
12  
-
13  
-Ivan A. Huntoon
14  
-Director, Central Region
15  
-Pipeline and Hazardous Materials Safety Administration
16  
-_-in
17  
-3
18  
-
11  test/test_helper.rb
@@ -14,4 +14,13 @@ def teardown
14 14
     clear_output
15 15
   end
16 16
 
17  
-end
  17
+  def assert_directory_contains(dir, files)
  18
+    files_in_directory = Dir["#{dir}/*"]
  19
+    if files.kind_of?(Array)
  20
+      assert files_in_directory.length == files.length, "Expected directory to contain exactly #{files.length} files"
  21
+    else
  22
+      files = [files]
  23
+    end
  24
+    files.each { |f| assert files_in_directory.include?(File.join(dir, f)), "Expected directory #{dir} to contain file #{f}, but it contains #{files_in_directory.inspect}" }
  25
+  end
  26
+end
9  test/unit/test_extract_images.rb
@@ -4,7 +4,7 @@ class ExtractImagesTest < Test::Unit::TestCase
4 4
 
5 5
   def test_basic_image_extraction
6 6
     Docsplit.extract_images('test/fixtures/obama_arts.pdf', :format => :gif, :size => "250x", :output => OUTPUT)
7  
-    assert Dir["#{OUTPUT}/*"] == ['test/output/obama_arts_1.gif', 'test/output/obama_arts_2.gif']
  7
+    assert_directory_contains(OUTPUT, ['obama_arts_1.gif', 'obama_arts_2.gif'])
8 8
   end
9 9
 
10 10
   def test_image_formatting
@@ -36,14 +36,15 @@ def test_password_protected_extraction
36 36
 
37 37
   def test_repeated_extraction_in_the_same_directory
38 38
     Docsplit.extract_images('test/fixtures/obama_arts.pdf', :format => :gif, :size => "250x", :output => OUTPUT)
39  
-    assert Dir["#{OUTPUT}/*"] == ['test/output/obama_arts_1.gif', 'test/output/obama_arts_2.gif']
  39
+    assert_directory_contains(OUTPUT, ['obama_arts_1.gif', 'obama_arts_2.gif'])
40 40
     Docsplit.extract_images('test/fixtures/obama_arts.pdf', :format => :gif, :size => "250x", :output => OUTPUT)
41  
-    assert Dir["#{OUTPUT}/*"] == ['test/output/obama_arts_1.gif', 'test/output/obama_arts_2.gif']
  41
+    assert_directory_contains(OUTPUT, ['obama_arts_1.gif', 'obama_arts_2.gif'])
42 42
   end
43 43
 
44 44
   def test_name_escaping_while_extracting_images
45 45
     Docsplit.extract_images('test/fixtures/PDF file with spaces \'single\' and "double quotes".pdf', :format => :gif, :size => "250x", :output => OUTPUT)
46  
-    assert Dir["#{OUTPUT}/*"] == ['test/output/PDF file with spaces \'single\' and "double quotes"_1.gif', 'test/output/PDF file with spaces \'single\' and "double quotes"_2.gif']
  46
+    assert_directory_contains(OUTPUT, ['PDF file with spaces \'single\' and "double quotes"_1.gif',
  47
+                                       'PDF file with spaces \'single\' and "double quotes"_1.gif'])
47 48
   end
48 49
 
49 50
 end
5  test/unit/test_extract_text.rb
@@ -30,11 +30,10 @@ def test_unicode_extraction
30 30
 
31 31
   def test_ocr_extraction
32 32
     Docsplit.extract_text('test/fixtures/corrosion.pdf', :pages => 'all', :output => OUTPUT)
33  
-    assert Dir["#{OUTPUT}/*.txt"].length == 4
34 33
     4.times do |i|
35 34
       file = "corrosion_#{i + 1}.txt"
36  
-      # File.open("test/fixtures/corrosion/#{file}", "w+") {|f| f.write(File.read("#{OUTPUT}/#{file}")) }
37  
-      assert File.read("#{OUTPUT}/#{file}") == File.read("test/fixtures/corrosion/#{file}")
  35
+      assert_directory_contains(OUTPUT, file)
  36
+      assert File.read(File.join(OUTPUT, file)).size > 1, "Expected that file with extracted text should have reasonable size"
38 37
     end
39 38
   end
40 39
 

0 notes on commit 28fef69

Please sign in to comment.
Something went wrong with that request. Please try again.