Exemple #1
0
    def setUp(self):
        super(BaseRequestTests, self).setUp()

        create_test_map()

        self.account_1 = self.accounts_factory.create_account()
        self.account_2 = self.accounts_factory.create_account()
        self.account_3 = self.accounts_factory.create_account()

        group_edit_item = sync_group('edit item', ['collections.edit_item'])
        group_moderate_item = sync_group('moderate item', ['collections.moderate_item'])

        group_edit = sync_group('edit kit', ['collections.edit_kit'])
        group_moderate = sync_group('moderate kit', ['collections.moderate_kit'])

        group_edit_item.user_set.add(self.account_2._model)
        group_moderate_item.user_set.add(self.account_3._model)

        group_edit.user_set.add(self.account_2._model)
        group_moderate.user_set.add(self.account_3._model)

        self.collection_1 = CollectionPrototype.create(caption='collection_1', description='description_1')
        self.collection_2 = CollectionPrototype.create(caption='collection_2', description='description_2')

        self.kit_1 = KitPrototype.create(collection=self.collection_1, caption='kit_1', description='description_1', approved=True)
        self.kit_2 = KitPrototype.create(collection=self.collection_1, caption='kit_2', description='description_2')

        self.item_1_1 = ItemPrototype.create(kit=self.kit_1, caption='item_1_1', text='text_1_1')
        self.item_1_2 = ItemPrototype.create(kit=self.kit_1, caption='item_1_2', text='text_1_2', approved=True)
Exemple #2
0
    def setUp(self):
        super(ItemsContainerTests, self).setUp()

        self.container = ItemsContainer()

        self.collection_1 = CollectionPrototype.create(
            caption=u'collection_1', description=u'description_1')
        self.collection_2 = CollectionPrototype.create(
            caption=u'collection_2',
            description=u'description_2',
            approved=True)

        self.kit_1 = KitPrototype.create(collection=self.collection_1,
                                         caption=u'kit_1',
                                         description=u'description_1')
        self.kit_2 = KitPrototype.create(collection=self.collection_2,
                                         caption=u'kit_2',
                                         description=u'description_2')

        self.item_1_1 = ItemPrototype.create(kit=self.kit_1,
                                             caption=u'item_1_1',
                                             text=u'text_1_1')
        self.item_1_2 = ItemPrototype.create(kit=self.kit_1,
                                             caption=u'item_1_2',
                                             text=u'text_1_2',
                                             approved=True)
        self.item_2_1 = ItemPrototype.create(kit=self.kit_2,
                                             caption=u'item_2_1',
                                             text=u'text_2_1',
                                             approved=True)
Exemple #3
0
    def setUp(self):
        super(_BaseRequestTests, self).setUp()

        create_test_map()

        result, account_id, bundle_id = register_user('test_user_1', '*****@*****.**', '111111')
        self.account_1 = AccountPrototype.get_by_id(account_id)

        result, account_id, bundle_id = register_user('test_user_2', '*****@*****.**', '111111')
        self.account_2 = AccountPrototype.get_by_id(account_id)

        group_edit = sync_group('edit achievement', ['achievements.edit_achievement'])

        group_edit.user_set.add(self.account_2._model)

        self.achievement_1 = AchievementPrototype.create(group=ACHIEVEMENT_GROUP.MONEY, type=ACHIEVEMENT_TYPE.MONEY, barrier=0, points=10,
                                                         caption=u'achievement_1', description=u'description_1', approved=True)
        self.achievement_2 = AchievementPrototype.create(group=ACHIEVEMENT_GROUP.MONEY, type=ACHIEVEMENT_TYPE.MONEY, barrier=2, points=10,
                                                         caption=u'achievement_2', description=u'description_2', approved=False)
        self.achievement_3 = AchievementPrototype.create(group=ACHIEVEMENT_GROUP.TIME, type=ACHIEVEMENT_TYPE.TIME, barrier=3, points=10,
                                                         caption=u'achievement_3', description=u'description_3', approved=True)

        self.collection_1 = CollectionPrototype.create(caption=u'collection_1', description=u'description_1', approved=True)
        self.kit_1 = KitPrototype.create(collection=self.collection_1, caption=u'kit_1', description=u'description_1', approved=True)
        self.item_1_1 = ItemPrototype.create(kit=self.kit_1, caption=u'item_1_1', text=u'text_1_1', approved=True)
        self.item_1_2 = ItemPrototype.create(kit=self.kit_1, caption=u'item_1_2', text=u'text_1_2', approved=True)

        self.account_achievements_1 = AccountAchievementsPrototype.get_by_account_id(self.account_1.id)
        self.account_achievements_1.achievements.add_achievement(self.achievement_1)
        self.account_achievements_1.save()
