import os
import pytest
import shutil
from fastapi.testclient import TestClient
from calculate.server.server import Server


TESTFILES_PATH = os.path.join(os.getcwd(), 'tests/server/testfiles')
VARS_PATH = os.path.join(TESTFILES_PATH, 'variables')
COMMANDS_PATH = 'tests/server/testfiles/commands'
server = Server(datavars_path=VARS_PATH, commands_path=COMMANDS_PATH)
test_client = TestClient(server.app)


@pytest.mark.server
class TestServer:
    pass
    # def test_to_make_testfiles(self):
    #     shutil.copytree(os.path.join(TESTFILES_PATH, 'var.backup'),
    #                     os.path.join(TESTFILES_PATH, 'var'),
    #                     symlinks=True)
    #     shutil.copytree(os.path.join(TESTFILES_PATH, 'etc.backup'),
    #                     os.path.join(TESTFILES_PATH, 'etc'),
    #                     symlinks=True)

    # def test_get_root_message(self):
    #     response = test_client.get("/")
    #     assert response.status_code == 200
    #     assert response.json() == {"msg": "root msg"}

    # def test_get_commands_list(self):
    #     response = test_client.get("/commands")
    #     assert response.status_code == 200
    #     assert response.json() == {"test_1":
    #                                {"title": "Test 1",
    #                                 "category": "Test Category",
    #                                 "icon": "/path/to/icon_1.png",
    #                                 "command": "test_1"},
    #                                "test_2":
    #                                {"title": "Test 2",
    #                                 "category": "Test Category",
    #                                 "icon": "/path/to/icon_2.png",
    #                                 "command": "cl_test_2"}}

    # def test_post_command(self):
    #     response = test_client.get("/commands/")
    #     assert response.status_code == 200

    # def test_get_command_by_cid(self):
    #     response = test_client.get("/commands/0")
    #     assert response.status_code == 200
    #     assert response.json() == {"id": 0, "name": "command_0"}

    # def test_get_worker_message_by_wid(self):
    #     response = test_client.get("/workers/0")
    #     assert response.status_code == 200
    #     data = response.json()
    #     assert data == {'type': 'log', 'level': 'INFO',
    #                     'msg': 'recieved message INFO'}

    # def test_for_removing_testfiles(self):
    #     shutil.rmtree(os.path.join(TESTFILES_PATH, 'var'))
    #     shutil.rmtree(os.path.join(TESTFILES_PATH, 'etc'))
