<reponame>piaoliangkb/task-offloading
import unittest

from server import FlaskTestServerList


class FlaskTestServerListTestCase(unittest.TestCase):
    def test_initialization(self):
        server_list = FlaskTestServerList()
        self.assertEqual(server_list.len(), 2)

        d = {
            "AWS": "172.16.17.32",
            "GCP": "172.16.58.3",
            "Azure": "192.168.127.12",
        }
        server_list1 = FlaskTestServerList.specify_server_list(d)
        self.assertEqual(len(d), server_list1.len())

    def test_update_server_from_list(self):
        server_list = FlaskTestServerList()
        new_servers = ["127.0.0.1", "127.0.0.1", "192.168.3.11"]

        server_list.update_server_list_using_list(new_servers)
        server_list.print_all_servers()

    def test_init_server_from_url(self):
        server_list = FlaskTestServerList().init_server_list_from_url("http://127.0.0.1:5000/getserverlists")
        self.assertEqual(server_list.len(), 3)

        server_list.print_all_servers()


if __name__ == '__main__':
    unittest.main()

import unittest

from server import FlaskTestServerList


class FlaskTestServerListTestCase(unittest.TestCase):
    def test_initialization(self):
        server_list = FlaskTestServerList()
        self.assertEqual(server_list.len(), 2)

        d = {
            "AWS": "172.16.17.32",
            "GCP": "172.16.58.3",
            "Azure": "192.168.127.12",
        }
        server_list1 = FlaskTestServerList.specify_server_list(d)
        self.assertEqual(len(d), server_list1.len())

    def test_update_server_from_list(self):
        server_list = FlaskTestServerList()
        new_servers = ["127.0.0.1", "127.0.0.1", "192.168.3.11"]

        server_list.update_server_list_using_list(new_servers)
        server_list.print_all_servers()

    def test_init_server_from_url(self):
        server_list = FlaskTestServerList().init_server_list_from_url("http://127.0.0.1:5000/getserverlists")
        self.assertEqual(server_list.len(), 3)

        server_list.print_all_servers()


if __name__ == '__main__':
    unittest.main()