Exemple #4
0
    def setUp(self):
        super(ItemsManagerTests, self).setUp()

        create_test_map()

        self.account_1 = self.accounts_factory.create_account()

        self.account_1_items = AccountItemsPrototype.get_by_account_id(self.account_1.id)

        self.collection_1 = CollectionPrototype.create(caption='collection_1', description='description_1')
        self.collection_2 = CollectionPrototype.create(caption='collection_2', description='description_2', approved=True)

        self.kit_1 = KitPrototype.create(collection=self.collection_1, caption='kit_1', description='description_1')
        self.kit_2 = KitPrototype.create(collection=self.collection_2, caption='kit_2', description='description_2', approved=True)
        self.kit_3 = KitPrototype.create(collection=self.collection_2, caption='kit_3', description='description_3', approved=True)

        self.item_1_1 = ItemPrototype.create(kit=self.kit_1, caption='item_1_1', text='text_1_1', approved=False)
        self.item_1_2 = ItemPrototype.create(kit=self.kit_1, caption='item_1_2', text='text_1_2', approved=True)
        self.item_2_1 = ItemPrototype.create(kit=self.kit_2, caption='item_2_1', text='text_2_1', approved=True)
        self.item_2_2 = ItemPrototype.create(kit=self.kit_2, caption='item_2_2', text='text_2_2', approved=False)
        self.item_3_1 = ItemPrototype.create(kit=self.kit_3, caption='item_3_1', text='text_3_1', approved=True)

        self.account_1_items.add_item(self.item_1_2)
        self.account_1_items.save()

        self.worker = environment.workers.items_manager
        self.worker.initialize()
    def setUp(self):
        super(ItemsManagerTests, self).setUp()

        create_test_map()

        result, account_id, bundle_id = register_user('test_user_1', '*****@*****.**', '111111')
        self.account_1 = AccountPrototype.get_by_id(account_id)

        self.account_1_items = AccountItemsPrototype.get_by_account_id(self.account_1.id)

        self.collection_1 = CollectionPrototype.create(caption=u'collection_1', description=u'description_1')
        self.collection_2 = CollectionPrototype.create(caption=u'collection_2', description=u'description_2', approved=True)

        self.kit_1 = KitPrototype.create(collection=self.collection_1, caption=u'kit_1', description=u'description_1')
        self.kit_2 = KitPrototype.create(collection=self.collection_2, caption=u'kit_2', description=u'description_2', approved=True)
        self.kit_3 = KitPrototype.create(collection=self.collection_2, caption=u'kit_3', description=u'description_3', approved=True)

        self.item_1_1 = ItemPrototype.create(kit=self.kit_1, caption=u'item_1_1', text=u'text_1_1', approved=False)
        self.item_1_2 = ItemPrototype.create(kit=self.kit_1, caption=u'item_1_2', text=u'text_1_2', approved=True)
        self.item_2_1 = ItemPrototype.create(kit=self.kit_2, caption=u'item_2_1', text=u'text_2_1', approved=True)
        self.item_2_2 = ItemPrototype.create(kit=self.kit_2, caption=u'item_2_2', text=u'text_2_2', approved=False)
        self.item_3_1 = ItemPrototype.create(kit=self.kit_3, caption=u'item_3_1', text=u'text_3_1', approved=True)

        self.account_1_items.add_item(self.item_1_2)
        self.account_1_items.save()

        self.worker = environment.workers.items_manager
        self.worker.initialize()
    def setUp(self):
        super(BaseRequestTests, self).setUp()

        create_test_map()

        self.account_1 = self.accounts_factory.create_account()
        self.account_2 = self.accounts_factory.create_account()
        self.account_3 = self.accounts_factory.create_account()

        group_edit = sync_group('edit item', ['collections.edit_item'])
        group_moderate = sync_group('moderate item',
                                    ['collections.moderate_item'])

        group_edit.user_set.add(self.account_2._model)
        group_moderate.user_set.add(self.account_3._model)

        self.collection_1 = CollectionPrototype.create(
            caption='collection_1', description='description_1')
        self.collection_2 = CollectionPrototype.create(
            caption='collection_2', description='description_2')

        self.kit_1 = KitPrototype.create(collection=self.collection_1,
                                         caption='kit_1',
                                         description='description_1')
        self.kit_2 = KitPrototype.create(collection=self.collection_1,
                                         caption='kit_2',
                                         description='description_2')

        self.item_1_1 = ItemPrototype.create(kit=self.kit_1,
                                             caption='item_1_1',
                                             text='text_1_1')
        self.item_1_2 = ItemPrototype.create(kit=self.kit_1,
                                             caption='item_1_2',
                                             text='text_1_2')
    def setUp(self):
        super(BaseRequestTests, self).setUp()

        create_test_map()

        result, account_id, bundle_id = register_user('test_user_1', '*****@*****.**', '111111')
        self.account_1 = AccountPrototype.get_by_id(account_id)

        result, account_id, bundle_id = register_user('test_user_2', '*****@*****.**', '111111')
        self.account_2 = AccountPrototype.get_by_id(account_id)

        result, account_id, bundle_id = register_user('test_user_3', '*****@*****.**', '111111')
        self.account_3 = AccountPrototype.get_by_id(account_id)

        group_edit_item = sync_group('edit item', ['collections.edit_item'])
        group_moderate_item = sync_group('moderate item', ['collections.moderate_item'])

        group_edit = sync_group('edit kit', ['collections.edit_kit'])
        group_moderate = sync_group('moderate kit', ['collections.moderate_kit'])

        group_edit_item.user_set.add(self.account_2._model)
        group_moderate_item.user_set.add(self.account_3._model)

        group_edit.user_set.add(self.account_2._model)
        group_moderate.user_set.add(self.account_3._model)

        self.collection_1 = CollectionPrototype.create(caption=u'collection_1', description=u'description_1')
        self.collection_2 = CollectionPrototype.create(caption=u'collection_2', description=u'description_2')

        self.kit_1 = KitPrototype.create(collection=self.collection_1, caption=u'kit_1', description=u'description_1', approved=True)
        self.kit_2 = KitPrototype.create(collection=self.collection_1, caption=u'kit_2', description=u'description_2')

        self.item_1_1 = ItemPrototype.create(kit=self.kit_1, caption=u'item_1_1', text=u'text_1_1')
        self.item_1_2 = ItemPrototype.create(kit=self.kit_1, caption=u'item_1_2', text=u'text_1_2', approved=True)
