Пример #1
0
    def test_request_multiple_valid_paths(self):
        "sends multiple articles to lax given paths to xml files"
        paths = [self.small_doc] * 3  # send the same article three times

        expected_lax_response = {
            # "id": '09560',
            "id": "16695",
            "requested-action": 'ingest',
            "token": 'pants-party',  # set by fs-adaptor
            "status": conf.INGESTED,
            "message": '...?',
            "datetime": utils.ymdhms(datetime.now())
        }
        expected = {
            'valid': [expected_lax_response] * 3,
            'errors': [],
            'invalid': []
        }

        with mock.patch('adaptor.call_lax',
                        autospec=True,
                        specset=True,
                        return_value=expected_lax_response):
            actual = bfup.do_paths(paths)
            self.assertTrue(partial_match(expected, actual))
Пример #2
0
 def test_request_lax_style(self):
     "dictionaries of article information can be fed in"
     paths = [{
         'msid':
         16695,
         'version':
         1,
         'location':
         'https://s3-external-1.amazonaws.com/elife-publishing-expanded/16695.1/9c2cabd8-a25a-4d76-9f30-1c729755480b/elife-16695-v1.xml',
     }]
     expected_lax_response = {
         "id": "16695",
         "requested-action": 'ingest',
         "token": 'pants-party',
         "status": conf.INGESTED,
         "message": '...?',
         "datetime": utils.ymdhms(datetime.now())
     }
     expected = {
         'valid': [expected_lax_response],
         'errors': [],
         'invalid': []
     }
     with mock.patch('adaptor.call_lax',
                     autospec=True,
                     specset=True,
                     return_value=expected_lax_response):
         with mock.patch('adaptor.http_download',
                         autospec=True,
                         return_value=open(self.small_doc, 'r')):
             actual = bfup.do_paths(paths)
             self.assertTrue(partial_match(expected, actual))