~facundo/ubuntu-rest-scopes/7digital-forbidden-countries-8

« back to all changes in this revision

Viewing changes to src/scopes/tests/test_weatherchannel.py

  • Committer: Tarmac
  • Author(s): Facundo Batista
  • Date: 2016-05-27 12:36:21 UTC
  • mfrom: (520.1.1 twc-support-not-dates)
  • Revision ID: tarmac-20160527123621-sowfy4if31s665lp
[r=ralsina] Support null values in sun rise & set.

Show diffs side-by-side

added added

removed removed

Lines of Context:
239
239
                'max_temp': None,
240
240
                'min_temp': u'4°C',
241
241
                'pop': u'20%',
242
 
                'conditions':  u'\u5c11\u4e91\u3002 \u6700\u4f4e 4\xbaC\u3002',
 
242
                'conditions': u'\u5c11\u4e91\u3002 \u6700\u4f4e 4\xbaC\u3002',
243
243
                'current_temp': u'6°C',
244
244
                'date': u'08 Feb',
245
245
                'day': u'今天晚上',
333
333
        mock.assert_called_with(query)
334
334
        self.assertDictEqual(resp[1]['result'], {
335
335
            'cat_id': 'cat-list',
336
 
            'preview_info':  {
 
336
            'preview_info': {
337
337
                'latitude': '123',
338
338
                'longitude': '456',
339
339
                'type': 'location'
839
839
        self.assertEqual(resp[0]['sunrise'], None)
840
840
        self.assertEqual(resp[0]['sunset'], None)
841
841
 
 
842
    def test_forecast_parsing_bad_sun_rise_set(self):
 
843
        twci = weatherchannel.TWCInterface('urlread', 'foo', FAKE_AUTH, 'es_AR', 'desktop')
 
844
        forecast = json.loads(get_fixture('weatherchannel-bad-sunriseset.json'))
 
845
        with patch.object(weatherchannel.TWCInterface, 'get_location') as mock:
 
846
            mock.return_value = {}
 
847
            resp = twci._parse_forecast(forecast, 123, 456)
 
848
 
 
849
        # check we nulled those fields
 
850
        self.assertEqual(len(resp), 11)
 
851
        self.assertEqual(resp[0]['sunrise'], None)
 
852
        self.assertEqual(resp[0]['sunset'], None)
 
853
 
842
854
    def test_forecast_parsing_missing_humidity(self):
843
855
        twci = weatherchannel.TWCInterface('urlread', 'foo', FAKE_AUTH, 'en_US', 'desktop')
844
856
        forecast = json.loads(get_fixture('weatherchannel-no-humid.json'))