Exemple #8
0
    def setUp(self):
        super(AccountAchievementsPrototypeTests, self).setUp()

        create_test_map()

        result, account_id, bundle_id = register_user('test_user_1',
                                                      '*****@*****.**',
                                                      '111111')
        self.account_1 = AccountPrototype.get_by_id(account_id)

        self.collection_1 = CollectionPrototype.create(
            caption=u'collection_1',
            description=u'description_1',
            approved=True)
        self.kit_1 = KitPrototype.create(collection=self.collection_1,
                                         caption=u'kit_1',
                                         description=u'description_1',
                                         approved=True)
        self.item_1_1 = ItemPrototype.create(kit=self.kit_1,
                                             caption=u'item_1_1',
                                             text=u'text_1_1',
                                             approved=False)
        self.item_1_2 = ItemPrototype.create(kit=self.kit_1,
                                             caption=u'item_1_2',
                                             text=u'text_1_2',
                                             approved=True)
        self.item_1_3 = ItemPrototype.create(kit=self.kit_1,
                                             caption=u'item_1_3',
                                             text=u'text_1_3',
                                             approved=True)

        self.achievement_1 = AchievementPrototype.create(
            group=ACHIEVEMENT_GROUP.MONEY,
            type=ACHIEVEMENT_TYPE.MONEY,
            barrier=1,
            points=10,
            caption=u'achievement_1',
            description=u'description_1',
            approved=True,
            item_1=self.item_1_1,
            item_2=self.item_1_2)
        self.achievement_2 = AchievementPrototype.create(
            group=ACHIEVEMENT_GROUP.MONEY,
            type=ACHIEVEMENT_TYPE.MONEY,
            barrier=2,
            points=10,
            caption=u'achievement_2',
            description=u'description_2',
            approved=False)
        self.achievement_3 = AchievementPrototype.create(
            group=ACHIEVEMENT_GROUP.TIME,
            type=ACHIEVEMENT_TYPE.TIME,
            barrier=3,
            points=10,
            caption=u'achievement_3',
            description=u'description_3',
            approved=True)

        self.account_achievements_1 = AccountAchievementsPrototype.get_by_account_id(
            self.account_1.id)
