view · edit · sidebar · attach · print · history

Index>

20140108-fix-oddb2xml-rspec

Summary

  • Fix running rspec for oddb2xml

Commits

Index

---

Fix running rspec for oddb2xml

  • Travis-CI reports that bundle install --without debugger fails.

See https://travis-ci.org/ngiger/oddb2xml/jobs/16548496. This works for me locally. The use gem version 2.2.0. I had locally 2.0.14 and (after upgrading) 2.2.1.

Posted a question on https://groups.google.com/forum/#!forum/travis-ci

Pushed commit Remove debugger from travis.yml/Gemfile to try whether a simplified Gemfile would help.

  • Running rspec fails with
  1) Oddb2xml::SwissmedicInfoExtractor can parse swissmedic_packages.xlsx should eq "globulina equina (immunis\303\251 avec coeur, tissu pulmonaire, reins de porcins)"
     Failure/Error: expect(first[:substance_swissmedic]).to eq('globulina equina (immunisé avec coeur, tissu pulmonaire, reins de porcins)')

       expected: "globulina equina (immunis\303\251 avec coeur, tissu pulmonaire, reins de porcins)"
            got: "globulina equina (immunis\303\251 avec coeur, endoth\303\251lium vasculaire porcins)"

       (compared using ==)
     # ./spec/extractor_spec.rb:76

Running it a second time gives

