Exemplo n.º 1
0
    def test_valid_with_contractno_after_formatting_markup_as_first_element(
            self):
        sample = io.BytesIO(b"""
        <article>
          <front>
            <article-meta>
	      <funding-group>
	        <award-group>
		  <funding-source>Brazilian Ministry of Health/Secretariat of Health Surveillance/Department of STD, AIDS and Viral Hepatitis</funding-source>
		  <award-id>2010/03107-2</award-id>
		</award-group>
                <funding-statement>Apoio financeiro: Fundacao de Amparo a Pesquisa do Estado de Sao Paulo (FAPESP). Processo 2010/03107-2. Conselho Nacional de Desenvolvimento Cientifico e Tecnologico (CNPq).
                </funding-statement>
              </funding-group>
            </article-meta>
          </front>
          <back>
	    <fn-group>
	      <fn fn-type="financial-disclosure">
	        <p><bold>Apoio financeiro:</bold> Fundacao de Amparo a Pesquisa do Estado de Sao
		   Paulo (FAPESP). Processo 2010/03107-2. Conselho Nacional de
		   Desenvolvimento Cientifico e Tecnologico (CNPq).</p>
	      </fn>
	    </fn-group>
          </back>
        </article>
        """)

        et = etree.parse(sample)
        _, err_list = checks.funding_group((et, []))

        self.assertEqual(len(err_list), 0)
Exemplo n.º 2
0
    def test_proposition_1_case_3(self):
        """
        HasExplicitContract is False
        HasFundingGroup is True
        (HasExplicitContract <=> HasFundingGroup) is False
        """
        sample = io.BytesIO(b"""
        <article>
          <front>
            <article-meta>
	      <funding-group>
	        <award-group>
		  <funding-source>Brazilian Ministry of Health/Secretariat of Health Surveillance/Department of STD, AIDS and Viral Hepatitis</funding-source>
		  <award-id>CSV 234/07</award-id>
		</award-group>
                <funding-statement>This study was supported by the Brazilian Ministry of Health/Secretariat of Health Surveillance/Department of STD, AIDS and Viral Hepatitis, through the Project of International Technical Cooperation AD/BRA/03/H34 between the Brazilian Government and the United Nations Office on Drugs and Crime (Process CSV 234/07).</funding-statement>
	      </funding-group>
            </article-meta>
          </front>
          <back>
            <fn-group>
              <fn id="fn1">
	        <p>This study was supported by the Brazilian Ministry of Health/Secretariat of Health Surveillance/Department of STD, AIDS and Viral Hepatitis, through the Project of International Technical Cooperation AD/BRA/03/H34 between the Brazilian Government and the United Nations Office on Drugs and Crime (Process CSV 234/07).</p>
	      </fn>
            </fn-group>
          </back>
        </article>
        """)

        et = etree.parse(sample)
        _, err_list = checks.funding_group((et, []))

        self.assertEqual(len(err_list), 1)
        self.assertTrue("'funding-group'" in err_list[0].message)
Exemplo n.º 3
0
    def test_valid_with_contractno_after_formatting_markup(self):
        sample = io.BytesIO(b"""
        <article>
          <front>
            <article-meta>
	      <funding-group>
	        <award-group>
		  <funding-source>Brazilian Ministry of Health/Secretariat of Health Surveillance/Department of STD, AIDS and Viral Hepatitis</funding-source>
		  <award-id>CSV 234/07</award-id>
		</award-group>
                <funding-statement>This study was supported by the Brazilian Ministry of Health/Secretariat of Health Surveillance/Department of STD, AIDS and Viral Hepatitis, through the Project of International Technical Cooperation AD/BRA/03/H34 between the Brazilian Government and the United Nations Office on Drugs and Crime (Process CSV 234/07).</funding-statement>
	      </funding-group>
            </article-meta>
          </front>
          <back>
            <ack>
	      <p>This study was supported by the <italic>Brazilian</italic> Ministry of Health/Secretariat of Health Surveillance/Department of STD, AIDS and Viral Hepatitis, through the Project of International Technical Cooperation AD/BRA/03/H34 between the Brazilian Government and the United Nations Office on Drugs and Crime (Process CSV 234/07).</p>
            </ack>
          </back>
        </article>
        """)

        et = etree.parse(sample)
        _, err_list = checks.funding_group((et, []))

        self.assertEqual(len(err_list), 0)