Exemple #9
0
    def setUp(self):
        super(ItemsManagerTests, self).setUp()

        create_test_map()

        result, account_id, bundle_id = register_user('test_user_1',
                                                      '*****@*****.**',
                                                      '111111')
        self.account_1 = AccountPrototype.get_by_id(account_id)

        self.account_1_items = AccountItemsPrototype.get_by_account_id(
            self.account_1.id)

        self.collection_1 = CollectionPrototype.create(
            caption=u'collection_1', description=u'description_1')
        self.collection_2 = CollectionPrototype.create(
            caption=u'collection_2',
            description=u'description_2',
            approved=True)

        self.kit_1 = KitPrototype.create(collection=self.collection_1,
                                         caption=u'kit_1',
                                         description=u'description_1')
        self.kit_2 = KitPrototype.create(collection=self.collection_2,
                                         caption=u'kit_2',
                                         description=u'description_2',
                                         approved=True)
        self.kit_3 = KitPrototype.create(collection=self.collection_2,
                                         caption=u'kit_3',
                                         description=u'description_3',
                                         approved=True)

        self.item_1_1 = ItemPrototype.create(kit=self.kit_1,
                                             caption=u'item_1_1',
                                             text=u'text_1_1',
                                             approved=False)
        self.item_1_2 = ItemPrototype.create(kit=self.kit_1,
                                             caption=u'item_1_2',
                                             text=u'text_1_2',
                                             approved=True)
        self.item_2_1 = ItemPrototype.create(kit=self.kit_2,
                                             caption=u'item_2_1',
                                             text=u'text_2_1',
                                             approved=True)
        self.item_2_2 = ItemPrototype.create(kit=self.kit_2,
                                             caption=u'item_2_2',
                                             text=u'text_2_2',
                                             approved=False)
        self.item_3_1 = ItemPrototype.create(kit=self.kit_3,
                                             caption=u'item_3_1',
                                             text=u'text_3_1',
                                             approved=True)

        self.account_1_items.add_item(self.item_1_2)
        self.account_1_items.save()

        self.worker = environment.workers.items_manager
        self.worker.initialize()
Exemple #10
0
    def setUp(self):
        super(_BaseRequestTests, self).setUp()

        create_test_map()

        self.account_1 = self.accounts_factory.create_account()
        self.account_2 = self.accounts_factory.create_account()

        group_edit = sync_group('edit achievement',
                                ['achievements.edit_achievement'])

        group_edit.user_set.add(self.account_2._model)

        self.achievement_1 = AchievementPrototype.create(
            group=ACHIEVEMENT_GROUP.MONEY,
            type=ACHIEVEMENT_TYPE.MONEY,
            barrier=0,
            points=10,
            caption='achievement_1',
            description='description_1',
            approved=True)
        self.achievement_2 = AchievementPrototype.create(
            group=ACHIEVEMENT_GROUP.MONEY,
            type=ACHIEVEMENT_TYPE.MONEY,
            barrier=2,
            points=10,
            caption='achievement_2',
            description='description_2',
            approved=False)
        self.achievement_3 = AchievementPrototype.create(
            group=ACHIEVEMENT_GROUP.TIME,
            type=ACHIEVEMENT_TYPE.TIME,
            barrier=3,
            points=10,
            caption='achievement_3',
            description='description_3',
            approved=True)

        self.collection_1 = CollectionPrototype.create(
            caption='collection_1', description='description_1', approved=True)
        self.kit_1 = KitPrototype.create(collection=self.collection_1,
                                         caption='kit_1',
                                         description='description_1',
                                         approved=True)
        self.item_1_1 = ItemPrototype.create(kit=self.kit_1,
                                             caption='item_1_1',
                                             text='text_1_1',
                                             approved=True)
        self.item_1_2 = ItemPrototype.create(kit=self.kit_1,
                                             caption='item_1_2',
                                             text='text_1_2',
                                             approved=True)

        self.account_achievements_1 = AccountAchievementsPrototype.get_by_account_id(
            self.account_1.id)
        self.account_achievements_1.achievements.add_achievement(
            self.achievement_1)
        self.account_achievements_1.save()
Exemple #11
0
    def setUp(self):
        super(AccountAchievementsPrototypeTests, self).setUp()

        create_test_map()

        self.account_1 = self.accounts_factory.create_account()

        self.collection_1 = CollectionPrototype.create(
            caption='collection_1', description='description_1', approved=True)
        self.kit_1 = KitPrototype.create(collection=self.collection_1,
                                         caption='kit_1',
                                         description='description_1',
                                         approved=True)
        self.item_1_1 = ItemPrototype.create(kit=self.kit_1,
                                             caption='item_1_1',
                                             text='text_1_1',
                                             approved=False)
        self.item_1_2 = ItemPrototype.create(kit=self.kit_1,
                                             caption='item_1_2',
                                             text='text_1_2',
                                             approved=True)
        self.item_1_3 = ItemPrototype.create(kit=self.kit_1,
                                             caption='item_1_3',
                                             text='text_1_3',
                                             approved=True)

        self.achievement_1 = AchievementPrototype.create(
            group=ACHIEVEMENT_GROUP.MONEY,
            type=ACHIEVEMENT_TYPE.MONEY,
            barrier=1,
            points=10,
            caption='achievement_1',
            description='description_1',
            approved=True,
            item_1=self.item_1_1,
            item_2=self.item_1_2)
        self.achievement_2 = AchievementPrototype.create(
            group=ACHIEVEMENT_GROUP.MONEY,
            type=ACHIEVEMENT_TYPE.MONEY,
            barrier=2,
            points=10,
            caption='achievement_2',
            description='description_2',
            approved=False)
        self.achievement_3 = AchievementPrototype.create(
            group=ACHIEVEMENT_GROUP.TIME,
            type=ACHIEVEMENT_TYPE.TIME,
            barrier=3,
            points=10,
            caption='achievement_3',
            description='description_3',
            approved=True)

        self.account_achievements_1 = AccountAchievementsPrototype.get_by_account_id(
            self.account_1.id)
