class TestWriteCoronaRussia(unittest.TestCase):
    def setUp(self):
        self.update = mock.MagicMock()
        self.corona = WorkWithCoronaData([], count, [], [], {}, 1)
        self.corona1 = WorkWithCoronaData([], count, [], [], {}, 0)

    def test_ok_write(self):
        write_database = mock.MagicMock()
        with patch('chat_bot_template1.write_database', write_database):
            answer = corona_russia_write(self.update)
        self.assertNotEqual(answer, "")

    def test_equal_write(self):
        write_database = mock.MagicMock()
        self.corona.corona_russia()
        data = self.corona.now
        self.corona1.corona_russia()
        answer_2_0 = ''
        for key, value in self.corona1.now.items():
            for key1, value1 in data.items():
                answer_2_0 += f'{str(value[0]).upper()}\n'
                answer_2_0 += f'Confirmed: {value[1] - value1[1]} Deaths: {value[2] - value1[2]} Recovered: ' \
                    f'{value[3] - value1[3]} Active: {value[4] - value1[4]}\n'
        with patch('chat_bot_template1.write_database', write_database):
            answer = corona_russia_write(self.update)
        self.assertEqual(answer, answer_2_0)
def corona_write(update: Updater, day):
    answer = ''
    corona0 = WorkWithCoronaData([], [0] * 1000, [], [], {}, day)
    WorkWithCoronaData.provinces(corona0)
    data = []
    for elem in corona0.count[:5]:
        for row in corona0.prov:
            for key, value in row.items():
                if value[2] == elem:
                    data.append({
                        'Country': value[0],
                        'Province': value[1],
                        'Active': value[2]
                    })
                    answer += f"{value[0]}, {value[1]}: {value[2]}\n"
    write_database("data\\", corona0.data1, 'prov', data)
    return answer
def corona_russia_write(update: Updater):
    answer = ''
    corona0 = WorkWithCoronaData([], [0] * 1000, [], [], {}, 0)
    corona1 = WorkWithCoronaData([], [0] * 1000, [], [], {}, 1)
    WorkWithCoronaData.corona_russia(corona0)
    WorkWithCoronaData.corona_russia(corona1)
    data_1, data = [], []
    for key, value in corona0.now.items():
        for key1, value1 in corona1.now.items():
            data.append({
                "Country_Region": value[0],
                "Confirmed": value[1],
                "Deaths": value[2],
                "Recovered": value[3],
                "Active": value[4]
            })
            data_1.append({
                "Country_Region": value1[0],
                "Confirmed": value1[1],
                "Deaths": value1[2],
                "Recovered": value1[3],
                "Active": value1[4]
            })
            answer += f'{str(value[0]).upper()}\n'
            answer += f'Confirmed: {value[1] - value1[1]} Deaths: {value[2] - value1[2]} Recovered: ' \
                f'{value[3] - value1[3]} Active: {value[4] - value1[4]}\n'
    write_database('data\\', corona0.data1, 'rus', data)
    write_database('data\\', corona1.data1, 'rus', data_1)
    return answer
class TestsWorkWithCoronaData(unittest.TestCase):
    def setUp(self):
        self.corona = WorkWithCoronaData([], [0] * 1000, [], [], {}, 0)

    def tearDown(self):
        self.prov = []
        self.count = []
        self.data1 = []
        self.table = []
        self.now = []
        self.day = 0

    def test_corona_data(self):
        self.corona.get_table()
        data_new = WorkWithCsvTable(data=[])
        data_new.read_table("google.csv")
        data = data_new.get_data()
        self.assertEqual(self.corona.table, data)

    def test_corona_no_data(self):
        self.corona.get_table()
        self.assertNotEqual(self.corona.table, [])
 def setUp(self):
     self.update = mock.MagicMock()
     self.corona = WorkWithCoronaData([], count, [], [], {}, 1)
     self.corona1 = WorkWithCoronaData([], count, [], [], {}, 0)
 def setUp(self):
     self.corona = WorkWithCoronaData([], [0] * 1000, [], [], {}, 0)