Exemplo n.º 4
0
    def test_proposition_1_case_4(self):
        """
        HasExplicitContract is False
        HasFundingGroup is False
        (HasExplicitContract <=> HasFundingGroup) is True
        """
        sample = StringIO("""
        <article>
          <front>
            <article-meta></article-meta>
          </front>
          <back>
            <fn-group>
			  <fn id="fn1">
			    <p>This study was supported by the Brazilian Ministry of Health/Secretariat of Health Surveillance/Department of STD, AIDS and Viral Hepatitis, through the Project of International Technical Cooperation AD/BRA/03/H34 between the Brazilian Government and the United Nations Office on Drugs and Crime (Process CSV 234/07).</p>
			  </fn>
		    </fn-group>
	      </back>
        </article>
        """)

        et = etree.parse(sample)
        _, err_list = checks.funding_group((et, []))

        self.assertEquals(len(err_list), 0)
Exemplo n.º 5
0
    def test_fn_p_and_awardid_with_no_content(self):
        sample = io.BytesIO(b"""
        <article>
          <front>
            <article-meta>
              <funding-group>
                <award-group>
                  <funding-source>Brazilian Ministry of Health/Secretariat of Health Surveillance/Department of STD, AIDS and Viral Hepatitis</funding-source>
                  <award-id/>
                </award-group>
              </funding-group>
            </article-meta>
          </front>
          <back>
            <fn-group>
              <fn id="fn1" fn-type="financial-disclosure">
                <p/>
              </fn>
            </fn-group>
          </back>
        </article>
        """)

        et = etree.parse(sample)
        _, err_list = checks.funding_group((et, []))

        self.assertEqual(len(err_list), 1)
        self.assertTrue("'fn-group'" in err_list[0].message)
Exemplo n.º 6
0
    def test_proposition_1_case_1(self):
        """
        HasExplicitContract is True
        HasFundingGroup is True
        (HasExplicitContract <=> HasFundingGroup) is True
        """
        sample = os.path.join(SAMPLES_PATH, '0034-8910-rsp-48-2-0206.xml')

        et = etree.parse(sample)
        _, err_list = checks.funding_group((et, []))

        self.assertEqual(len(err_list), 0)
Exemplo n.º 7
0
    def test_proposition_1_case_1(self):
        """
        HasExplicitContract is True
        HasFundingGroup is True
        (HasExplicitContract <=> HasFundingGroup) is True
        """
        sample = os.path.join(SAMPLES_PATH, '0034-8910-rsp-48-2-0206.xml')

        et = etree.parse(sample)
        _, err_list = checks.funding_group((et, []))

        self.assertEquals(len(err_list), 0)
Exemplo n.º 8
0
    def test_fn_p_with_no_content(self):
        sample = io.BytesIO(b"""
        <article>
          <front>
            <article-meta>
            </article-meta>
          </front>
          <back>
            <fn-group>
              <fn id="fn1" fn-type="financial-disclosure">
                <p/>
              </fn>
            </fn-group>
          </back>
        </article>
        """)

        et = etree.parse(sample)
        _, err_list = checks.funding_group((et, []))

        self.assertEqual(len(err_list), 1)
        self.assertTrue("'fn-group'" in err_list[0].message)
Exemplo n.º 9
0
    def test_proposition_3_case_3(self):
        """
        ∀ContractNo<fn> [ Registered(FundingGroup, ContractNo) ] ^
        ∀ContractNo<ack> [ Registered(FundingGroup, ContractNo) ] ^
        ∃ContractNo<funding-group> [ ¬(Registered(Ack, ContractNo)) ^ ¬(Registered(Fn, ContractNo)) ]
        """
        sample = io.BytesIO(b"""
        <article>
          <front>
            <article-meta>
              <funding-group>
                <award-group>
                  <funding-source>Brazilian Ministry of Health/Secretariat of Health Surveillance/Department of STD, AIDS and Viral Hepatitis</funding-source>
                  <award-id>234/07</award-id>
                </award-group>
                <award-group>
                  <funding-source>Brazilian Ministry of Health/Secretariat of Health Surveillance/Department of STD, AIDS and Viral Hepatitis</funding-source>
                  <award-id>236/08</award-id>
                </award-group>
                <funding-statement>This study was supported by the Brazilian Ministry of Health/Secretariat of Health Surveillance/Department of STD, AIDS and Viral Hepatitis, through the Project of International Technical Cooperation AD/BRA/03/H34 between the Brazilian Government and the United Nations Office on Drugs and Crime (Process CSV 234/07).</funding-statement>
              </funding-group>
            </article-meta>
          </front>
          <back>
            <fn-group>
              <fn id="fn1" fn-type="financial-disclosure">
                <p>This study was supported by the Brazilian Ministry of Health/Secretariat of Health Surveillance/Department of STD, AIDS and Viral Hepatitis, through the Project of International Technical Cooperation AD/BRA/03/H34 between the Brazilian Government and the United Nations Office on Drugs and Crime (Process CSV 234/07).</p>
              </fn>
            </fn-group>
          </back>
        </article>
        """)

        et = etree.parse(sample)
        _, err_list = checks.funding_group((et, []))

        self.assertEqual(len(err_list), 1)
        self.assertTrue("'funding-group'" in err_list[0].message)
