Esempio n. 1
0
    def setUp(self):
        # creating org
        org = _create_org("NPF_org_1", "npf")
        self.biz_org = _create_org("BIZ_org_1", 'biz')

        # creating a volunteer that sees the popup
        user_name = 'volunteer_default'
        _create_test_user(user_name)

        # creating a volunteer that answered NO to the popup question
        user_name = 'volunteer_no'
        _create_test_user(user_name)

        # changing setting emulating NO answer to the tooltip
        oc_user = User.objects.get(username=user_name)
        oc_user_settings = UserSettings.objects.get(user=oc_user)
        oc_user_settings.popup_reaction = False
        oc_user_settings.save()

        # creating a volunteer that answered YES to the popup question
        user_name = 'volunteer_yes'
        _create_test_user(user_name)

        # changing setting emulating YES answer to the tooltip
        oc_user = User.objects.get(username=user_name)
        oc_user_settings = UserSettings.objects.get(user=oc_user)
        oc_user_settings.popup_reaction = True
        oc_user_settings.save()

        # create master offer
        _create_offer(self.biz_org,
                      currents_share=_SHARE * 100,
                      is_master=True)

        # setting up client
        self.client = Client()
    def setUp(self):
        """Setup Selenium test."""
        super(PartialRedemptionSelenium, self).setUp()

        self.selenium = webdriver.Firefox()
        self.live_server_url = 'http://127.0.0.1:8081/'

        # giving volunteer_1 some currency
        self.initial_currents = 1.0
        self.receipt_path = 'openCurrents/tests/test_files/'
        self.receipt_name = 'unittest_receipt.jpg'
        _setup_ledger_entry(self.org_npf.orgentity,
                            self.vol_1_entity,
                            amount=self.initial_currents,
                            is_issued=True)

        # creating a new offer to prevent error 500 on marketplace page
        self.offer = _create_offer(self.org_biz,
                                   offer_item_name='Test Item Master',
                                   currents_share=_SHARE * 100,
                                   is_master=True)
Esempio n. 3
0
    def setUp(self):
        # dates
        future_date = timezone.now() + timedelta(days=1)
        past_date = timezone.now() - timedelta(days=2)

        # creating orgs
        self.org1 = _create_org("NPF_org_1", "npf")
        self.org2 = _create_org("NPF_org_2", "npf")
        self.biz_org = _create_org("BIZ_org_1", 'biz')

        # creating 2 projects for 2 npf orgs
        self.project_1 = _create_project(self.org1, 'org1_project_1')
        self.project_2 = _create_project(self.org2, 'org2_project_1')

        # creating volunteers
        self.volunteer_1 = _create_test_user('volunteer_1')
        self.vol_1_entity = UserEntity.objects.get(user=self.volunteer_1)

        self.volunteer_2 = _create_test_user('volunteer_2')
        self.vol_2_entity = UserEntity.objects.get(user=self.volunteer_2)

        # creating admins
        self.npf_admin_1 = _create_test_user('npf_admin_1',
                                             org=self.org1,
                                             is_org_admin=True)
        self.npf_adm_1_entity = UserEntity.objects.get(user=self.npf_admin_1)

        self.npf_admin_2 = _create_test_user('npf_admin_2',
                                             org=self.org2,
                                             is_org_admin=True)
        self.npf_adm_2_entity = UserEntity.objects.get(user=self.npf_admin_2)

        self.biz_admin_1 = _create_test_user('biz_admin_1',
                                             org=self.biz_org,
                                             is_org_admin=True)
        # self.biz_adm_1_entity = UserEntity.objects.get(user=self.biz_admin_1)

        # 1st event time = 3 hours
        self.datetime_start_1 = past_date
        self.datetime_end_1 = past_date + timedelta(hours=3)

        # setting 1 pending events - should create 3 pending currents
        _setup_volunteer_hours(self.volunteer_1, self.npf_admin_1, self.org1,
                               self.project_1, self.datetime_start_1,
                               self.datetime_end_1)

        # setting 1 approved events - should create 3 available currents
        _setup_volunteer_hours(self.volunteer_1,
                               self.npf_admin_1,
                               self.org1,
                               self.project_1,
                               self.datetime_start_1,
                               self.datetime_end_1,
                               is_verified=True,
                               action_type='app')

        # issuing currents from npf org to vol1 - should create 20 available
        # currents in total
        OcLedger().issue_currents(
            entity_id_from=self.org1.orgentity.id,
            entity_id_to=self.vol_1_entity.id,
            action=None,
            amount=20,
        )

        # transacting 4 currents from volunteer to biz org - should create 16
        # available currents in total (20 - 4)
        OcLedger().transact_currents(
            entity_type_from=self.vol_1_entity.entity_type,
            entity_id_from=self.vol_1_entity.id,
            entity_type_to=self.biz_org.orgentity.entity_type,
            entity_id_to=self.biz_org.orgentity.id,
            action=None,
            amount=4)

        # setting up pending transaction
        _setup_transactions(self.biz_org, self.biz_admin_1, 0.436, 10.91)

        # create master offer
        _create_offer(self.biz_org,
                      currents_share=_SHARE * 100,
                      is_master=True)

        # setting up client
        self.client = Client()
