コード例 #1
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'}])
コード例 #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)
コード例 #3
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)
コード例 #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'}])
コード例 #5
0
 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)
コード例 #6
0
 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)
コード例 #7
0
 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)
コード例 #8
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)
コード例 #9
0
 def test_can_parse(self):
     self.assertTrue(NewsMLTwoFeedParser().can_parse(self.xml.getroot()))
コード例 #10
0
 def test_can_parse(self):
     self.assertTrue(NewsMLTwoFeedParser().can_parse(self.root_elt))