Exemplo n.º 10
0
    def test_proposition_3_case_3(self):
        """
        ∀ContractNo<fn> [ Registered(FundingGroup, ContractNo) ] ^
        ∀ContractNo<ack> [ Registered(FundingGroup, ContractNo) ] ^
        ∃ContractNo<funding-group> [ ¬(Registered(Ack, ContractNo)) ^ ¬(Registered(Fn, ContractNo)) ]
        """
        sample = StringIO("""
        <article>
          <front>
            <article-meta>
			  <funding-group>
				<award-group>
				  <funding-source>Brazilian Ministry of Health/Secretariat of Health Surveillance/Department of STD, AIDS and Viral Hepatitis</funding-source>
			      <award-id>234/07</award-id>
				</award-group>
				<award-group>
				  <funding-source>Brazilian Ministry of Health/Secretariat of Health Surveillance/Department of STD, AIDS and Viral Hepatitis</funding-source>
			      <award-id>236/08</award-id>
				</award-group>
			    <funding-statement>This study was supported by the Brazilian Ministry of Health/Secretariat of Health Surveillance/Department of STD, AIDS and Viral Hepatitis, through the Project of International Technical Cooperation AD/BRA/03/H34 between the Brazilian Government and the United Nations Office on Drugs and Crime (Process CSV 234/07).</funding-statement>
			  </funding-group>
            </article-meta>
          </front>
          <back>
            <fn-group>
			  <fn id="fn1" fn-type="financial-disclosure">
			    <p>This study was supported by the Brazilian Ministry of Health/Secretariat of Health Surveillance/Department of STD, AIDS and Viral Hepatitis, through the Project of International Technical Cooperation AD/BRA/03/H34 between the Brazilian Government and the United Nations Office on Drugs and Crime (Process CSV 234/07).</p>
			  </fn>
		    </fn-group>
	      </back>
        </article>
        """)

        et = etree.parse(sample)
        _, err_list = checks.funding_group((et, []))

        self.assertEquals(len(err_list), 1)
        self.assertTrue("'funding-group'" in err_list[0].message)
Exemplo n.º 11
0
    def test_proposition_3_case_2(self):
        """ This cannot be checked by packtools' stylechecker.

        ∀ContractNo<fn> [ Registered(FundingGroup, ContractNo) ] ^
        ∃ContractNo<ack> [ ¬Registered(FundingGroup, ContractNo) ] ^
        ∀ContractNo<funding-group> [ Registered(Ack, ContractNo) v Registered(Fn, ContractNo) ]
        """
        sample = io.BytesIO(b"""
        <article>
          <front>
            <article-meta>
              <funding-group>
                <award-group>
                  <funding-source>Brazilian Ministry of Health/Secretariat of Health Surveillance/Department of STD, AIDS and Viral Hepatitis</funding-source>
                  <award-id>234/07</award-id>
                </award-group>
                <funding-statement>This study was supported by the Brazilian Ministry of Health/Secretariat of Health Surveillance/Department of STD, AIDS and Viral Hepatitis, through the Project of International Technical Cooperation AD/BRA/03/H34 between the Brazilian Government and the United Nations Office on Drugs and Crime (Process CSV 234/07).</funding-statement>
              </funding-group>
            </article-meta>
          </front>
          <back>
            <fn-group>
              <fn id="fn1" fn-type="financial-disclosure">
                <p>This study was supported by the Brazilian Ministry of Health/Secretariat of Health Surveillance/Department of STD, AIDS and Viral Hepatitis, through the Project of International Technical Cooperation AD/BRA/03/H34 between the Brazilian Government and the United Nations Office on Drugs and Crime (Process CSV 234/07).</p>
              </fn>
            </fn-group>
            <ack>
              <p>... this study was supported by FooBar under the process 235/09.</p>
            </ack>
          </back>
        </article>
        """)

        et = etree.parse(sample)
        _, err_list = checks.funding_group((et, []))

        self.assertEqual(len(err_list), 0)  # the error could not be detected