from repository import Repository
from controller import Controller
from datetime import date
from reservation import Reservation

def test_get_empty_rooms():
    f=open("test_data.txt","w")
    f.close()
    repo = Repository("test_data.txt")
    controller = Controller(repo)
    rooms = controller.get_empty_rooms(date(2023, 1, 1),date(2023, 1, 1))
    assert len(rooms) == 5
    print("test_get_empty_rooms passed")

def test_get_empty_rooms_repo():
    f=open("test_data.txt","w")
    f.close()
    repo = Repository("test_data.txt")
    rooms = repo.get_empty_rooms(date(2023, 1, 1),date(2023, 1, 1))
    assert len(rooms) == 5
    print("test_get_empty_rooms_repo passed")

def test_create_reservation_repo():
    f=open("test_data.txt","w")
    f.close()
    repo = Repository("test_data.txt")
    repo.add_reservation(Reservation("1","Smith", "John", "01", "1", date(2023, 1, 1), date(2023, 1, 2)))
    assert len(repo.get_all()) == 1
    print("test_create_reservation passed")

def test_create_reservation():
    f=open("test_data.txt","w")
    f.close()
    repo = Repository("test_data.txt")
    controller = Controller(repo)
    controller.create_reservation("Smith", "John", "01", "1", date(2023, 1, 1), date(2023, 1, 2))
    assert len(repo.get_all()) == 1
    print("test_create_reservation passed")

if __name__ == "__main__":
    test_get_empty_rooms()
    test_get_empty_rooms_repo()
    test_create_reservation()
    test_create_reservation_repo()