示例#1
0
 def __init__(self):
     self.user_manager = UsersManager()
     self.stores_manager = None
     username = self.user_manager.add_guest_user()
     print(username)
     self.user_manager.register(username, "admin")
     self.user_manager.admins.append("admin")
 def setUp(self) -> None:
     self.users_manager = UsersManager()
     date_str = '04-10-2020'
     dt = timedelta(days=10)
     date_object = datetime.strptime(date_str, '%m-%d-%Y')
     self.product_orange = Product("orange", 2, "food", None, 100)
     self.product_orange.discount.append(
         VisibleProductDiscount(date_object, date_object + dt, 50))
     self.product_apple = Product("apple", 2, "food", None, 100)
     self.product_apple.discount.append(
         VisibleProductDiscount(date_object, date_object + dt, 50))
     self.product_petunia = Product("petunia", 5, "food", None, 100)
     self.product_petunia.discount.append(
         VisibleProductDiscount(date_object, date_object + dt, 50))
     self.product_begonia = Product("begonia", 15, "food", None, 100)
     self.product_begonia.discount.append(
         VisibleProductDiscount(date_object, date_object + dt, 50))
示例#3
0
class UsersManagerInterface:
    security = Security()

    def __init__(self):
        self.user_manager = UsersManager()
        username = self.user_manager.add_guest_user()
        self.user_manager.register(username, "admin")
        self.user_manager.admins.append("admin")

    def register(self, username, new_username, password):
        logger.log("user %s called register with new_username:%s", username, new_username)
        if self.user_manager.register(username, new_username):
            self.security.add_user(new_username, password)
            return True
        else:
            return False

    ##EVERYTIME SOMEONE OPENS THE SYSTEM A NEW USER IS CREATEDDDDDDDD
    def login(self, username: str, login_username: str, password) -> bool:
        logger.log("user %s called login with login_username:%s", username, login_username)
        if self.security.verify_password(login_username, password):
            return self.user_manager.login(username, login_username)
        else:
            return False

    def add_guest_user(self):
        return self.user_manager.add_guest_user()

    # look up via usr id change user list to map of ids and user
    def view_cart(self, username) -> Cart:
        logger.log("user %s called view_cart", username)
        return self.user_manager.view_cart(username)

    def logout(self, username):
        return self.user_manager.logout(username)

    def view_purchases(self, username):
        logger.log("user %s called view_purchases", username)
        return self.user_manager.view_purchases(username)

    def add_product(self, username, store_id, product, quantity):
        logger.log("user %s called add prdouct with store_id:%d, product_name:%s, quantity:%d", username, store_id, jsonpickle.decode(product).name, quantity)
        return self.user_manager.add_product(username, store_id, product, quantity)

    def remove_product(self, username, store_id, product, quantity):
        logger.log("user %s called remove product with store_id:%d, product_name:%s, quantity:%d", username, store_id, product.name, quantity)
        return self.user_manager.remove_product(username,store_id, product, quantity)

    def get_cart(self, username):
        return self.user_manager.get_cart(username)

    def view_purchases_admin(self, username, admin):
        logger.log("admin %s called view_purchases_admin for user %s", admin, username)
        return self.user_manager.view_purchases_admin(username, admin)

    def is_admin(self,username):
        return self.user_manager.is_admin(username)

    def add_managed_store(self, username, store_id):
        return self.user_manager.add_managed_store(username, store_id)

    def remove_managed_store(self, username, store_id):
        return self.user_manager.remove_managed_store(username, store_id)

    def get_managed_stores(self, username):
        return self.user_manager.get_managed_stores(username)

    def check_if_registered(self, username):
        return self.user_manager.check_if_registered(username)

    def check_if_loggedin(self, username):
        return self.user_manager.check_if_loggedin(username)

    def add_purchase(self, username, purchase):
        return self.user_manager.add_purchase(username, purchase)

    def remove_cart(self, username):
        return self.user_manager.remove_cart(username)
示例#4
0
 def __init__(self):
     self.user_manager = UsersManager()
     username = self.user_manager.add_guest_user()
     self.user_manager.register(username, "admin")
     self.user_manager.admins.append("admin")
