Commits

Jason R. Coombs  committed fc41673

Expanded basic test

  • Participants
  • Parent commits 05fefe1

Comments (0)

Files changed (2)

File wolframalpha/__init__.py

     def __init__(self, stream):
         self.tree = etree.parse(stream)
 
+    def __iter__(self):
+        return (Pod(node) for node in self.tree.findall('pod'))
+
+    def __len__(self):
+        return len(self.tree)
+
     @property
     def pods(self):
-        return map(Pod, self.tree.findall('pod'))
+        return list(iter(self))
+
+    @property
+    def results(self):
+        return (pod for pod in self if pod.title=='Result')
 
 class Pod(object):
     def __init__(self, node):
         self.__dict__.update(node.attrib)
 
     def __iter__(self):
-        return (Content(node) for node in self.nodes.findall('subpod'))
+        return (Content(node) for node in self.node.findall('subpod'))
 
     @property
     def main(self):

File wolframalpha/test_client.py

+#-*- coding: utf-8 -*-
+
+from __future__ import unicode_literals
+
 import wolframalpha
 
 app_id = 'Q59EW4-7K8AHE858R'
 def test_basic():
 	client = wolframalpha.Client(app_id)
 	res = client.query('30 deg C in deg F')
-	import pytest; pytest.set_trace()
+	assert len(res.pods) > 0
+	results = list(res.results)
+	assert results[0].text == '86 °F  (degrees Fahrenheit)'