<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
import datetime

from dateutil.tz import tzfile
from flask import json
from main import app
import unittest
from unittest.mock import patch


class MainApiTests(unittest.TestCase):

    def setUp(self):
        self.app = app.test_client()
        self.app.testing = True

    @patch('sophiabus230.get_next_buses')
    def test_get_no_buses(self, mock_bus):
        mock_bus.return_value = []
        result = self.app.get('/bus230')
        json_data = json.loads(result.data)
        self.assertEqual(json_data, [])
        self.assertEqual(result.status_code, 200)

    @patch('sophiabus230.get_next_buses')
    def test_get(self, mock_bus):

        expected_tt = [
            {'dest': 'Cathédrale-Vieille Ville',
             'is_real_time': True,
             'bus_time': '2017-01-19T17:23:06.302989+01:00'
             },
            {'dest': 'Cathédrale-Vieille Ville',
             'is_real_time': False,
             'bus_time': '2017-01-19T17:32:00'
             }
            ]
        mock_bus.return_value = [
            {'dest': b'Cath\xc3\xa9drale-Vieille Ville',
             'is_real_time': True,
             'bus_time': datetime.datetime(2017, 1, 19, 17, 23, 6, 302989,
                                           tzinfo=tzfile('/usr/share/zoneinfo/Europe/Paris'))
             },
            {'dest': b'Cath\xc3\xa9drale-Vieille Ville',
             'is_real_time': False,
             'bus_time': datetime.datetime(2017, 1, 19, 17, 32)
             }
            ]
        result = self.app.get('/bus230')
        json_data = json.loads(result.data)
        self.assertEqual(json_data, expected_tt)
        self.assertEqual(result.status_code, 200)
<commit_msg>Fix package issue<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
import datetime

from dateutil.tz import tzfile
from flask import json
from .main import app
import unittest
from unittest.mock import patch


class MainApiTests(unittest.TestCase):

    def setUp(self):
        self.app = app.test_client()
        self.app.testing = True

    @patch('sophiabus230.get_next_buses')
    def test_get_no_buses(self, mock_bus):
        mock_bus.return_value = []
        result = self.app.get('/bus230')
        json_data = json.loads(result.data)
        self.assertEqual(json_data, [])
        self.assertEqual(result.status_code, 200)

    @patch('sophiabus230.get_next_buses')
    def test_get(self, mock_bus):

        expected_tt = [
            {'dest': 'Cathédrale-Vieille Ville',
             'is_real_time': True,
             'bus_time': '2017-01-19T17:23:06.302989+01:00'
             },
            {'dest': 'Cathédrale-Vieille Ville',
             'is_real_time': False,
             'bus_time': '2017-01-19T17:32:00'
             }
            ]
        mock_bus.return_value = [
            {'dest': b'Cath\xc3\xa9drale-Vieille Ville',
             'is_real_time': True,
             'bus_time': datetime.datetime(2017, 1, 19, 17, 23, 6, 302989,
                                           tzinfo=tzfile('/usr/share/zoneinfo/Europe/Paris'))
             },
            {'dest': b'Cath\xc3\xa9drale-Vieille Ville',
             'is_real_time': False,
             'bus_time': datetime.datetime(2017, 1, 19, 17, 32)
             }
            ]
        result = self.app.get('/bus230')
        json_data = json.loads(result.data)
        self.assertEqual(json_data, expected_tt)
        self.assertEqual(result.status_code, 200)

{'fraction_non_alphanumeric': 0.1278969957081545, 'fraction_numerical': 0.05150214592274678, 'mean_word_length': 2.0242214532871974, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3685748', 'n_tokens_mistral': 1280, 'n_tokens_neox': 1131, 'n_words': 196}