示例#5
0
    def setUp(self) -> None:
        self.users_manager = UsersManager()
        date_str = '04-10-2020'
        dt = timedelta(days=10)
        date_object = datetime.datetime(2020, 4, 10)
        self.product_orange = Product("orange", 2, "food", None, 100)
        self.product_orange.visible_discount.append(
            VisibleProductDiscount(date_object, date_object + dt, 50))
        self.product_apple = Product("apple", 2, "food", None, 100)
        self.product_apple.visible_discount.append(
            VisibleProductDiscount(date_object, date_object + dt, 50))
        self.product_petunia = Product("petunia", 5, "food", None, 100)
        self.product_petunia.visible_discount.append(
            VisibleProductDiscount(date_object, date_object + dt, 50))
        self.product_begonia = Product("begonia", 15, "food", None, 100)
        self.product_begonia.visible_discount.append(
            VisibleProductDiscount(date_object, date_object + dt, 50))

        ###############################################
        self.store_manager = StoresManager()
        self.guest_user = self.users_manager.add_guest_user()
        self.idx = 0

        self.store_id1 = self.users_manager.store_manager.open_store(
            "test store1", "test owner1")
        self.store_id2 = self.users_manager.store_manager.open_store(
            "test store2", "test owner2")
        self.store_id3 = self.users_manager.store_manager.open_store(
            "test store3", "test owner3")
        self.store_id4 = self.users_manager.store_manager.open_store(
            "test store4", "test owner4")

        self.products = {
            "Apple":
            Product("Apple", 20, ["Food"], ["Fruits"], 10),
            "Banana":
            Product("Banana", 20, ["Food"], ["Fruits"], 10),
            "Orange":
            Product("Orange", 20, ["Food"], ["Fruits"], 10),
            "Tomato":
            Product("Tomato", 20, ["Food"], ["Vegetables"], 10),
            "Cucumber":
            Product("Cucumber", 20, ["Food"], ["Vegetables"], 10),
            "Carrot":
            Product("Carrot", 20, ["Food"], ["Vegetables"], 10),
            "Iphone":
            Product("Iphone", 20, ["Electronics"], ["Computers"], 10),
            "Hard Disk":
            Product("Hard Disk", 20, ["Electronics"], ["Computers"], 10),
            "Keyboard":
            Product("Keyboard", 20, ["Electronics"], ["Computers"], 10)
        }

        self.users_manager.store_manager.get_store(
            self.store_id1).inventory.products = self.products
        self.users_manager.store_manager.get_store(
            self.store_id2).inventory.products = self.products
        self.users_manager.store_manager.get_store(
            self.store_id3).inventory.products = self.products
        self.users_manager.store_manager.get_store(
            self.store_id4).inventory.products = self.products

        self.discount = VisibleProductDiscount(datetime.datetime(2018, 6, 1),
                                               datetime.datetime(2020, 5, 17),
                                               10)
        self.discount1 = VisibleProductDiscount(datetime.datetime(2018, 6, 1),
                                                datetime.datetime(2020, 5, 17),
                                                30)

        self.users_manager.store_manager.get_store(
            self.store_id1).discounts[self.discount.id] = self.discount
        self.users_manager.store_manager.get_store(
            self.store_id1).discounts[self.discount1.id] = self.discount1
        self.users_manager.store_manager.get_store(
            self.store_id2).discounts[self.discount.id] = self.discount
        self.users_manager.store_manager.get_store(
            self.store_id3).discounts[self.discount1.id] = self.discount1

        self.discount.products_in_discount[
            "Apple"] = self.users_manager.store_manager.get_store(
                self.store_id1).inventory.products["Apple"]
        self.discount.products_in_discount[
            "Tomato"] = self.users_manager.store_manager.get_store(
                self.store_id1).inventory.products["Tomato"]
        self.discount1.products_in_discount[
            "Apple"] = self.users_manager.store_manager.get_store(
                self.store_id1).inventory.products["Apple"]
        self.discount.products_in_discount[
            "Carrot"] = self.users_manager.store_manager.get_store(
                self.store_id1).inventory.products["Carrot"]
        self.discount.products_in_discount[
            "Keyboard"] = self.users_manager.store_manager.get_store(
                self.store_id1).inventory.products["Keyboard"]
        self.discount.products_in_discount[
            "Apple"] = self.users_manager.store_manager.get_store(
                self.store_id2).inventory.products["Apple"]
        self.discount.products_in_discount[
            "Tomato"] = self.users_manager.store_manager.get_store(
                self.store_id2).inventory.products["Tomato"]
        self.discount.products_in_discount[
            "Carrot"] = self.users_manager.store_manager.get_store(
                self.store_id2).inventory.products["Carrot"]
        self.discount.products_in_discount[
            "Keyboard"] = self.users_manager.store_manager.get_store(
                self.store_id2).inventory.products["Keyboard"]
        self.discount.products_in_discount[
            "Apple"] = self.users_manager.store_manager.get_store(
                self.store_id3).inventory.products["Apple"]
        self.discount.products_in_discount[
            "Tomato"] = self.users_manager.store_manager.get_store(
                self.store_id3).inventory.products["Tomato"]
        self.discount1.products_in_discount[
            "Apple"] = self.users_manager.store_manager.get_store(
                self.store_id3).inventory.products["Apple"]
        self.discount.products_in_discount[
            "Carrot"] = self.users_manager.store_manager.get_store(
                self.store_id3).inventory.products["Carrot"]
        self.discount.products_in_discount[
            "Keyboard"] = self.users_manager.store_manager.get_store(
                self.store_id3).inventory.products["Keyboard"]

        self.basket1 = Basket(
            self.users_manager.store_manager.get_store(
                self.store_id1).store_id)
        self.basket2 = Basket(
            self.users_manager.store_manager.get_store(
                self.store_id2).store_id)
        self.basket3 = Basket(
            self.users_manager.store_manager.get_store(
                self.store_id3).store_id)

        self.basket1.products["Apple"] = (
            self.users_manager.store_manager.get_store(
                self.store_id1).inventory.products["Apple"], 10)
        self.basket1.products["Keyboard"] = (
            self.users_manager.store_manager.get_store(
                self.store_id1).inventory.products["Keyboard"], 5)
        self.basket1.products["Carrot"] = (
            self.users_manager.store_manager.get_store(
                self.store_id1).inventory.products["Carrot"], 1)
        self.basket2.products["Apple"] = (
            self.users_manager.store_manager.get_store(
                self.store_id2).inventory.products["Apple"], 3)
        self.basket2.products["Keyboard"] = (
            self.users_manager.store_manager.get_store(
                self.store_id2).inventory.products["Keyboard"], 7)
        self.basket2.products["Carrot"] = (
            self.users_manager.store_manager.get_store(
                self.store_id2).inventory.products["Carrot"], 5)
        self.basket3.products["Apple"] = (
            self.users_manager.store_manager.get_store(
                self.store_id3).inventory.products["Apple"], 5)
        self.basket3.products["Keyboard"] = (
            self.users_manager.store_manager.get_store(
                self.store_id3).inventory.products["Keyboard"], 5)
        self.basket3.products["Carrot"] = (
            self.users_manager.store_manager.get_store(
                self.store_id3).inventory.products["Carrot"], 2)

        self.cart = self.users_manager.get_cart(self.guest_user)
        self.cart.baskets[self.store_id1] = self.basket1
        self.cart.baskets[self.store_id2] = self.basket2
        self.cart.baskets[self.store_id3] = self.basket3
