Browse Source

Fixed unittests.

pyrrh0n1c 7 years ago
parent
commit
a1d1a50149
1 changed files with 7 additions and 6 deletions
  1. 7
    6
      tests/unit/engines/test_currency_convert.py

+ 7
- 6
tests/unit/engines/test_currency_convert.py View File

17
         query = b'convert 10 Pound Sterlings to United States Dollars'
17
         query = b'convert 10 Pound Sterlings to United States Dollars'
18
         params = currency_convert.request(query, dicto)
18
         params = currency_convert.request(query, dicto)
19
         self.assertIn('url', params)
19
         self.assertIn('url', params)
20
-        self.assertIn('finance.yahoo.com', params['url'])
20
+        self.assertIn('finance.google.com', params['url'])
21
         self.assertIn('GBP', params['url'])
21
         self.assertIn('GBP', params['url'])
22
         self.assertIn('USD', params['url'])
22
         self.assertIn('USD', params['url'])
23
 
23
 
31
         response = mock.Mock(text='a,b,c,d', search_params=dicto)
31
         response = mock.Mock(text='a,b,c,d', search_params=dicto)
32
         self.assertEqual(currency_convert.response(response), [])
32
         self.assertEqual(currency_convert.response(response), [])
33
 
33
 
34
-        csv = "2,0.5,1"
35
-        response = mock.Mock(text=csv, search_params=dicto)
34
+        body = "<span class=bld>0.5 {}</span>".format(dicto['to'])
35
+        response = mock.Mock(text=body, search_params=dicto)
36
         results = currency_convert.response(response)
36
         results = currency_convert.response(response)
37
         self.assertEqual(type(results), list)
37
         self.assertEqual(type(results), list)
38
         self.assertEqual(len(results), 1)
38
         self.assertEqual(len(results), 1)
39
         self.assertEqual(results[0]['answer'], '10.0 GBP = 5.0 USD, 1 GBP (pound sterling)' +
39
         self.assertEqual(results[0]['answer'], '10.0 GBP = 5.0 USD, 1 GBP (pound sterling)' +
40
                          ' = 0.5 USD (United States dollar)')
40
                          ' = 0.5 USD (United States dollar)')
41
-        now_date = datetime.now().strftime('%Y%m%d')
42
-        self.assertEqual(results[0]['url'], 'https://finance.yahoo.com/currency/converter-results/' +
43
-                                            now_date + '/10.0-gbp-to-usd.html')
41
+
42
+        target_url = 'https://finance.google.com/finance?q={}{}'.format(
43
+            dicto['from'], dicto['to'])
44
+        self.assertEqual(results[0]['url'], target_url)