"""Tự kiểm hồ sơ shop (shop/): tra hồ sơ, mã lạ, shop chưa sẵn sàng, tệp chỉ mục riêng."""
import os
import sys

sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

import shop  # noqa: E402

t = shop.lay('tradingauto')
assert t.ten == 'TradingAuto' and t.nganh == 'trading' and t.co_tra_key and t.co_dat_code
assert shop.lay('khong-co') is t and shop.lay(None) is t, 'mã lạ -> shop mặc định'
assert shop.co('tradingauto') and not shop.co('khong-co')
s = shop._CAC_SHOP['spa']
assert s.nganh == 'spa' and not shop.co('spa'), 'spa chưa sẵn sàng thì cổng phải chặn'
assert t.tep_chi_muc('/x').endswith('chi_muc.sqlite') and s.tep_chi_muc('/x').endswith('chi_muc_spa.sqlite')
assert [h.ma for h in shop.ds_shop(chi_san_sang=True)] == ['tradingauto']
print('THU_SHOP: QUA HẾT.', [h.ma for h in shop.ds_shop()])