示例#6
0
class TestUsersManagerIntegration(TestCase):
    def setUp(self) -> None:
        self.users_manager = UsersManager()
        date_str = '04-10-2020'
        dt = timedelta(days=10)
        date_object = datetime.datetime(2020, 4, 10)
        self.product_orange = Product("orange", 2, "food", None, 100)
        self.product_orange.visible_discount.append(
            VisibleProductDiscount(date_object, date_object + dt, 50))
        self.product_apple = Product("apple", 2, "food", None, 100)
        self.product_apple.visible_discount.append(
            VisibleProductDiscount(date_object, date_object + dt, 50))
        self.product_petunia = Product("petunia", 5, "food", None, 100)
        self.product_petunia.visible_discount.append(
            VisibleProductDiscount(date_object, date_object + dt, 50))
        self.product_begonia = Product("begonia", 15, "food", None, 100)
        self.product_begonia.visible_discount.append(
            VisibleProductDiscount(date_object, date_object + dt, 50))

        ###############################################
        self.store_manager = StoresManager()
        self.guest_user = self.users_manager.add_guest_user()
        self.idx = 0

        self.store_id1 = self.users_manager.store_manager.open_store(
            "test store1", "test owner1")
        self.store_id2 = self.users_manager.store_manager.open_store(
            "test store2", "test owner2")
        self.store_id3 = self.users_manager.store_manager.open_store(
            "test store3", "test owner3")
        self.store_id4 = self.users_manager.store_manager.open_store(
            "test store4", "test owner4")

        self.products = {
            "Apple":
            Product("Apple", 20, ["Food"], ["Fruits"], 10),
            "Banana":
            Product("Banana", 20, ["Food"], ["Fruits"], 10),
            "Orange":
            Product("Orange", 20, ["Food"], ["Fruits"], 10),
            "Tomato":
            Product("Tomato", 20, ["Food"], ["Vegetables"], 10),
            "Cucumber":
            Product("Cucumber", 20, ["Food"], ["Vegetables"], 10),
            "Carrot":
            Product("Carrot", 20, ["Food"], ["Vegetables"], 10),
            "Iphone":
            Product("Iphone", 20, ["Electronics"], ["Computers"], 10),
            "Hard Disk":
            Product("Hard Disk", 20, ["Electronics"], ["Computers"], 10),
            "Keyboard":
            Product("Keyboard", 20, ["Electronics"], ["Computers"], 10)
        }

        self.users_manager.store_manager.get_store(
            self.store_id1).inventory.products = self.products
        self.users_manager.store_manager.get_store(
            self.store_id2).inventory.products = self.products
        self.users_manager.store_manager.get_store(
            self.store_id3).inventory.products = self.products
        self.users_manager.store_manager.get_store(
            self.store_id4).inventory.products = self.products

        self.discount = VisibleProductDiscount(datetime.datetime(2018, 6, 1),
                                               datetime.datetime(2020, 5, 17),
                                               10)
        self.discount1 = VisibleProductDiscount(datetime.datetime(2018, 6, 1),
                                                datetime.datetime(2020, 5, 17),
                                                30)

        self.users_manager.store_manager.get_store(
            self.store_id1).discounts[self.discount.id] = self.discount
        self.users_manager.store_manager.get_store(
            self.store_id1).discounts[self.discount1.id] = self.discount1
        self.users_manager.store_manager.get_store(
            self.store_id2).discounts[self.discount.id] = self.discount
        self.users_manager.store_manager.get_store(
            self.store_id3).discounts[self.discount1.id] = self.discount1

        self.discount.products_in_discount[
            "Apple"] = self.users_manager.store_manager.get_store(
                self.store_id1).inventory.products["Apple"]
        self.discount.products_in_discount[
            "Tomato"] = self.users_manager.store_manager.get_store(
                self.store_id1).inventory.products["Tomato"]
        self.discount1.products_in_discount[
            "Apple"] = self.users_manager.store_manager.get_store(
                self.store_id1).inventory.products["Apple"]
        self.discount.products_in_discount[
            "Carrot"] = self.users_manager.store_manager.get_store(
                self.store_id1).inventory.products["Carrot"]
        self.discount.products_in_discount[
            "Keyboard"] = self.users_manager.store_manager.get_store(
                self.store_id1).inventory.products["Keyboard"]
        self.discount.products_in_discount[
            "Apple"] = self.users_manager.store_manager.get_store(
                self.store_id2).inventory.products["Apple"]
        self.discount.products_in_discount[
            "Tomato"] = self.users_manager.store_manager.get_store(
                self.store_id2).inventory.products["Tomato"]
        self.discount.products_in_discount[
            "Carrot"] = self.users_manager.store_manager.get_store(
                self.store_id2).inventory.products["Carrot"]
        self.discount.products_in_discount[
            "Keyboard"] = self.users_manager.store_manager.get_store(
                self.store_id2).inventory.products["Keyboard"]
        self.discount.products_in_discount[
            "Apple"] = self.users_manager.store_manager.get_store(
                self.store_id3).inventory.products["Apple"]
        self.discount.products_in_discount[
            "Tomato"] = self.users_manager.store_manager.get_store(
                self.store_id3).inventory.products["Tomato"]
        self.discount1.products_in_discount[
            "Apple"] = self.users_manager.store_manager.get_store(
                self.store_id3).inventory.products["Apple"]
        self.discount.products_in_discount[
            "Carrot"] = self.users_manager.store_manager.get_store(
                self.store_id3).inventory.products["Carrot"]
        self.discount.products_in_discount[
            "Keyboard"] = self.users_manager.store_manager.get_store(
                self.store_id3).inventory.products["Keyboard"]

        self.basket1 = Basket(
            self.users_manager.store_manager.get_store(
                self.store_id1).store_id)
        self.basket2 = Basket(
            self.users_manager.store_manager.get_store(
                self.store_id2).store_id)
        self.basket3 = Basket(
            self.users_manager.store_manager.get_store(
                self.store_id3).store_id)

        self.basket1.products["Apple"] = (
            self.users_manager.store_manager.get_store(
                self.store_id1).inventory.products["Apple"], 10)
        self.basket1.products["Keyboard"] = (
            self.users_manager.store_manager.get_store(
                self.store_id1).inventory.products["Keyboard"], 5)
        self.basket1.products["Carrot"] = (
            self.users_manager.store_manager.get_store(
                self.store_id1).inventory.products["Carrot"], 1)
        self.basket2.products["Apple"] = (
            self.users_manager.store_manager.get_store(
                self.store_id2).inventory.products["Apple"], 3)
        self.basket2.products["Keyboard"] = (
            self.users_manager.store_manager.get_store(
                self.store_id2).inventory.products["Keyboard"], 7)
        self.basket2.products["Carrot"] = (
            self.users_manager.store_manager.get_store(
                self.store_id2).inventory.products["Carrot"], 5)
        self.basket3.products["Apple"] = (
            self.users_manager.store_manager.get_store(
                self.store_id3).inventory.products["Apple"], 5)
        self.basket3.products["Keyboard"] = (
            self.users_manager.store_manager.get_store(
                self.store_id3).inventory.products["Keyboard"], 5)
        self.basket3.products["Carrot"] = (
            self.users_manager.store_manager.get_store(
                self.store_id3).inventory.products["Carrot"], 2)

        self.cart = self.users_manager.get_cart(self.guest_user)
        self.cart.baskets[self.store_id1] = self.basket1
        self.cart.baskets[self.store_id2] = self.basket2
        self.cart.baskets[self.store_id3] = self.basket3
        ###################################################

    # test register and assert that cart is transferred
    def test_register(self):
        guest_user_name = self.users_manager.add_guest_user()
        guest_cart = self.users_manager.get_cart(guest_user_name)
        self.assertTrue(self.users_manager.register(guest_user_name, "lielle"))
        self.assertEqual(guest_cart, self.users_manager.get_cart("lielle"))
        guest_user_name = self.users_manager.add_guest_user()
        self.assertFalse(self.users_manager.register(guest_user_name,
                                                     "lielle"))

    def test_login(self):
        guest_user_name = self.users_manager.add_guest_user()
        self.users_manager.register(guest_user_name, "registered1")
        registered1 = self.users_manager.find_reg_user("registered1")
        login_un = self.users_manager.login(guest_user_name,
                                            registered1.username)
        self.assertEqual(
            self.users_manager.find_reg_user(login_un).loggedin,
            registered1.loggedin)

    def test_view_cart(self):
        pass

    def test_logout(self):
        pass

    def test_add_product(self):
        pass

    def test_remove_product(self):
        pass

    def test_add_managed_store(self):
        pass

    def test_add_purchase(self):
        pass

    def test_remove_cart(self):
        pass

    def test_view_cart_after_discount(self):
        self.cart_after_discount = self.users_manager.view_cart_after_discount(
            self.guest_user)
        x = 5
