def test_parse_newsml(self): with open(self.fixture, 'rb') as f: parser = NewsMLTwoFeedParser() xml = ElementTree.parse(f) items = parser.parse(xml.getroot(), self.provider) self.assertEqual(items[0]['headline'], 'Pope Francis leaves Peru at end of Latin American trip') self.assertEqual(items[0]['place'], [{'name': 'Euro Zone'}])
def setUp(self): dirname = os.path.dirname(os.path.realpath(__file__)) fixture = os.path.normpath(os.path.join(dirname, '../fixtures', self.filename)) provider = {'name': 'Test'} with open(fixture, 'rb') as f: parser = NewsMLTwoFeedParser() self.xml = ElementTree.parse(f) self.item = parser.parse(self.xml.getroot(), provider)
def setUp(self): dirname = os.path.dirname(os.path.realpath(__file__)) fixture = os.path.normpath(os.path.join(dirname, '../fixtures', self.filename)) provider = {'name': 'Test'} with open(fixture, 'rb') as f: parser = NewsMLTwoFeedParser() self.xml = ElementTree.parse(f) self.item = parser.parse(self.xml.getroot(), provider)
def test_parse_newsml(self): with open(self.fixture, 'rb') as f: parser = NewsMLTwoFeedParser() xml = ElementTree.parse(f) items = parser.parse(xml.getroot(), self.provider) self.assertEqual( items[0]['headline'], 'Pope Francis leaves Peru at end of Latin American trip') self.assertEqual(items[0]['place'], [{'name': 'Euro Zone'}])
def setUp(self): app = flask.Flask(__name__) dirname = os.path.dirname(os.path.realpath(__file__)) fixture = os.path.normpath( os.path.join(dirname, '../fixtures', self.filename)) provider = {'name': 'Test'} with open(fixture, 'rb') as f: self.parser = NewsMLTwoFeedParser() self.xml = ElementTree.parse(f) with app.app_context(): self.item = self.parser.parse(self.xml.getroot(), provider)
def setUp(self): app = flask.Flask(__name__) app.api_prefix = "/api" init_subjects(app) dirname = os.path.dirname(os.path.realpath(__file__)) fixture = os.path.normpath( os.path.join(dirname, "../fixtures", self.filename)) provider = {"name": "Test"} with open(fixture, "rb") as f: self.parser = NewsMLTwoFeedParser() self.xml = ElementTree.parse(f) with app.app_context(): self.item = self.parser.parse(self.xml.getroot(), provider)
def setUp(self): with self.app.app_context(): self.app.data.insert('vocabularies', self.vocab) dirname = os.path.dirname(os.path.realpath(__file__)) fixture = os.path.normpath( os.path.join(dirname, '../fixtures', self.filename)) provider = {'name': 'Test'} with open(fixture, 'rb') as f: self.root_elt = etree.fromstring(f.read()) self.items = NewsMLTwoFeedParser().parse(self.root_elt, provider)
class BaseNewMLTwoTestCase(unittest.TestCase): def setUp(self): app = flask.Flask(__name__) app.api_prefix = '/api' init_subjects(app) dirname = os.path.dirname(os.path.realpath(__file__)) fixture = os.path.normpath( os.path.join(dirname, '../fixtures', self.filename)) provider = {'name': 'Test'} with open(fixture, 'rb') as f: self.parser = NewsMLTwoFeedParser() self.xml = ElementTree.parse(f) with app.app_context(): self.item = self.parser.parse(self.xml.getroot(), provider)
def test_can_parse(self): self.assertTrue(NewsMLTwoFeedParser().can_parse(self.xml.getroot()))
def test_can_parse(self): self.assertTrue(NewsMLTwoFeedParser().can_parse(self.root_elt))