Exemple #1
0
    def test_diff(self):
        """The diff results page should have a header and a div for each message."""
        xml_file = StringIO(PfifXml.XML_ADDED_DELETED_CHANGED_1)
        xml_file.name = 'added_deleted_changed_1.xml'
        utils.set_file_for_test(StringIO(PfifXml.XML_ADDED_DELETED_CHANGED_2))
        post_dict = {
            'pfif_xml_file_1': xml_file,
            'pfif_xml_url_2': 'fake_url',
            'options': ['text_is_case_sensitive']
        }
        response = self.make_request(post_dict, path='/diff/results')
        response_str = response.content

        # set the test file again because the first one will be at the end, and the
        # xml parser doesn't have to seek(0) on it.
        utils.set_file_for_test(StringIO(PfifXml.XML_ADDED_DELETED_CHANGED_2))
        post_dict['options'].append('group_messages_by_record')
        grouped_response = self.make_request(post_dict, path='/diff/results')
        grouped_response_str = grouped_response.content

        # The header should have 'Diff' and 'Messages' in it along with the filename
        # or url.
        # The body should have each of five message types from pfif_object_diff
        for message in [
                'Diff', 'Messages', 'added_deleted_changed_1.xml', 'fake_url',
                'extra', 'missing', 'field', 'record', 'Value', 'changed', 'A',
                'B'
        ]:
            self.assertTrue(
                message in response_str and message in grouped_response_str,
                'The diff was missing the '
                'following message: ' + message + '.  The diff: ' +
                response_str)
  def test_diff(self):
    """The diff results page should have a header and a div for each message."""
    xml_file = StringIO(PfifXml.XML_ADDED_DELETED_CHANGED_1)
    xml_file.name = 'added_deleted_changed_1.xml'
    utils.set_file_for_test(StringIO(PfifXml.XML_ADDED_DELETED_CHANGED_2))
    post_dict = {
        'pfif_xml_file_1' : xml_file, 'pfif_xml_url_2' : 'fake_url',
        'options' : ['text_is_case_sensitive']}
    response = self.make_request(post_dict, path='/diff/results')
    response_str = response.content

    # set the test file again because the first one will be at the end, and the
    # xml parser doesn't have to seek(0) on it.
    utils.set_file_for_test(StringIO(PfifXml.XML_ADDED_DELETED_CHANGED_2))
    post_dict['options'].append('group_messages_by_record')
    grouped_response = self.make_request(post_dict, path='/diff/results')
    grouped_response_str = grouped_response.content

    # The header should have 'Diff' and 'Messages' in it along with the filename
    # or url.
    # The body should have each of five message types from pfif_object_diff
    for message in ['Diff', 'Messages', 'added_deleted_changed_1.xml',
                    'fake_url', 'extra', 'missing', 'field', 'record', 'Value',
                    'changed', 'A', 'B']:
      self.assertTrue(message in  response_str and message in
                      grouped_response_str, 'The diff was missing the '
                      'following message: ' + message + '.  The diff: ' +
                      response_str)
    def test_diff(self):
        """The diff results page should have a header and a div for each message."""
        fake_file_1 = FakeFieldStorage('added_deleted_changed_1.xml',
                                       PfifXml.XML_ADDED_DELETED_CHANGED_1)
        utils.set_file_for_test(StringIO(PfifXml.XML_ADDED_DELETED_CHANGED_2))
        request = MultiDict({
            'pfif_xml_file_1': fake_file_1,
            'pfif_xml_url_2': 'fake_url',
            'options': 'text_is_case_sensitive'
        })
        response = self.make_webapp_request(
            request, handler_init_method=controller.DiffController)
        response_str = response.out.getvalue()

        # set the test file again because the first one will be at the end, and the
        # xml parser doesn't have to seek(0) on it.
        utils.set_file_for_test(StringIO(PfifXml.XML_ADDED_DELETED_CHANGED_2))
        request.add('options', 'group_messages_by_record')
        grouped_response = self.make_webapp_request(
            request, handler_init_method=controller.DiffController)
        grouped_response_str = grouped_response.out.getvalue()

        # The header should have 'Diff' and 'Messages' in it along with the filename
        # or url.
        # The body should have each of five message types from pfif_object_diff
        for message in [
                'Diff', 'Messages', 'added_deleted_changed_1.xml', 'fake_url',
                'extra', 'missing', 'field', 'record', 'Value', 'changed', 'A',
                'B'
        ]:
            self.assertTrue(
                message in response_str and message in grouped_response_str,
                'The diff was missing the '
                'following message: ' + message + '.  The diff: ' +
                response_str)
Exemple #4
0
    def run_main(self, argv):
        """Mocks files and runs main after setting sys.argv to the provided argv."""
        old_argv = sys.argv
        old_stdout = sys.stdout
        sys.argv = argv
        sys.stdout = StringIO('')

        utils.set_file_for_test(StringIO(PfifXml.XML_11_FULL))
        pfif_diff.main()
        self.assertFalse('all_messages' in sys.stdout.getvalue())

        sys.stdout = old_stdout
        sys.argv = old_argv
Exemple #5
0
  def run_main(self, argv):
    """Mocks files and runs main after setting sys.argv to the provided argv."""
    old_argv = sys.argv
    old_stdout = sys.stdout
    sys.argv = argv
    sys.stdout = StringIO('')

    utils.set_file_for_test(StringIO(PfifXml.XML_11_FULL))
    pfif_diff.main()
    self.assertFalse('all_messages' in sys.stdout.getvalue())

    sys.stdout = old_stdout
    sys.argv = old_argv
Exemple #6
0
    def test_main(self):
        """main should not raise an exception under normal circumstances."""
        old_argv = sys.argv
        old_stdout = sys.stdout
        sys.argv = ['pfif_validator.py', 'mocked_file']
        sys.stdout = StringIO('')

        utils.set_file_for_test(StringIO(PfifXml.XML_11_FULL))
        pfif_validator.main()
        self.assertFalse('all_messages' in sys.stdout.getvalue())

        sys.stdout = old_stdout
        sys.argv = old_argv
  def test_main(self):
    """main should not raise an exception under normal circumstances."""
    old_argv = sys.argv
    old_stdout = sys.stdout
    sys.argv = ['pfif_validator.py', 'mocked_file']
    sys.stdout = StringIO('')

    utils.set_file_for_test(StringIO(PfifXml.XML_11_FULL))
    pfif_validator.main()
    self.assertFalse('all_messages' in sys.stdout.getvalue())

    sys.stdout = old_stdout
    sys.argv = old_argv
Exemple #8
0
 def test_url_upload(self):
     """The page should have the correct number of errors in the header when
 using the pfif_xml_url_1 POST variable to send PFIF XML."""
     utils.set_file_for_test(StringIO(PfifXml.XML_TWO_DUPLICATE_NO_CHILD))
     response = self.make_request({'pfif_xml_url_1': 'dummy_url'})
     self.assertTrue("3 Messages" in response.content)
 def test_url_upload(self):
   """The page should have the correct number of errors in the header when
   using the pfif_xml_url_1 POST variable to send PFIF XML."""
   utils.set_file_for_test(StringIO(PfifXml.XML_TWO_DUPLICATE_NO_CHILD))
   response = self.make_request({'pfif_xml_url_1' : 'dummy_url'})
   self.assertTrue("3 Messages" in response.content)