示例#7
0
class UsersManagerInterface:
    security = Security()

    def __init__(self):
        self.user_manager = UsersManager()
        self.stores_manager = None
        username = self.user_manager.add_guest_user()
        print(username)
        self.user_manager.register(username, "admin")
        self.user_manager.admins.append("admin")

    def set_stores_manager(self, stores_manager: StoresManagerInterface):
        self.stores_manager = stores_manager

    def register(self, username, new_username, password):
        logger.log("user %s called register with new_username:%s", username,
                   new_username)
        ans, data = self.user_manager.register(username, new_username)
        if ans is True:
            self.security.add_user(new_username, password)
        print(data)
        return ans, data

# TODO: remove the return type hint. does not necessarily returns bool
# EVERYTIME SOMEONE OPENS THE SYSTEM A NEW USER IS CREATEDDDDDDDD

    def login(self, username: str, login_username: str, password):
        print("here!")
        logger.log("user %s called login with login_username:%s", username,
                   login_username)
        if self.security.verify_password(login_username, password):
            logged_in, data = self.user_manager.login(username, login_username)
            print(data)
            if logged_in is True:
                user = jsons.loads(data['data'])
                managed_stores = []
                print(user)
                for store in user['managed_stores']:
                    store_description = self.stores_manager.get_store_description(
                        store['store_id'])
                    managed_stores.append(store_description)
                user['managed_stores'] = managed_stores
                print("******************")
                print(user)
                return {'error': not logged_in, 'data': user}
            return {'error': True, 'error_msg': data['error_msg']}
        else:
            print("!!!!!!!!!!!")
            return {
                'error': True,
                'error_msg': 'incorrect password. Try again.'
            }

    def add_guest_user(self):
        return self.user_manager.add_guest_user()