Exemple #12
0
    def setUp(self):
        super(BaseRequestTests, self).setUp()

        create_test_map()

        result, account_id, bundle_id = register_user('test_user_1',
                                                      '*****@*****.**',
                                                      '111111')
        self.account_1 = AccountPrototype.get_by_id(account_id)

        result, account_id, bundle_id = register_user('test_user_2',
                                                      '*****@*****.**',
                                                      '111111')
        self.account_2 = AccountPrototype.get_by_id(account_id)

        result, account_id, bundle_id = register_user('test_user_3',
                                                      '*****@*****.**',
                                                      '111111')
        self.account_3 = AccountPrototype.get_by_id(account_id)

        group_edit_item = sync_group('edit item', ['collections.edit_item'])
        group_moderate_item = sync_group('moderate item',
                                         ['collections.moderate_item'])

        group_edit = sync_group('edit kit', ['collections.edit_kit'])
        group_moderate = sync_group('moderate kit',
                                    ['collections.moderate_kit'])

        group_edit_item.user_set.add(self.account_2._model)
        group_moderate_item.user_set.add(self.account_3._model)

        group_edit.user_set.add(self.account_2._model)
        group_moderate.user_set.add(self.account_3._model)

        self.collection_1 = CollectionPrototype.create(
            caption=u'collection_1', description=u'description_1')
        self.collection_2 = CollectionPrototype.create(
            caption=u'collection_2', description=u'description_2')

        self.kit_1 = KitPrototype.create(collection=self.collection_1,
                                         caption=u'kit_1',
                                         description=u'description_1',
                                         approved=True)
        self.kit_2 = KitPrototype.create(collection=self.collection_1,
                                         caption=u'kit_2',
                                         description=u'description_2')

        self.item_1_1 = ItemPrototype.create(kit=self.kit_1,
                                             caption=u'item_1_1',
                                             text=u'text_1_1')
        self.item_1_2 = ItemPrototype.create(kit=self.kit_1,
                                             caption=u'item_1_2',
                                             text=u'text_1_2',
                                             approved=True)
Exemple #13
0
    def setUp(self):
        super(LogicTests, self).setUp()

        create_test_map()

        result, account_id, bundle_id = register_user('test_user_1',
                                                      '*****@*****.**',
                                                      '111111')
        self.account_1 = AccountPrototype.get_by_id(account_id)

        self.account_1_items = AccountItemsPrototype.get_by_account_id(
            self.account_1.id)

        self.collection_1 = CollectionPrototype.create(
            caption=u'collection_1', description=u'description_1')
        self.collection_2 = CollectionPrototype.create(
            caption=u'collection_2',
            description=u'description_2',
            approved=True)

        self.kit_1 = KitPrototype.create(collection=self.collection_1,
                                         caption=u'kit_1',
                                         description=u'description_1')
        self.kit_2 = KitPrototype.create(collection=self.collection_2,
                                         caption=u'kit_2',
                                         description=u'description_2',
                                         approved=True)
        self.kit_3 = KitPrototype.create(collection=self.collection_2,
                                         caption=u'kit_3',
                                         description=u'description_3',
                                         approved=True)

        self.item_1_1 = ItemPrototype.create(kit=self.kit_1,
                                             caption=u'item_1_1',
                                             text=u'text_1_1',
                                             approved=False)
        self.item_1_2 = ItemPrototype.create(kit=self.kit_1,
                                             caption=u'item_1_2',
                                             text=u'text_1_2',
                                             approved=True)
        self.item_2_1 = ItemPrototype.create(kit=self.kit_2,
                                             caption=u'item_2_1',
                                             text=u'text_2_1',
                                             approved=True)
        self.item_2_2 = ItemPrototype.create(kit=self.kit_2,
                                             caption=u'item_2_2',
                                             text=u'text_2_2',
                                             approved=False)
        self.item_3_1 = ItemPrototype.create(kit=self.kit_3,
                                             caption=u'item_3_1',
                                             text=u'text_3_1',
                                             approved=True)
