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'}])
Esempio n. 2
0
 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)
Esempio n. 4
0
 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'}])
Esempio n. 5
0
class BaseNewMLTwoTestCase(unittest.TestCase):
    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)
Esempio n. 6
0
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)