# TODO: view_cart returns json object, not Cart.
# look up via usr id change user list to map of ids and user

    def view_cart(self, username):
        logger.log("user %s called view_cart", username)
        res, cart = self.user_manager.get_cart(username)
        if res is True:
            user_cart = jsonpickle.decode(cart)
            cart_view = jsons.loads(
                self.stores_manager.get_cart_description(user_cart))
            return ({'error': False, 'data': cart_view})
        return ({'error': True, 'error_msg': cart})

    def logout(self, username):
        return self.user_manager.logout(username)

    def view_purchases(self, username):
        logger.log("user %s called view_purchases", username)
        return self.user_manager.view_purchases(username)

# TODO: change product to product_name and get the actual product from the method i added in StoresManagerInterface

    def add_product(self, username, store_id, product_name, quantity):
        logger.log(
            "user %s called add product with store_id:%d, product_name:%s, quantity:%d",
            username, store_id, product_name, quantity)
        valid = self.stores_manager.is_valid_amount(store_id, product_name,
                                                    quantity)
        if valid['error'] is False:
            return {
                'error':
                not self.user_manager.add_product(username, store_id,
                                                  product_name, quantity),
                'error_msg':
                'error',
                'data':
                'added!'
            }
        return {'error': True, 'error_msg': valid['error_msg']}

    # TODO: remove_product receive actual product. change to product_name
    def remove_product(self, username, store_id, product, quantity):
        """
        :param username:
        :param store_id:
        :param product:
        :param quantity:
        :return: True if product was removed. False otherwise.
        """
        logger.log(
            "user %s called remove product with store_id:%d, product_name:%s, quantity:%d",
            username, store_id, product.name, quantity)
        return self.user_manager.remove_product(username, store_id, product,
                                                quantity)

    def get_product_from_store(self, store_id, product_name):
        return self.stores_manager.get_product_from_store(
            store_id, product_name)

    def get_cart(self, username):
        answer, data = self.user_manager.get_cart(username)
        if answer is False:
            return answer, data
        return answer, jsonpickle.decode(data)

    def view_purchases_admin(self, username, admin):
        logger.log("admin %s called view_purchases_admin for user %s", admin,
                   username)
        return self.user_manager.view_purchases_admin(username, admin)

    def is_admin(self, username):
        answer = self.user_manager.is_admin(username)
        return {'error': False, 'data': answer}

    def add_managed_store(self, username, store_id):
        """
        :param username:
        :param store_id:
        :return:
        """
        return self.user_manager.add_managed_store(username, store_id)

    def remove_managed_store(self, username, store_id):
        return self.user_manager.remove_managed_store(username, store_id)

    def get_managed_stores_description(self, username):
        ans = jsons.loads(self.user_manager.get_managed_stores(username))
        if ans['error'] is False:
            stores_des = []
            for store in ans['data']:
                res_store = self.stores_manager.get_store_description(store)
                print(res_store)
                stores_des.append(res_store)
            return ({'error': False, 'data': stores_des})
        else:
            return ({'error': True, 'error_msg': ans['error_msg']})

    def get_managed_stores(self, username):
        ans = jsons.loads(self.user_manager.get_managed_stores(username))
        if ans['error'] is True:
            return []
        return ans['data']

    def get_stores_managed_by_user(self, username):
        return self.user_manager.get_managed_stores(username)

    def check_if_registered(self, username):
        return self.user_manager.check_if_registered(username)

    def check_if_loggedin(self, username):
        return self.user_manager.check_if_loggedin(username)

    def add_purchase(self, username, purchases):
        return self.user_manager.add_purchase(username,
                                              jsonpickle.encode(purchases))

    def remove_cart(self, username):
        return self.user_manager.remove_cart(username)

    def is_store_manager(self, username):
        return self.user_manager.is_store_manager(username)

    def get_users_manager(self) -> UsersManager:
        return self.user_manager
