# region PROBLEM
'''
<> LL: Constructor
You are tasked with implementing a basic data structure: a singly linked list.

To accomplish this, you will create two classes, Node and LinkedList.

The Node class will represent an individual node within the linked list, while the LinkedList class will manage the overall list structure.

Your implementation should satisfy the following requirements:

Create a Node class with the following features:
- A constructor that takes a value as an argument and initializes the value attribute of the node.
- A next attribute, initialized to None, which will store a reference to the next node in the list.

Create a LinkedList class with the following features:
- A constructor that takes a value as an argument, creates a new Node with that value, and initializes the head and tail attributes of the linked list to point to the new node.
- A length attribute, initialized to 1, which represents the current number of nodes in the list.

Example:
    my_linked_list = LinkedList(4)
    print('Head:', my_linked_list.head.value)
    print('Tail:', my_linked_list.tail.value)
    print('Length:', my_linked_list.length)

Expected output:
    Head: 4
    Tail: 4
    Length: 1
'''
# endregion


# region SOLUTION

class Node():
    
    def __init__(self, value):
        self.value = value
        self.next = None
        
class LinkedList():
    
    def __init__(self, value):
        self.value = Node(value)
        self.value.next = None
        self.head = self.value
        self.tail = self.value
        self.length = 1

# endregion


# region TESTS

def test_node_value():
    node = Node(5)
    assert node.value == 5


def test_node_next_defaults_to_none():
    node = Node(5)
    assert node.next is None


def test_linked_list_head_value():
    ll = LinkedList(4)
    assert ll.head.value == 4


def test_linked_list_tail_is_head():
    ll = LinkedList(4)
    assert ll.tail is ll.head


def test_linked_list_length_is_one():
    ll = LinkedList(4)
    assert ll.length == 1


def test_linked_list_head_next_is_none():
    ll = LinkedList(4)
    assert ll.head.next is None


if __name__ == "__main__":
    import pytest

    raise SystemExit(pytest.main([__file__, "-v"]))

# endregion
