Exemplo n.º 1
0
    def test_assert_document_already_processed_negative(self):
        config = mock.Mock()
        config.display.columns = {LSTAIL_DEFAULT_FIELD_DOCUMENT_ID: None}

        logger = LstailLogger(config, output=sys.stdout, verbose=False)
        logger._setup_processed_ids_queue()

        _id = str(uuid4())
        document_values = {LSTAIL_DEFAULT_FIELD_DOCUMENT_ID: _id}
        # this is OK, the passed ID is first seen
        logger._assert_document_already_processed(document_values)
        # this one should raise an exception
        with self.assertRaises(DocumentIdAlreadyProcessedError):
            logger._assert_document_already_processed(document_values)
Exemplo n.º 2
0
    def test_assert_document_already_processed_positive(self):
        config = mock.Mock()
        config.display.columns = {LSTAIL_DEFAULT_FIELD_DOCUMENT_ID: None}
        logger = LstailLogger(config, output=sys.stdout, verbose=False)
        logger._setup_processed_ids_queue()

        # positive test - uuid
        _id = str(uuid4())
        document_values = {LSTAIL_DEFAULT_FIELD_DOCUMENT_ID: _id}
        logger._assert_document_already_processed(document_values)
        # check
        self.assertIn(_id, logger._processed_ids)

        # positive test - internal dummy id
        _id = LSTAIL_INTERNAL_DOCUMENT_ID
        document_values = {LSTAIL_DEFAULT_FIELD_DOCUMENT_ID: _id}
        logger._assert_document_already_processed(document_values)