def test_make_reflexive_ownership(self):  # 4.3-2
     new_user = next(self.generate_user_with_default_password)
     self.assertFalse(service.get_user_store_list(new_user.pk))
     self.assertFalse(
         service.add_manager(new_user.username, [], True, self.store.pk,
                             self.user.username, False)[0])
     self.assertTrue(service.get_user_store_list(new_user.pk))
     self.assertTrue(
         service.add_manager(self.user.username, [], True, self.store.pk,
                             new_user.username, False)[0])
 def test_delete_none_existing_item_by_manager(self):  # 5.1-2
     new_user = next(self.generate_user_with_default_password)
     self.assertFalse(
         service.add_manager(new_user.username,
                             [self.Perms.REMOVE_ITEM.value], False,
                             self.store.pk, self.default_user, False)[0])
     self.assertFalse(service.delete_item(666, new_user.pk)[0])
 def test_add_manager_that_already_manages_the_store(self):  # 4.5-3
     store_pk = self.generate_store(self.user)
     new_user = next(self.generate_user_with_default_password)
     self.assertFalse(
         service.add_manager(
             new_user.username,
             [self.Perms.ADD_ITEM.value, self.Perms.EDIT_ITEM.value], False,
             store_pk, self.default_user, False)[0])
     self.assertTrue(
         new_user.has_perm(self.Perms.EDIT_ITEM.value,
                           Store.objects.get(pk=store_pk)))
     self.assertTrue(
         service.add_manager(
             new_user.username,
             [self.Perms.ADD_ITEM.value, self.Perms.EDIT_ITEM.value], False,
             store_pk, self.default_user, False)[0])
 def test_delete_owner_by_another_owner(self):  # 4.4-1
     new_user = next(self.generate_user_with_default_password)
     self.assertFalse(
         service.add_manager(new_user.username, [], True, self.store.pk,
                             self.user.username, False)[0])
     self.assertTrue(
         service.remove_manager_from_store(self.store.pk, new_user.pk))
 def test_add_owner_to_store(self):  # 4.3-1
     new_user = next(self.generate_user_with_default_password)
     self.assertFalse(service.get_user_store_list(new_user.pk))
     self.assertFalse(
         service.add_manager(new_user.username, [], True, self.store.pk,
                             self.default_user, False)[0])
     self.assertTrue(service.get_user_store_list(new_user.pk))
 def test_add_manager_by_none_owner(self):  # 4.5-2
     store_pk = self.generate_store(self.user)
     new_user = next(self.generate_user_with_default_password)
     new_user2 = next(self.generate_user_with_default_password)
     self.assertTrue(
         service.add_manager(
             new_user.username,
             [self.Perms.ADD_ITEM.value, self.Perms.EDIT_ITEM.value], False,
             store_pk, new_user2.username, False)[0])
     self.assertFalse(
         new_user.has_perm(self.Perms.EDIT_ITEM.value,
                           Store.objects.get(pk=store_pk)))
 def test_delete_existing_item_by_manager(self):  # 5.1-1
     new_user = next(self.generate_user_with_default_password)
     self.assertFalse(
         service.add_manager(new_user.username,
                             [self.Perms.REMOVE_ITEM.value], False,
                             self.store.pk, self.default_user, False)[0])
     item_name = "bbb2"
     item_dict = {
         "price": 12.34,
         "name": item_name,
         "description": "This is a %s" % item_name,
         "category": "HOME",
         "quantity": 12
     }
     service.add_item_to_store(json.dumps(item_dict), self.store.pk,
                               self.user.pk)
     self.assertEqual(item_dict["name"],
                      service.get_store_items(self.store.pk)[0]["name"])
     self.assertTrue(
         service.delete_item(
             service.get_store_items(self.store.pk)[0]["id"], new_user.pk))
     self.assertFalse(service.get_store_items(self.store.pk))
 def test_add_guest_to_store_by_store_owner(self):  # 4.3-3
     self.assertTrue(
         service.add_manager("Moshe", [], True, self.store.pk,
                             self.default_user, False)[0])