nasa / pyCMR

Client for CMR APIs
Apache License 2.0
23 stars 12 forks source link

Fix failing test in master branch #24

Open lewismc opened 7 years ago

lewismc commented 7 years ago

From travis-ci build

================================================================================================= FAILURES =================================================================================================
_____________________________________________________________________________________ TestCMRIntegration.test_monolith _____________________________________________________________________________________

self = <pyCMR.tests.test_cmr_integration.TestCMRIntegration testMethod=test_monolith>

    def test_monolith(self):
         '''
             Since these are order-sensitive integration tests,
             wrap them in a monolithic test, so that they run in the proper order
             and stop after a single failure (without having to specify `failfast`)

             https://stackoverflow.com/questions/5387299/python-unittest-testcase-execution-order
             '''

         for test_name in [
             'collection_search',
             'granule_search',
             'collection_ingest',
             'granule_ingest',
             'collection_update',
             'granule_update',
             'granule_delete',
             'collection_delete'
         ]:
             test = getattr(self, test_name)
>            test()

pyCMR/tests/test_cmr_integration.py:95:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pyCMR/tests/test_cmr_integration.py:42: in collection_ingest
    result = self.cmr.ingestCollection(self._test_collection_path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <pyCMR.pyCMR.CMR object at 0x1095457b8>, XMLData = '/usr/local/cmr/pyCMR/tests/fixtures/test-collection.xml'

    def ingestCollection(self, XMLData):
        """
            :purpose : ingest the collections using cmr rest api
            :param XMLData: a parameter that holds the XML data that needs to be ingested it can be a file
            :return: the ingest collection request if it is successfully validated
            """

        if not XMLData:
            return False

        if os.path.isfile(XMLData):
            data = self._getXMLData(pathToXMLFile=XMLData)
        else:
            data=XMLData

        dataset_id = self._getDataSetId(pathToXMLFile=data)
        url = self._INGEST_URL + self._PROVIDER + "/collections/" + dataset_id
        validationRequest = self._validateCollection(data=data, dataset_id=dataset_id)
        if validationRequest.ok:  # if the collection is valid
            if self.isTokenExpired():  # check if the token has been expired
                self._generateNewToken()
            putCollection = self.session.put(url=url, data=data, headers=self._INGEST_HEADER)  # ingest granules

            return putCollection.content

        else:
>           raise ValueError("Collection failed to validate:\n{}".format(validationRequest.content))
E           ValueError: Collection failed to validate:
E           b'<?xml version="1.0" encoding="UTF-8"?><errors><error>Provider with provider-id [*****] does not exist.</error></errors>'

pyCMR/pyCMR.py:223: ValueError
=================================================================================== 1 failed, 1 passed in 17.67 seconds ====================================================================================
amarouane commented 7 years ago

It is failing because the provider/password is not correctly defined in configfile.

On Thu, Jul 13, 2017 at 2:25 PM, Lewis John McGibbney < notifications@github.com> wrote:

From travis-ci build

================================================================================================= FAILURES ================================================================================================= _____ TestCMRIntegration.testmonolith ____

self =

def test_monolith(self):
     '''
         Since these are order-sensitive integration tests,
         wrap them in a monolithic test, so that they run in the proper order
         and stop after a single failure (without having to specify `failfast`)

         https://stackoverflow.com/questions/5387299/python-unittest-testcase-execution-order
         '''

     for test_name in [
         'collection_search',
         'granule_search',
         'collection_ingest',
         'granule_ingest',
         'collection_update',
         'granule_update',
         'granule_delete',
         'collection_delete'
     ]:
         test = getattr(self, test_name)
       test()

pyCMR/tests/test_cmr_integration.py:95:


pyCMR/tests/test_cmr_integration.py:42: in collection_ingest result = self.cmr.ingestCollection(self._test_collection_path)


self = <pyCMR.pyCMR.CMR object at 0x1095457b8>, XMLData = '/usr/local/cmr/pyCMR/tests/fixtures/test-collection.xml'

def ingestCollection(self, XMLData):
    """
        :purpose : ingest the collections using cmr rest api
        :param XMLData: a parameter that holds the XML data that needs to be ingested it can be a file
        :return: the ingest collection request if it is successfully validated
        """

    if not XMLData:
        return False

    if os.path.isfile(XMLData):
        data = self._getXMLData(pathToXMLFile=XMLData)
    else:
        data=XMLData

    dataset_id = self._getDataSetId(pathToXMLFile=data)
    url = self._INGEST_URL + self._PROVIDER + "/collections/" + dataset_id
    validationRequest = self._validateCollection(data=data, dataset_id=dataset_id)
    if validationRequest.ok:  # if the collection is valid
        if self.isTokenExpired():  # check if the token has been expired
            self._generateNewToken()
        putCollection = self.session.put(url=url, data=data, headers=self._INGEST_HEADER)  # ingest granules

        return putCollection.content

    else:
      raise ValueError("Collection failed to validate:\n{}".format(validationRequest.content))

E ValueError: Collection failed to validate: E b'<?xml version="1.0" encoding="UTF-8"?>Provider with provider-id [*****] does not exist.'

pyCMR/pyCMR.py:223: ValueError =================================================================================== 1 failed, 1 passed in 17.67 seconds ====================================================================================

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ghrcdaac/cmr/issues/24, or mute the thread https://github.com/notifications/unsubscribe-auth/AKNwPqaZDJCVkvJ4jhMhItbLm9CZC_-_ks5sNm9EgaJpZM4OXbyy .

-- Abdelhak MAROUANE Doctorant au Laboratoire des Recherches Subatomiques et Applications (LRSA) Faculté des Sciences Ben M'sik UNIVERSITE HASSAN II–MOHAMMEDIA-CASABLANCA GSM: (+212) 6-69-42-05-27 E-mail : abdelhak.marouane@univh2m.ac.ma

lewismc commented 7 years ago

I know that, we should however set up a dummy account and password for the purposes of testing this codebase.

amarouane commented 7 years ago

Yes we did apply for test credentials and as soon as we get them I will push the new config file.

On Thu, Jul 13, 2017 at 2:48 PM, Lewis John McGibbney < notifications@github.com> wrote:

I know that, we should however set up a dummy account and password for the purposes of testing this codebase.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ghrcdaac/cmr/issues/24#issuecomment-315183053, or mute the thread https://github.com/notifications/unsubscribe-auth/AKNwPmaD5YuBSoglJRNZbr6dOSlyHJCDks5sNnSFgaJpZM4OXbyy .

-- Abdelhak MAROUANE Doctorant au Laboratoire des Recherches Subatomiques et Applications (LRSA) Faculté des Sciences Ben M'sik UNIVERSITE HASSAN II–MOHAMMEDIA-CASABLANCA GSM: (+212) 6-69-42-05-27 E-mail : abdelhak.marouane@univh2m.ac.ma