Esempio n. 1
0
    def test_parseRecord(self, mocker):
        testEncRec = {'body': '{"url": "www.testing.url"}'}
        testURL = 's3.testing.url'
        mockCoverParse = mocker.patch('service.CoverParse')()
        mockCoverParse.s3CoverURL = testURL
        mockKinesisPut = MagicMock()
        mocker.patch.dict('os.environ', {'DB_UPDATE_STREAM': 'testing'})

        outURL = parseRecord(testEncRec, mockKinesisPut)
        assert outURL == testURL
        mockCoverParse.storeCover.assert_called_once()
        mockKinesisPut.putKinesis.assert_called_once()
Esempio n. 2
0
 def test_parseRecord_missingBody(self):
     missingBodyRecord = {'record': '{"data": "data"}'}
     with pytest.raises(DataError):
         parseRecord(missingBodyRecord, 'outManager')
Esempio n. 3
0
 def test_parseRecord_invalidJSON(self):
     malformedJSON = {'body': '{"field: "its missing a quotation mark"}'}
     with pytest.raises(DataError):
         parseRecord(malformedJSON, 'outManager')
Esempio n. 4
0
 def test_parseRecords_bad_stage(self, mock_json):
     res = parseRecord({'body': {'data': ''}})
     mock_json.assert_called_once()
     self.assertFalse(res)
Esempio n. 5
0
 def test_parseRecords(self, mock_enhance, mock_json):
     res = parseRecord({'body': {'data': ''}})
     mock_enhance.assert_called_once()
     mock_json.assert_called_once()
     self.assertTrue(res)