from django.test import TestCase
from pos.pos import PosSys
from pos.models import MenuItem
# Create your tests here.

class PosSysTestCase(TestCase):
    def setUp(self):
        PosSys.regis("tum", "patumos@gmail.com", "Tum1984", "Tum1984")
        self.posSys = PosSys.login("tum", "Tum1984")
        self.tableSys = self.posSys.tableSys
        self.menuSys = self.posSys.menuSys
        self.orderSys = self.posSys.orderSys
        self.uiSys = self.posSys.uiSys
        self.storeSys = self.posSys.storeSys

    def test_hello(self):
        self.assertEqual(1, 1)

    def test_create_table(self):
        self.tableSys.create(code="T1", nseats=3)
        print(self.tableSys.list())
        bt = self.tableSys.bookingTbl(code="T1")
        print(bt)

    def test_create_menu(self):
        self.posSys.createSampleMenu()
        print(MenuItem.objects.all())

    def test_create_order(self):
        m1 = self.menuSys.create('Menu 1')
        tbl = self.tableSys.create('T1',3);
        order = self.orderSys.create(tbl.code)
        self.orderSys.putItem(order.id, m1.id, 1)



    def test_settingSys(self):
        settingSys = self.posSys.settingSys
        settingSys.set({'firstTime':True})
        settingSys.commit()
        self.assertEqual(settingSys.get('firstTime'), True)
        settingSys.set({'tum':True, 'name': 'Suebpong'})
        settingSys.commit()

        self.assertEqual(settingSys.get('name'), 'Suebpong')
        print(settingSys.get('name'))

        print(settingSys)

    def test_uiweb(self):
        self.uiSys.menu('primary')
        self.uiSys.menu('footer')

        self.uiSys.search('large')

        modelForm = self.uiSys.form('form-id')

    def test_store_sys(self):
        pass