Exemple #14
0
    def setUp(self):
        super(ItemsContainerTests, self).setUp()

        self.container = ItemsContainer()

        self.collection_1 = CollectionPrototype.create(caption='collection_1', description='description_1')
        self.collection_2 = CollectionPrototype.create(caption='collection_2', description='description_2', approved=True)

        self.kit_1 = KitPrototype.create(collection=self.collection_1, caption='kit_1', description='description_1')
        self.kit_2 = KitPrototype.create(collection=self.collection_2, caption='kit_2', description='description_2')

        self.item_1_1 = ItemPrototype.create(kit=self.kit_1, caption='item_1_1', text='text_1_1')
        self.item_1_2 = ItemPrototype.create(kit=self.kit_1, caption='item_1_2', text='text_1_2', approved=True)
        self.item_2_1 = ItemPrototype.create(kit=self.kit_2, caption='item_2_1', text='text_2_1', approved=True)
Exemple #15
0
    def setUp(self):
        super(AccountAchievementsPrototypeTests, self).setUp()

        create_test_map()

        result, account_id, bundle_id = register_user("test_user_1", "*****@*****.**", "111111")
        self.account_1 = AccountPrototype.get_by_id(account_id)

        self.collection_1 = CollectionPrototype.create(
            caption=u"collection_1", description=u"description_1", approved=True
        )
        self.kit_1 = KitPrototype.create(
            collection=self.collection_1, caption=u"kit_1", description=u"description_1", approved=True
        )
        self.item_1_1 = ItemPrototype.create(kit=self.kit_1, caption=u"item_1_1", text=u"text_1_1", approved=False)
        self.item_1_2 = ItemPrototype.create(kit=self.kit_1, caption=u"item_1_2", text=u"text_1_2", approved=True)
        self.item_1_3 = ItemPrototype.create(kit=self.kit_1, caption=u"item_1_3", text=u"text_1_3", approved=True)

        self.achievement_1 = AchievementPrototype.create(
            group=ACHIEVEMENT_GROUP.MONEY,
            type=ACHIEVEMENT_TYPE.MONEY,
            barrier=1,
            points=10,
            caption=u"achievement_1",
            description=u"description_1",
            approved=True,
            item_1=self.item_1_1,
            item_2=self.item_1_2,
        )
        self.achievement_2 = AchievementPrototype.create(
            group=ACHIEVEMENT_GROUP.MONEY,
            type=ACHIEVEMENT_TYPE.MONEY,
            barrier=2,
            points=10,
            caption=u"achievement_2",
            description=u"description_2",
            approved=False,
        )
        self.achievement_3 = AchievementPrototype.create(
            group=ACHIEVEMENT_GROUP.TIME,
            type=ACHIEVEMENT_TYPE.TIME,
            barrier=3,
            points=10,
            caption=u"achievement_3",
            description=u"description_3",
            approved=True,
        )

        self.account_achievements_1 = AccountAchievementsPrototype.get_by_account_id(self.account_1.id)
Exemple #16
0
    def setUp(self):
        super(LogicTests, self).setUp()

        create_test_map()

        self.account_1 = self.accounts_factory.create_account()

        self.account_1_items = AccountItemsPrototype.get_by_account_id(
            self.account_1.id)

        self.collection_1 = CollectionPrototype.create(
            caption='collection_1', description='description_1')
        self.collection_2 = CollectionPrototype.create(
            caption='collection_2', description='description_2', approved=True)

        self.kit_1 = KitPrototype.create(collection=self.collection_1,
                                         caption='kit_1',
                                         description='description_1')
        self.kit_2 = KitPrototype.create(collection=self.collection_2,
                                         caption='kit_2',
                                         description='description_2',
                                         approved=True)
        self.kit_3 = KitPrototype.create(collection=self.collection_2,
                                         caption='kit_3',
                                         description='description_3',
                                         approved=True)

        self.item_1_1 = ItemPrototype.create(kit=self.kit_1,
                                             caption='item_1_1',
                                             text='text_1_1',
                                             approved=False)
        self.item_1_2 = ItemPrototype.create(kit=self.kit_1,
                                             caption='item_1_2',
                                             text='text_1_2',
                                             approved=True)
        self.item_2_1 = ItemPrototype.create(kit=self.kit_2,
                                             caption='item_2_1',
                                             text='text_2_1',
                                             approved=True)
        self.item_2_2 = ItemPrototype.create(kit=self.kit_2,
                                             caption='item_2_2',
                                             text='text_2_2',
                                             approved=False)
        self.item_3_1 = ItemPrototype.create(kit=self.kit_3,
                                             caption='item_3_1',
                                             text='text_3_1',
                                             approved=True)