class TestUsersManagerIntegration(TestCase):
    def setUp(self) -> None:
        self.users_manager = UsersManager()
        date_str = '04-10-2020'
        dt = timedelta(days=10)
        date_object = datetime.strptime(date_str, '%m-%d-%Y')
        self.product_orange = Product("orange", 2, "food", None, 100)
        self.product_orange.discount.append(
            VisibleProductDiscount(date_object, date_object + dt, 50))
        self.product_apple = Product("apple", 2, "food", None, 100)
        self.product_apple.discount.append(
            VisibleProductDiscount(date_object, date_object + dt, 50))
        self.product_petunia = Product("petunia", 5, "food", None, 100)
        self.product_petunia.discount.append(
            VisibleProductDiscount(date_object, date_object + dt, 50))
        self.product_begonia = Product("begonia", 15, "food", None, 100)
        self.product_begonia.discount.append(
            VisibleProductDiscount(date_object, date_object + dt, 50))

    # test register and assert that cart is transferred
    def test_register(self):
        guest_user_name = self.users_manager.add_guest_user()
        guest_cart = self.users_manager.get_cart(guest_user_name)
        self.assertTrue(self.users_manager.register(guest_user_name, "lielle"))
        self.assertEqual(guest_cart, self.users_manager.get_cart("lielle"))
        guest_user_name = self.users_manager.add_guest_user()
        self.assertFalse(self.users_manager.register(guest_user_name,
                                                     "lielle"))

    def test_login(self):
        guest_user_name = self.users_manager.add_guest_user()
        self.users_manager.register(guest_user_name, "registered1")
        registered1 = self.users_manager.find_reg_user("registered1")
        login_un = self.users_manager.login(guest_user_name,
                                            registered1.username)
        self.assertEqual(
            self.users_manager.find_reg_user(login_un).loggedin,
            registered1.loggedin)

    def test_view_cart(self):
        pass

    def test_logout(self):
        pass

    def test_add_product(self):
        pass

    def test_remove_product(self):
        pass

    def test_add_managed_store(self):
        pass

    def test_add_purchase(self):
        pass

    def test_remove_cart(self):
        pass