Failures:

  1) Oddb2xml::SwissmedicInfoExtractor can parse swissmedic_packages.xlsx should eq "J06AA"
     Failure/Error: expect(first[:atc_code]).to eq('J06AA')

       expected: "J06AA"
            got: "N03AX14"

       (compared using ==)
     # ./spec/extractor_spec.rb:72

  2) Oddb2xml::Builder when no option is given should generate a valid oddb_product.xml
     Failure/Error: article_xml.should match(/<VDAT>01.10.2011</)
       expected "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<ARTICLE xmlns=\"http://wiki.oddb.org/wiki.php?pagename=Swissmedic.Datendeklaration\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" PROD_DATE=\"2014-01-08T08:37:12+0100\" VALID_DATE=\"2014-01-08T08:37:12+0100\" CREATION_DATETIME=\"2014-01-08T08:37:12+0100\">\n  <ART DT=\"\">\n    <PHAR>1699947</PHAR>\n    <SMNO>53662013</SMNO>\n    <SALECD>A</SALECD>\n    <CDBG>N</CDBG>\n    <BG>N</BG>\n    <QTY>60 Stk</QTY>\n    <DSCRD>3TC Filmtabl 150 mg</DSCRD>\n    <DSCRF>3TC Filmtabl 150 mg</DSCRF>\n    <SORTD>3TC FILMTABL 150 MG</SORTD>\n    <SORTF>3TC FILMTABL 150 MG</SORTF>\n    <ARTCOMP>\n      <COMPNO>7601001392175</COMPNO>\n    </ARTCOMP>\n    <ARTBAR>\n      <CDTYP>E13</CDTYP>\n      <BC>7680536620137</BC>\n      <BCSTAT>A</BCSTAT>\n    </ARTBAR>\n  </ART>\n  <ART DT=\"\">\n    <PHAR>5819012</PHAR>\n    <SMNO>62069008</SMNO>\n    <SALECD>A</SALECD>\n    <CDBG>N</CDBG>\n    <BG>N</BG>\n    <QTY>30 Stk</QTY>\n    <DSCRD>LEVETIRACETAM DESITIN Filmtabl 250 mg</DSCRD>\n    <DSCRF>LEVETIRACETAM DESITIN Filmtabl 250 mg</DSCRF>\n    <SORTD>LEVETIRACETAM DESITIN FILMTABL 250 MG</SORTD>\n    <SORTF>LEVETIRACETAM DESITIN FILMTABL 250 MG</SORTF>\n    <ARTCOMP>\n      <COMPNO>7601001320451</COMPNO>\n    </ARTCOMP>\n    <ARTBAR>\n      <CDTYP>E13</CDTYP>\n      <BC>7680620690084</BC>\n      <BCSTAT>A</BCSTAT>\n    </ARTBAR>\n  </ART>\n  <RESULT>\n    <OK_ERROR>OK</OK_ERROR>\n    <NBR_RECORD>2</NBR_RECORD>\n    <ERROR_CODE/>\n    <MESSAGE/>\n  </RESULT>\n</ARTICLE>\n" to match /<VDAT>01.10.2011</
       Diff:
       @@ -1,2 +1,50 @@
       -/<VDAT>01.10.2011</
       +<?xml version="1.0" encoding="utf-8"?>
       +<ARTICLE xmlns="http://wiki.oddb.org/wiki.php?pagename=Swissmedic.Datendeklaration" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" PROD_DATE="2014-01-08T08:37:12+0100" VALID_DATE="2014-01-08T08:37:12+0100" CREATION_DATETIME="2014-01-08T08:37:12+0100">
       +  <ART DT="">
       +    <PHAR>1699947</PHAR>
       +    <SMNO>53662013</SMNO>
       +    <SALECD>A</SALECD>
       +    <CDBG>N</CDBG>
       +    <BG>N</BG>
       +    <QTY>60 Stk</QTY>
       +    <DSCRD>3TC Filmtabl 150 mg</DSCRD>
       +    <DSCRF>3TC Filmtabl 150 mg</DSCRF>
       +    <SORTD>3TC FILMTABL 150 MG</SORTD>
       +    <SORTF>3TC FILMTABL 150 MG</SORTF>
       +    <ARTCOMP>
       +      <COMPNO>7601001392175</COMPNO>
       +    </ARTCOMP>
       +    <ARTBAR>
       +      <CDTYP>E13</CDTYP>
       +      <BC>7680536620137</BC>
       +      <BCSTAT>A</BCSTAT>
       +    </ARTBAR>
       +  </ART>
       +  <ART DT="">
       +    <PHAR>5819012</PHAR>
       +    <SMNO>62069008</SMNO>
       +    <SALECD>A</SALECD>
       +    <CDBG>N</CDBG>
       +    <BG>N</BG>
       +    <QTY>30 Stk</QTY>
       +    <DSCRD>LEVETIRACETAM DESITIN Filmtabl 250 mg</DSCRD>
       +    <DSCRF>LEVETIRACETAM DESITIN Filmtabl 250 mg</DSCRF>
       +    <SORTD>LEVETIRACETAM DESITIN FILMTABL 250 MG</SORTD>
       +    <SORTF>LEVETIRACETAM DESITIN FILMTABL 250 MG</SORTF>
       +    <ARTCOMP>
       +      <COMPNO>7601001320451</COMPNO>
       +    </ARTCOMP>
       +    <ARTBAR>
       +      <CDTYP>E13</CDTYP>
       +      <BC>7680620690084</BC>
       +      <BCSTAT>A</BCSTAT>
       +    </ARTBAR>
       +  </ART>
       +  <RESULT>
       +    <OK_ERROR>OK</OK_ERROR>
       +    <NBR_RECORD>2</NBR_RECORD>
       +    <ERROR_CODE/>
       +    <MESSAGE/>
       +  </RESULT>
       +</ARTICLE>
     # ./spec/builder_spec.rb:60

Okay. Problem is that with Ruby 1.8.7 hashes can have a different order than with Ruby 1.9 or later.

One error was easy to fix. See commit Fix spec for ruby 1.8.7 which does not have ordered hashes.

But the error with the missing VDAT persisted even when I also changed the implementation of files in builder.rb to behave like a sorted hash. Running the specs sorted did not help.

Using ActiveSupport::OrderedHash did not solve the problem neither.

The problem seems to be that in about 50% of the time the BagXmlDownloader read_xml_form_zip call return the content from the zip file passed as argument and sometimes the content of Preparation.xml.

view · edit · sidebar · attach · print · history
Page last modified on January 08, 2014, at 03:16 PM