Exemple #17
0
    def test_unapproved_item__anonymous(self):
        item = ItemPrototype.create(kit=self.kit_2, caption='item_2_2', text='item_text_2_2', approved=False)

        self.account_1_items.add_item(item)
        self.account_1_items.save()

        self.check_html_ok(self.request_html(self.test_url), texts=[(item.caption, 0),
                                                                    (item.text, 0)])
Exemple #18
0
    def test_create(self):
        self.assertTrue(self.item_1_1.id in items_storage)
        self.assertTrue(self.item_1_2.id in items_storage)

        with self.check_changed(lambda: items_storage.version):
            item = ItemPrototype.create(kit=self.kit_2, caption=u'item_3', text=u'description_3')

        self.assertTrue(item.id in items_storage)
Exemple #19
0
    def test_unapproved_item__moderator(self):
        item = ItemPrototype.create(kit=self.kit_2, caption='item_2_2', text='item_text_2_2', approved=False)

        self.account_1_items.add_item(item)
        self.account_1_items.save()

        self.request_login(self.account_2.email)

        self.check_html_ok(self.request_html(self.test_url), texts=[(item.caption, 1),
                                                                    (item.text, 1)])
Exemple #20
0
    def create(self):
        form = EditItemForm(self.request.POST)

        if not form.is_valid():
            return self.json_error('collections.items.create.form_errors', form.errors)

        item = ItemPrototype.create(kit=form.c.kit,
                                        caption=form.c.caption,
                                        text=form.c.text)

        return self.json_ok(data={'next_url': url('collections:collections:show', item.kit.collection_id)})
Exemple #21
0
    def setUp(self):
        super(LogicTests, self).setUp()

        create_test_map()

        self.account_1 = self.accounts_factory.create_account()

        self.account_1_items = AccountItemsPrototype.get_by_account_id(self.account_1.id)

        self.collection_1 = CollectionPrototype.create(caption='collection_1', description='description_1')
        self.collection_2 = CollectionPrototype.create(caption='collection_2', description='description_2', approved=True)

        self.kit_1 = KitPrototype.create(collection=self.collection_1, caption='kit_1', description='description_1')
        self.kit_2 = KitPrototype.create(collection=self.collection_2, caption='kit_2', description='description_2', approved=True)
        self.kit_3 = KitPrototype.create(collection=self.collection_2, caption='kit_3', description='description_3', approved=True)

        self.item_1_1 = ItemPrototype.create(kit=self.kit_1, caption='item_1_1', text='text_1_1', approved=False)
        self.item_1_2 = ItemPrototype.create(kit=self.kit_1, caption='item_1_2', text='text_1_2', approved=True)
        self.item_2_1 = ItemPrototype.create(kit=self.kit_2, caption='item_2_1', text='text_2_1', approved=True)
        self.item_2_2 = ItemPrototype.create(kit=self.kit_2, caption='item_2_2', text='text_2_2', approved=False)
        self.item_3_1 = ItemPrototype.create(kit=self.kit_3, caption='item_3_1', text='text_3_1', approved=True)
Exemple #22
0
    def setUp(self):
        super(LogicTests, self).setUp()

        create_test_map()

        result, account_id, bundle_id = register_user('test_user_1', '*****@*****.**', '111111')
        self.account_1 = AccountPrototype.get_by_id(account_id)

        self.account_1_items = AccountItemsPrototype.get_by_account_id(self.account_1.id)

        self.collection_1 = CollectionPrototype.create(caption=u'collection_1', description=u'description_1')
        self.collection_2 = CollectionPrototype.create(caption=u'collection_2', description=u'description_2', approved=True)

        self.kit_1 = KitPrototype.create(collection=self.collection_1, caption=u'kit_1', description=u'description_1')
        self.kit_2 = KitPrototype.create(collection=self.collection_2, caption=u'kit_2', description=u'description_2', approved=True)
        self.kit_3 = KitPrototype.create(collection=self.collection_2, caption=u'kit_3', description=u'description_3', approved=True)

        self.item_1_1 = ItemPrototype.create(kit=self.kit_1, caption=u'item_1_1', text=u'text_1_1', approved=False)
        self.item_1_2 = ItemPrototype.create(kit=self.kit_1, caption=u'item_1_2', text=u'text_1_2', approved=True)
        self.item_2_1 = ItemPrototype.create(kit=self.kit_2, caption=u'item_2_1', text=u'text_2_1', approved=True)
        self.item_2_2 = ItemPrototype.create(kit=self.kit_2, caption=u'item_2_2', text=u'text_2_2', approved=False)
        self.item_3_1 = ItemPrototype.create(kit=self.kit_3, caption=u'item_3_1', text=u'text_3_1', approved=True)
