<s> from __future__ import unicode_literals <EOL> import mock <EOL> import pytest <EOL> from datetime import date <EOL> from scrapi import requests <EOL> from scrapi . base import OAIHarvester <EOL> from scrapi . linter import RawDocument <EOL> from . utils import TEST_OAI_DOC <EOL> request_url = '<STR_LIT>' <EOL> @ pytest . fixture ( autouse = True ) <EOL> def mock_maybe_load_response ( monkeypatch ) : <EOL> mock_mlr = mock . Mock ( ) <EOL> mock_mlr . return_value = requests . HarvesterResponse ( <EOL> ok = True , <EOL> method = '<STR_LIT>' , <EOL> url = request_url . lower ( ) , <EOL> content = TEST_OAI_DOC , <EOL> ) <EOL> mock_save = lambda x : x <EOL> monkeypatch . setattr ( requests , '<STR_LIT>' , mock_mlr ) <EOL> monkeypatch . setattr ( requests . HarvesterResponse , '<STR_LIT>' , mock_save ) <EOL> @ pytest . fixture ( autouse = True ) <EOL> def mock_requests ( monkeypatch ) : <EOL> mock_req = mock . Mock ( ) <EOL> monkeypatch . setattr ( requests , '<STR_LIT>' , mock_req ) <EOL> return mock_req <EOL> @ pytest . fixture ( autouse = True ) <EOL> def mock_record_transactions ( monkeypatch ) : <EOL> monkeypatch . setattr ( requests . settings , '<STR_LIT>' , True ) <EOL> class TestHarvester ( OAIHarvester ) : <EOL> base_url = '<STR_LIT>' <EOL> long_name = '<STR_LIT>' <EOL> short_name = '<STR_LIT:test>' <EOL> url = '<STR_LIT:test>' <EOL> property_list = [ '<STR_LIT:type>' , '<STR_LIT:source>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:date>' ] <EOL> verify = True <EOL> def harvest ( self , start_date = None , end_date = None ) : <EOL> start_date = date ( <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT> ) <EOL> end_date = date ( <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT:16> ) <EOL> records = self . get_records ( request_url , start_date , end_date ) <EOL> return [ RawDocument ( { <EOL> '<STR_LIT>' : TEST_OAI_DOC , <EOL> '<STR_LIT:source>' : '<STR_LIT:test>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : "<STR_LIT:1>" <EOL> } ) for record in records ] <EOL> class TestOAIHarvester ( object ) : <EOL> def setup_method ( self , method ) : <EOL> self . harvester = TestHarvester ( ) <EOL> def test_normalize ( self ) : <EOL> results = [ <EOL> self . harvester . normalize ( record ) for record in self . harvester . harvest ( ) <EOL> ] <EOL> for res in results : <EOL> assert res [ '<STR_LIT:title>' ] == '<STR_LIT>' </s>
