Exemple #1
0
def yahoo_fetcher(stock, start, end):
    with rest.create(YAHOO_HOST) as c:
        c.move(YAHOO_APP)
        c.query("s",stock).query("ignore",".csv")
        c.params.update(map_date(["a","b","c"],start))
        c.params.update(map_date(["d","e","f"],end))
        c.query("g","d")
        resp = c.get()
        if not resp.status == 200:
            raise IOError("Failed to fetch index data. Error code : %i" % resp.status)
        return resp.read()
Exemple #2
0
def yahoo_fetcher(stock, start, end):
    with rest.create(YAHOO_HOST) as c:
        c.move(YAHOO_APP)
        c.query("s", stock).query("ignore", ".csv")
        c.params.update(map_date(["a", "b", "c"], start))
        c.params.update(map_date(["d", "e", "f"], end))
        c.query("g", "d")
        resp = c.get()
        if not resp.status == 200:
            raise IOError("Failed to fetch index data. Error code : %i" %
                          resp.status)
        return resp.read()
Exemple #3
0
 def setUp(self):
     self.subject = rest.create(HOST)
Exemple #4
0
 def test_get_fetches_a_body(self):
     with rest.create(VALID_HOST) as c:
         response = c.get()
         self.assertTrue(response.status < 400)
         self.assertTrue(len(response.read()) > 0)
Exemple #5
0
 def test_head_fetches_no_body(self):
     with rest.create(VALID_HOST) as c:
         response = c.head()
         self.assertTrue(response.status < 400)
         self.assertEqual(0, len(response.read()))
Exemple #6
0
 def test_context_autoconnects(self):
     with rest.create(VALID_HOST) as client:
         self.assertTrue(client.isConnected())
Exemple #7
0
 def test_invalid_host_fails_on_connecting(self):
     self.subject = rest.create(INVALID_HOST)
     with self.assertRaises(InvalidURL):
         self.subject.connect()
Exemple #8
0
 def test_can_connect_to_valid(self):
     self.subject = rest.create(VALID_HOST)
     self.subject.connect()
     self.assertTrue(self.subject.isConnected())
Exemple #9
0
 def test_is_disconnected_before_connecting(self):
     self.subject = rest.create(INVALID_HOST)
     self.assertFalse(self.subject.isConnected())
 def test_get_fetches_a_body(self):
     with rest.create(VALID_HOST) as c:
         response = c.get()
         self.assertTrue(response.status < 400)
         self.assertTrue(len(response.read()) > 0)
 def test_head_fetches_no_body(self):
     with rest.create(VALID_HOST) as c:
         response = c.head()
         self.assertTrue(response.status < 400)
         self.assertEqual(0, len(response.read()))
 def test_context_autoconnects(self):
     with rest.create(VALID_HOST) as client:
         self.assertTrue(client.isConnected())
 def test_invalid_host_fails_on_connecting(self):
     self.subject = rest.create(INVALID_HOST)
     with self.assertRaises(InvalidURL):
         self.subject.connect()
 def test_can_connect_to_valid(self):
     self.subject = rest.create(VALID_HOST)
     self.subject.connect()
     self.assertTrue(self.subject.isConnected())
 def test_is_disconnected_before_connecting(self):
     self.subject = rest.create(INVALID_HOST)
     self.assertFalse(self.subject.isConnected())