Exemple #23
0
    def setUp(self):
        super(BaseRequestTests, self).setUp()

        create_test_map()

        self.account_1 = self.accounts_factory.create_account()
        self.account_2 = self.accounts_factory.create_account()
        self.account_3 = self.accounts_factory.create_account()
        self.account_4 = self.accounts_factory.create_account()

        self.account_1_items = AccountItemsPrototype.get_by_account_id(self.account_1.id)
        self.account_2_items = AccountItemsPrototype.get_by_account_id(self.account_2.id)
        self.account_3_items = AccountItemsPrototype.get_by_account_id(self.account_3.id)

        group_edit_kit = sync_group('edit kit', ['collections.edit_kit'])
        group_edit = sync_group('edit collection', ['collections.edit_collection'])
        group_edit_item = sync_group('edit item', ['collections.edit_item'])
        group_moderate = sync_group('moderate collection', ['collections.moderate_collection'])
        group_moderate_kit = sync_group('moderate kit', ['collections.moderate_kit'])
        group_moderate_item = sync_group('moderate item', ['collections.moderate_item'])

        group_edit_kit.user_set.add(self.account_2._model)
        group_edit.user_set.add(self.account_2._model)
        group_edit_item.user_set.add(self.account_2._model)
        group_moderate.user_set.add(self.account_3._model)
        group_moderate_kit.user_set.add(self.account_3._model)
        group_moderate_item.user_set.add(self.account_3._model)


        self.collection_1 = CollectionPrototype.create(caption='collection_1', description='description_1')
        self.collection_2 = CollectionPrototype.create(caption='collection_2', description='description_2', approved=True)

        self.kit_1 = KitPrototype.create(collection=self.collection_1, caption='kit_1', description='description_1')
        self.kit_2 = KitPrototype.create(collection=self.collection_2, caption='kit_2', description='description_2', approved=True)

        self.item_1_1 = ItemPrototype.create(kit=self.kit_1, caption='item_1_1', text='item_text_1_1')
        self.item_1_2 = ItemPrototype.create(kit=self.kit_1, caption='item_1_2', text='item_text_1_2', approved=True)
        self.item_2_1 = ItemPrototype.create(kit=self.kit_2, caption='item_2_1', text='item_text_2_1', approved=True)
Exemple #24
0
    def setUp(self):
        super(AccountAchievementsPrototypeTests, self).setUp()

        create_test_map()

        self.account_1 = self.accounts_factory.create_account()

        self.collection_1 = CollectionPrototype.create(caption='collection_1', description='description_1', approved=True)
        self.kit_1 = KitPrototype.create(collection=self.collection_1, caption='kit_1', description='description_1', approved=True)
        self.item_1_1 = ItemPrototype.create(kit=self.kit_1, caption='item_1_1', text='text_1_1', approved=False)
        self.item_1_2 = ItemPrototype.create(kit=self.kit_1, caption='item_1_2', text='text_1_2', approved=True)
        self.item_1_3 = ItemPrototype.create(kit=self.kit_1, caption='item_1_3', text='text_1_3', approved=True)


        self.achievement_1 = AchievementPrototype.create(group=ACHIEVEMENT_GROUP.MONEY, type=ACHIEVEMENT_TYPE.MONEY, barrier=1, points=10,
                                                         caption='achievement_1', description='description_1', approved=True,
                                                         item_1=self.item_1_1, item_2=self.item_1_2)
        self.achievement_2 = AchievementPrototype.create(group=ACHIEVEMENT_GROUP.MONEY, type=ACHIEVEMENT_TYPE.MONEY, barrier=2, points=10,
                                                         caption='achievement_2', description='description_2', approved=False)
        self.achievement_3 = AchievementPrototype.create(group=ACHIEVEMENT_GROUP.TIME, type=ACHIEVEMENT_TYPE.TIME, barrier=3, points=10,
                                                         caption='achievement_3', description='description_3', approved=True)

        self.account_achievements_1 = AccountAchievementsPrototype.get_by_account_id(self.account_1.id)
Exemple #25
0
    def create(self):
        form = EditItemForm(self.request.POST)

        if not form.is_valid():
            return self.json_error('collections.items.create.form_errors',
                                   form.errors)

        item = ItemPrototype.create(kit=form.c.kit,
                                    caption=form.c.caption,
                                    text=form.c.text)

        return self.json_ok(
            data={
                'next_url':
                url('collections:collections:show', item.kit.collection_id)
            })