Esempio n. 4
0
    def setUp(self):
        self.test_curr_per_tr = 12

        # dates
        future_date = timezone.now() + timedelta(days=1)
        past_date = timezone.now() - timedelta(days=2)

        # creating orgs
        org1 = _create_org("NPF_org_1", "npf")
        org2 = _create_org("NPF_org_2", "npf")

        # creating a volunteer
        volunteer_1 = _create_test_user('volunteer_1')
        vol_1_entity = UserEntity.objects.get(user=volunteer_1)
        volunteer_2 = _create_test_user('volunteer_2')

        # creting bizorg and its admin
        biz_org = OcOrg().setup_org(name="BIZ_org_1", status='biz')
        biz_admin_1 = _create_test_user('biz_admin_1',
                                        org=biz_org,
                                        is_org_admin=True)

        biz_org_oc = _create_org("openCurrents", "biz")

        # creating an admins for NPF_orgs
        npf_admin_1 = _create_test_user('npf_admin_1',
                                        org=org1,
                                        is_org_admin=True)
        npf_admin_2 = _create_test_user('npf_admin_2',
                                        org=org2,
                                        is_org_admin=True)

        # creating 2 projects for 2 npf orgs
        project_1 = _create_project(org1, 'org1_project_1')
        project_2 = _create_project(org2, 'org2_project_1')

        # 1st event time = 3 hours
        datetime_start_1 = past_date
        datetime_end_1 = past_date + timedelta(hours=3)
        # 2nd event time = 2 hours
        datetime_start_2 = past_date + timedelta(hours=3)
        datetime_end_2 = past_date + timedelta(hours=5)

        # setting two approved events for different NPF orgs in the past
        # approved 3 hrs for org1
        _setup_volunteer_hours(volunteer_1,
                               npf_admin_1,
                               org1,
                               project_1,
                               datetime_start_1,
                               datetime_end_1,
                               is_verified=True,
                               action_type='app')

        # approved 2 hrs for org2
        _setup_volunteer_hours(volunteer_1,
                               npf_admin_2,
                               org2,
                               project_2,
                               datetime_start_2,
                               datetime_end_2,
                               is_verified=True,
                               action_type='app')

        # setting a pending past events 3 hrs
        _setup_volunteer_hours(volunteer_1, npf_admin_1, org1, project_1,
                               datetime_start_1, datetime_end_1)

        # setting up two future events 5 hrs each
        self.event1 = _create_event(project_1,
                                    npf_admin_1.id,
                                    future_date,
                                    future_date + timedelta(hours=5),
                                    is_public=True)
        self.event2 = _create_event(project_1,
                                    npf_admin_1.id,
                                    future_date,
                                    future_date + timedelta(hours=5),
                                    description="Test Event 2",
                                    is_public=True)

        # issuing currents to volunteer1
        OcLedger().issue_currents(
            entity_id_from=org1.orgentity.id,
            entity_id_to=vol_1_entity.id,
            action=None,
            amount=40,
        )

        # registering user for an event
        _setup_user_event_registration(volunteer_1, self.event2)

        # setting up user dollars "Dollars available"
        _setup_ledger_entry(org1.orgentity,
                            vol_1_entity,
                            currency='usd',
                            amount=30.30,
                            is_issued=True)

        # setting approved and pending dollars
        _setup_transactions(biz_org, volunteer_1, self.test_curr_per_tr, 20)
        _setup_transactions(biz_org,
                            volunteer_1,
                            self.test_curr_per_tr,
                            20,
                            action_type='app')
        _setup_transactions(biz_org,
                            volunteer_1,
                            self.test_curr_per_tr,
                            20,
                            action_type='red')

        # create master offer
        _create_offer(biz_org, currents_share=_SHARE * 100, is_master=True)

        # setting up client
        self.client = Client()
    def set_up_objects(self, old=False, user=False):
        # creating NPF org
        org = OcOrg().setup_org(name="NPF_org_1", status="npf")
        self.org_id = org_id = org.id

        # create BIZ org
        biz_org = _create_org("BIZ_org_1", 'biz')

        # create master offer
        _create_offer(biz_org, currents_share=_SHARE * 100, is_master=True)

        # creating users
        # admins
        self.create_user('org_user_1',
                         org,
                         is_org_user=True,
                         is_org_admin=True)
        self.create_user('org_user_2',
                         org,
                         is_org_user=True,
                         is_org_admin=True,
                         password='******')
        self.create_user('org_user_3',
                         org,
                         is_org_user=True,
                         is_org_admin=True,
                         password='******')

        self.org_user_1 = User.objects.get(username='******')
        self.org_user_2 = User.objects.get(username='******')
        self.org_user_3 = User.objects.get(username='******')

        # volunteer user
        self.create_user('volunteer_1',
                         org,
                         is_org_user=False,
                         is_org_admin=False)
        self.create_user('volunteer_2',
                         org,
                         is_org_user=False,
                         is_org_admin=False)

        # setup Project
        project = Project.objects.create(org=org, name="test_project_1")

        org_admin = User.objects.get(username='******')

        future_date = timezone.now() + timedelta(days=1)
        past_date = timezone.now() - timedelta(days=2)

        # setting up events
        self.future_event = Event.objects.create(project=project,
                                                 is_public=True,
                                                 description="future event",
                                                 location="test_location_1",
                                                 coordinator=org_admin,
                                                 creator_id=org_admin.id,
                                                 event_type="GR",
                                                 datetime_start=future_date,
                                                 datetime_end=future_date +
                                                 timedelta(days=1))

        self.current_event = Event.objects.create(project=project,
                                                  is_public=True,
                                                  description="current event",
                                                  location="test_location_2",
                                                  coordinator=org_admin,
                                                  creator_id=org_admin.id,
                                                  event_type="GR",
                                                  datetime_start=past_date,
                                                  datetime_end=future_date)

        self.finished_event = Event.objects.create(
            project=project,
            is_public=True,
            description="finished event",
            location="test_location_3",
            coordinator=org_admin,
            creator_id=org_admin.id,
            event_type="GR",
            datetime_start=past_date,
            datetime_end=past_date + timedelta(days=1))

        # @@ TODO @@
        # move repeatable actions during setting up testing environment to a class in tests/interfaces
        #

        # creating APPROVED 4 hours for NPF admin1
        volunteer1 = User.objects.get(username='******')
        datetime_start = past_date + timedelta(hours=2)
        datetime_end = past_date + timedelta(hours=6)

        project = Project.objects.create(org=org, name="test_project_2")

        volunteer1_mt_event_1 = Event.objects.create(
            project=project,
            is_public=True,
            description="finished event",
            location="test_location_4",
            coordinator=org_admin,
            event_type="MN",
            datetime_start=datetime_start,
            datetime_end=datetime_end)

        volunteer1_timelog = UserTimeLog.objects.create(
            user=volunteer1,
            event=volunteer1_mt_event_1,
            datetime_start=datetime_start,
            datetime_end=datetime_end,
            is_verified=True)

        actiontimelog = AdminActionUserTime.objects.create(
            user=org_admin, usertimelog=volunteer1_timelog, action_type='app')

        # creating APPROVED 2 hours for NPF admin2
        org_admin = User.objects.get(username='******')
        volunteer2 = User.objects.get(username='******')
        datetime_start = past_date + timedelta(hours=1)
        datetime_end = past_date + timedelta(hours=3)

        project = Project.objects.create(org=org, name="test_project_2")

        volunteer2_mt_event_1 = Event.objects.create(
            project=project,
            is_public=True,
            description="finished event 2",
            location="test_location_5",
            coordinator=org_admin,
            event_type="MN",
            datetime_start=datetime_start,
            datetime_end=datetime_end)

        volunteer2_timelog = UserTimeLog.objects.create(
            user=volunteer2,
            event=volunteer2_mt_event_1,
            datetime_start=datetime_start,
            datetime_end=datetime_end,
            is_verified=True)

        actiontimelog = AdminActionUserTime.objects.create(
            user=org_admin, usertimelog=volunteer2_timelog, action_type='app')

        # creating APPROVED 6 hours for NPF admin3
        org_admin = User.objects.get(username='******')
        volunteer2 = User.objects.get(username='******')
        datetime_start = past_date + timedelta(hours=4)
        datetime_end = past_date + timedelta(hours=10)

        project = Project.objects.create(org=org, name="test_project_2")

        volunteer2_mt_event_1 = Event.objects.create(
            project=project,
            is_public=True,
            description="finished event 2",
            location="test_location_5",
            coordinator=org_admin,
            event_type="MN",
            datetime_start=datetime_start,
            datetime_end=datetime_end)

        volunteer2_timelog = UserTimeLog.objects.create(
            user=volunteer2,
            event=volunteer2_mt_event_1,
            datetime_start=datetime_start,
            datetime_end=datetime_end,
            is_verified=True)

        actiontimelog = AdminActionUserTime.objects.create(
            user=org_admin, usertimelog=volunteer2_timelog, action_type='app')

        # creating PENDING 1 hour assigned to NPF admin1 (currently logged in)
        volunteer2 = User.objects.get(username='******')
        org_admin = User.objects.get(username='******')
        datetime_start = past_date + timedelta(hours=5)
        datetime_end = past_date + timedelta(hours=6)

        volunteer2_mt_event_2 = Event.objects.create(
            project=project,
            is_public=True,
            description="pending event",
            location="test_location_6",
            coordinator=org_admin,
            event_type="MN",
            datetime_start=datetime_start,
            datetime_end=datetime_end)

        volunteer2_timelog = UserTimeLog.objects.create(
            user=volunteer2,
            event=volunteer2_mt_event_2,
            datetime_start=datetime_start,
            datetime_end=datetime_end,
            is_verified=False)

        actiontimelog = AdminActionUserTime.objects.create(
            user=org_admin, usertimelog=volunteer2_timelog, action_type='req')

        # creating PENDING 2 hours assigned to NPF admin2
        volunteer1 = User.objects.get(username='******')
        org_admin = User.objects.get(username='******')
        datetime_start = past_date + timedelta(hours=2)
        datetime_end = past_date + timedelta(hours=4)

        volunteer1_mt_event_2 = Event.objects.create(
            project=project,
            is_public=True,
            description="pending event",
            location="test_location_7",
            coordinator=org_admin,
            event_type="MN",
            datetime_start=datetime_start,
            datetime_end=datetime_end)

        volunteer1_timelog = UserTimeLog.objects.create(
            user=volunteer1,
            event=volunteer1_mt_event_2,
            datetime_start=datetime_start,
            datetime_end=datetime_end,
            is_verified=False)

        actiontimelog = AdminActionUserTime.objects.create(
            user=org_admin, usertimelog=volunteer1_timelog, action_type='req')

        # creating PENDING 3 hours assigned to NPF admin3
        volunteer2 = User.objects.get(username='******')
        org_admin = User.objects.get(username='******')
        datetime_start = past_date + timedelta(hours=1)
        datetime_end = past_date + timedelta(hours=4)

        volunteer2_mt_event_2 = Event.objects.create(
            project=project,
            is_public=True,
            description="pending event",
            location="test_location_8",
            coordinator=org_admin,
            event_type="MN",
            datetime_start=datetime_start,
            datetime_end=datetime_end)

        volunteer2_timelog = UserTimeLog.objects.create(
            user=volunteer2,
            event=volunteer2_mt_event_2,
            datetime_start=datetime_start,
            datetime_end=datetime_end,
            is_verified=False)

        actiontimelog = AdminActionUserTime.objects.create(
            user=org_admin, usertimelog=volunteer2_timelog, action_type='req')