import pytest
from web_test_base import *

class TestIATIValidator(WebTestBase):
    requests_to_load = {
        'IATI Validator': {
            'url': 'http://validator.iatistandard.org/'
        }
    }

    def test_contains_links(self, loaded_request):
        """
        Test that each page contains links to the defined URLs.
        """
        result = utility.get_links_from_page(loaded_request)

        assert "http://iatistandard.org/" in result

import pytest
from web_test_base import *

class TestIATIValidator(WebTestBase):
    requests_to_load = {
        'IATI Validator': {
            'url': 'http://validator.iatistandard.org/'
        }
    }

    def test_contains_links(self, loaded_request):
        """
        Test that each page contains links to the defined URLs.
        """
        result = utility.get_links_from_page(loaded_request)

        assert "http://iatistandard.org/" in result

    def test_contains_form(self, loaded_request):
        """
        Test that the validator contains a form on each of three tabs.
        """
        assert len(utility.locate_xpath_result(loaded_request, '//*[@id="status"]/div/form')) == 1
        assert len(utility.locate_xpath_result(loaded_request, '//*[@id="fileTab"]/div/form')) == 1
        assert len(utility.locate_xpath_result(loaded_request, '//*[@id="extra"]/div/form')) == 1

Check forms on validator page
Check forms on validator page

Add a test to check that each of the three forms exist on the
validator page.
This test does not check whether the three forms work correctly.

  import pytest
  from web_test_base import *
  
  class TestIATIValidator(WebTestBase):
      requests_to_load = {
          'IATI Validator': {
              'url': 'http://validator.iatistandard.org/'
          }
      }
  
      def test_contains_links(self, loaded_request):
          """
          Test that each page contains links to the defined URLs.
          """
          result = utility.get_links_from_page(loaded_request)
  
          assert "http://iatistandard.org/" in result
  
+     def test_contains_form(self, loaded_request):
+         """
+         Test that the validator contains a form on each of three tabs.
+         """
+         assert len(utility.locate_xpath_result(loaded_request, '//*[@id="status"]/div/form')) == 1
+         assert len(utility.locate_xpath_result(loaded_request, '//*[@id="fileTab"]/div/form')) == 1
+         assert len(utility.locate_xpath_result(loaded_request, '//*[@id="extra"]/div/form')) == 1
+ 
Check forms on validator page
## Code Before:
import pytest
from web_test_base import *

class TestIATIValidator(WebTestBase):
    requests_to_load = {
        'IATI Validator': {
            'url': 'http://validator.iatistandard.org/'
        }
    }

    def test_contains_links(self, loaded_request):
        """
        Test that each page contains links to the defined URLs.
        """
        result = utility.get_links_from_page(loaded_request)

        assert "http://iatistandard.org/" in result

## Instruction:
Check forms on validator page
## Code After:
import pytest
from web_test_base import *

class TestIATIValidator(WebTestBase):
    requests_to_load = {
        'IATI Validator': {
            'url': 'http://validator.iatistandard.org/'
        }
    }

    def test_contains_links(self, loaded_request):
        """
        Test that each page contains links to the defined URLs.
        """
        result = utility.get_links_from_page(loaded_request)

        assert "http://iatistandard.org/" in result

    def test_contains_form(self, loaded_request):
        """
        Test that the validator contains a form on each of three tabs.
        """
        assert len(utility.locate_xpath_result(loaded_request, '//*[@id="status"]/div/form')) == 1
        assert len(utility.locate_xpath_result(loaded_request, '//*[@id="fileTab"]/div/form')) == 1
        assert len(utility.locate_xpath_result(loaded_request, '//*[@id="extra"]/div/form')) == 1
