Esempio n. 1
0
    def setUpClass(self):

        print("\n---> Testing Testimonials <---\n")

        self.client = Client()

        self.USER, self.CADMIN, self.SADMIN = createUsers()

        signinAs(self.client, self.SADMIN)

        setupCC(self.client)

        COMMUNITY_NAME = "test_testimonials"
        self.COMMUNITY = Community.objects.create(
            **{
                'subdomain': COMMUNITY_NAME,
                'name': COMMUNITY_NAME.capitalize(),
                'accepted_terms_and_conditions': True
            })

        admin_group_name = f"{self.COMMUNITY.name}-{self.COMMUNITY.subdomain}-Admin-Group"
        self.COMMUNITY_ADMIN_GROUP = CommunityAdminGroup.objects.create(
            name=admin_group_name, community=self.COMMUNITY)
        self.COMMUNITY_ADMIN_GROUP.members.add(self.CADMIN)

        self.TESTIMONIAL1 = Testimonial.objects.create(title="testimonial1")
        self.TESTIMONIAL1.save()
Esempio n. 2
0
    def setUpClass(self):

        print("\n---> Testing Vendors <---\n")

        self.client = Client()

        self.USER, self.CADMIN, self.SADMIN = createUsers()

        signinAs(self.client, self.SADMIN)

        setupCC(self.client)

        COMMUNITY_NAME = "test_vendors"
        self.COMMUNITY = Community.objects.create(
            **{
                'subdomain': COMMUNITY_NAME,
                'name': COMMUNITY_NAME.capitalize(),
                'accepted_terms_and_conditions': True
            })

        admin_group_name = f"{self.COMMUNITY.name}-{self.COMMUNITY.subdomain}-Admin-Group"
        self.COMMUNITY_ADMIN_GROUP = CommunityAdminGroup.objects.create(
            name=admin_group_name, community=self.COMMUNITY)
        self.COMMUNITY_ADMIN_GROUP.members.add(self.CADMIN)

        self.VENDOR1 = Vendor.objects.create(name="vendor1")
        self.VENDOR1.communities.set([self.COMMUNITY])
        self.VENDOR2 = Vendor.objects.create(name="vendor2")
        self.VENDOR2.communities.set([self.COMMUNITY])
        self.VENDOR1.save()
        self.VENDOR2.save()
Esempio n. 3
0
    def setUpClass(self):

        print("\n---> Testing Carbon Equivalencies <---\n")

        self.client = Client()

        self.USER, self.CADMIN, self.SADMIN = createUsers()

        signinAs(self.client, self.SADMIN)

        setupCC(self.client)

        equivalency = {"name": "trees", "value": "41"}
        self.CARBON_EQUIVALENCY = CarbonEquivalency.objects.create(
            **equivalency)
        self.CARBON_EQUIVALENCY.save()
Esempio n. 4
0
    def setUpClass(self):

        print("\n---> Testing Events <---\n")

        self.client = Client()

        self.USER, self.CADMIN, self.SADMIN = createUsers()

        signinAs(self.client, self.SADMIN)

        setupCC(self.client)
    
        COMMUNITY_NAME = "test_events"
        self.COMMUNITY = Community.objects.create(**{
          'subdomain': COMMUNITY_NAME,
          'name': COMMUNITY_NAME.capitalize(),
          'accepted_terms_and_conditions': True
        })

        admin_group_name  = f"{self.COMMUNITY.name}-{self.COMMUNITY.subdomain}-Admin-Group"
        self.COMMUNITY_ADMIN_GROUP = CommunityAdminGroup.objects.create(name=admin_group_name, community=self.COMMUNITY)
        self.COMMUNITY_ADMIN_GROUP.members.add(self.CADMIN)

        self.startTime = datetime.now()
        self.endTime = datetime.now()
        self.EVENT1 = Event.objects.create(community=self.COMMUNITY, name="event1", start_date_and_time=self.startTime, end_date_and_time=self.endTime, is_published=True)
        self.EVENT2 = Event.objects.create(community=self.COMMUNITY, name="event2", start_date_and_time=self.startTime, end_date_and_time=self.endTime, is_published=True)
        self.EVENT3 = Event.objects.create(community=self.COMMUNITY, name="event3", start_date_and_time=self.startTime, end_date_and_time=self.endTime, is_published=True)
        self.EVENT4 = Event.objects.create(community=self.COMMUNITY, name="event4", start_date_and_time=self.startTime, end_date_and_time=self.endTime, is_published=True)
        self.EVENT1.save()
        self.EVENT2.save()
        self.EVENT3.save()
        self.EVENT4.save()

        # a recurring event, to test the date updating
        self.EVENT5 = Event.objects.create(community=self.COMMUNITY, name="event5", start_date_and_time=self.startTime, end_date_and_time=self.endTime, is_published=True)
        self.EVENT5.is_recurring = True
        self.EVENT5.recurring_details = {
          "recurring_type": "week", 
          "separation_count": 1, 
          "day_of_week": "Sunday", 
          #"week_of_month": week_of_month,
          #"final_date": str(final_date)
        } 
        self.EVENT5.save()

        self.RSVP = EventAttendee.objects.create(user=self.USER, event=self.EVENT1, status="GOING").save()
Esempio n. 5
0
    def setUpClass(self):

        print("\n---> Testing User Profiles <---\n")
        self.client = Client()
        self.USER, self.CADMIN, self.SADMIN = createUsers()
        signinAs(self.client, self.SADMIN)
        setupCC(self.client)
        COMMUNITY_NAME = "test_users"
        self.COMMUNITY = Community.objects.create(**{
          'subdomain': COMMUNITY_NAME,
          'name': COMMUNITY_NAME.capitalize(),
          'accepted_terms_and_conditions': True
        })
        admin_group_name  = f"{self.COMMUNITY.name}-{self.COMMUNITY.subdomain}-Admin-Group"
        self.COMMUNITY_ADMIN_GROUP = CommunityAdminGroup.objects.create(name=admin_group_name, community=self.COMMUNITY)
        self.COMMUNITY_ADMIN_GROUP.members.add(self.CADMIN)

        self.REAL_ESTATE_UNIT = RealEstateUnit.objects.create()
        self.REAL_ESTATE_UNIT.save()

        self.USER2 = UserProfile.objects.create(email="*****@*****.**", full_name="user2test2", preferred_name="user2test2")

        self.ACTION  = Action.objects.create()
        self.ACTION2 = Action.objects.create()
        self.ACTION3 = Action.objects.create()
        self.ACTION4 = Action.objects.create()

        response = self.client.post('/api/users.actions.completed.add', urlencode({"user_id": self.USER2.id, "action_id": self.ACTION.id, "household_id": self.REAL_ESTATE_UNIT.id}), content_type="application/x-www-form-urlencoded").toDict()
        self.client.post('/api/users.actions.completed.add', urlencode({"user_id": self.USER2.id, "action_id": self.ACTION2.id, "household_id": self.REAL_ESTATE_UNIT.id}), content_type="application/x-www-form-urlencoded")
        self.client.post('/api/users.actions.completed.add', urlencode({"user_id": self.USER2.id, "action_id": self.ACTION3.id, "household_id": self.REAL_ESTATE_UNIT.id}), content_type="application/x-www-form-urlencoded")

        self.ACTION.save()
        self.ACTION2.save()
        self.ACTION3.save()
        self.ACTION4.save()

        self.USER_ACTION_REL = UserActionRel.objects.filter(user=self.USER2, action=self.ACTION).first()
        self.USER_ACTION_REL2 = UserActionRel.objects.filter(user=self.USER2, action=self.ACTION2).first()
        self.USER_ACTION_REL3 = UserActionRel.objects.filter(user=self.USER2, action=self.ACTION3).first()

        self.PROFILE_PICTURE = createImage("https://www.whitehouse.gov/wp-content/uploads/2021/04/P20210303AS-1901-cropped.jpg")
Esempio n. 6
0
    def setUpClass(self):
        self.client = Client()
        
        self.USER = UserProfile.objects.create(**{
          'full_name': "Regular User",
          'email': '*****@*****.**',
        })

        self.CADMIN = UserProfile.objects.create(**{
          'full_name': "Community Admin",
          'email': '*****@*****.**',
          'is_community_admin': True
        })

        self.SADMIN = UserProfile.objects.create(**{
          'full_name': "Super Admin",
          'email': '*****@*****.**',
          'is_super_admin': True
        })

        signinAs(self.client, self.SADMIN)

        setupCC(self.client)

        generate_inputs = eval(os.getenv("GENERATE_INPUTS"))
        if generate_inputs > 0:
            print("Generating Carbon Calculator input files")
            populate_inputs_file()
            self.input_data = []
        else:
            infile = os.getenv("TEST_INPUTS",default=INPUTS_FILE)
            print("Using input file: "+infile)
            self.input_data = self.read_inputs(self,infile)

        self.output_data = []
        self.differences = []
Esempio n. 7
0
    def setUpClass(self):

        print("\n---> Testing Actions <---\n")

        self.client = Client()

        self.USER, self.CADMIN, self.SADMIN = createUsers()

        signinAs(self.client, self.SADMIN)

        setupCC(self.client)

        COMMUNITY_NAME = "test_actions"
        self.COMMUNITY = Community.objects.create(
            **{
                'subdomain': COMMUNITY_NAME,
                'name': COMMUNITY_NAME.capitalize(),
                'accepted_terms_and_conditions': True
            })

        admin_group_name = f"{self.COMMUNITY.name}-{self.COMMUNITY.subdomain}-Admin-Group"
        self.COMMUNITY_ADMIN_GROUP = CommunityAdminGroup.objects.create(
            name=admin_group_name, community=self.COMMUNITY)
        self.COMMUNITY_ADMIN_GROUP.members.add(self.CADMIN)

        self.ACTION1 = Action(title="action1")
        self.ACTION2 = Action(title="action2")
        self.ACTION3 = Action(title="action3")
        self.ACTION4 = Action(title="action4")
        self.ACTION5 = Action(title="action5")

        self.ACTION1.save()
        self.ACTION2.save()
        self.ACTION3.save()
        self.ACTION4.save()
        self.ACTION5.save()
Esempio n. 8
0
    def setUpClass(self):

        print("\n---> Testing Downloads <---\n")

        self.client = Client()

        self.USER, self.CADMIN, self.SADMIN = createUsers()

        signinAs(self.client, self.SADMIN)

        setupCC(self.client)

        COMMUNITY_NAME = "test_downloads"
        self.COMMUNITY = Community.objects.create(
            **{
                'subdomain': COMMUNITY_NAME,
                'name': COMMUNITY_NAME.capitalize(),
                'accepted_terms_and_conditions': True
            })

        admin_group_name = f"{self.COMMUNITY.name}-{self.COMMUNITY.subdomain}-Admin-Group"
        self.COMMUNITY_ADMIN_GROUP = CommunityAdminGroup.objects.create(
            name=admin_group_name, community=self.COMMUNITY)
        self.COMMUNITY_ADMIN_GROUP.members.add(self.CADMIN)

        self.USER1 = UserProfile.objects.create(
            **{
                'full_name': "Josh Katofksy",
                'email': 'foo@test_downloads.com',
                'accepts_terms_and_conditions': True
            })
        self.USER2 = UserProfile.objects.create(
            **{
                'full_name': "Kosh Jatofsky",
                'email': 'bar@test_downloads.com',
                'accepts_terms_and_conditions': True
            })
        self.USER3 = UserProfile.objects.create(
            **{
                'full_name': "Not A User",
                'email': 'notuser@test_downloads.com',
                'accepts_terms_and_conditions': False
            })

        CommunityMember(community=self.COMMUNITY, user=self.USER1).save()
        CommunityMember(community=self.COMMUNITY, user=self.USER2).save()
        CommunityMember(community=self.COMMUNITY, user=self.USER3).save()

        self.TEAM1 = Team.objects.create(primary_community=self.COMMUNITY,
                                         name="The Downloaders",
                                         is_published=True)
        self.TEAM1.communities.add(self.COMMUNITY)

        self.ADMIN1 = TeamMember(team=self.TEAM1, user=self.USER1)
        self.ADMIN1.is_admin = True
        self.ADMIN1.save()

        self.TEAM1.save()

        self.ACTION1 = Action(title="test downloads action1")
        self.ACTION2 = Action(title="test downloads action2")
        self.ACTION3 = Action(title="test downloads action3")

        self.ACTION1.community = self.COMMUNITY
        self.ACTION2.community = self.COMMUNITY

        self.ACTION1.save()
        self.ACTION2.save()
        self.ACTION3.save()
Esempio n. 9
0
  def setUpClass(self):

    print("\n---> Testing Communities <---\n")

    self.client = Client()

    self.USER, self.CADMIN, self.SADMIN = createUsers()

    signinAs(self.client, self.SADMIN)

    setupCC(self.client)

    name = 'turtles'  
    self.COMMUNITY = Community.objects.create(**{
      'subdomain': name,
      'name': name.capitalize(),
      'accepted_terms_and_conditions': True,
      'is_published': True,
      'is_approved': True
    })

    # also reserve the subdomain
    Subdomain.objects.create(name=self.COMMUNITY.subdomain.lower(), community=self.COMMUNITY, in_use=True)


    self.COMMUNITY2 = Community.objects.create(**{
      'subdomain': "alternate_community",
      'name': "alternate_community",
      'accepted_terms_and_conditions': True,
      'is_approved': True
    })

    # also reserve the subdomain
    Subdomain.objects.create(name=self.COMMUNITY2.subdomain.lower(), community=self.COMMUNITY2, in_use=True)

    admin_group_name  = f"{self.COMMUNITY.name}-{self.COMMUNITY.subdomain}-Admin-Group"
    self.COMMUNITY_ADMIN_GROUP = CommunityAdminGroup.objects.create(name=admin_group_name, community=self.COMMUNITY)
    self.COMMUNITY_ADMIN_GROUP.members.add(self.CADMIN)
    self.COMMUNITY_ADMIN_GROUP.save()

    admin_group_name  = f"{self.COMMUNITY2.name}-{self.COMMUNITY2.subdomain}-Admin-Group"
    self.COMMUNITY_ADMIN_GROUP2 = CommunityAdminGroup.objects.create(name=admin_group_name, community=self.COMMUNITY2)
    self.COMMUNITY_ADMIN_GROUP2.members.add(self.CADMIN)
    self.COMMUNITY_ADMIN_GROUP2.save()
    
    self.USER1 = UserProfile.objects.create(**{
      'full_name': "Community Tester",
      'email': '*****@*****.**'
    })
    self.USER2 = UserProfile.objects.create(**{
      'full_name': "Tester Community",
      'email': '*****@*****.**'
    })
    self.USER3 = UserProfile.objects.create(**{
      'full_name': "mango",
      'email': '*****@*****.**'
    })
    self.USER4 = UserProfile.objects.create(**{
      'full_name': "avocado",
      'email': '*****@*****.**'
    })
    self.USER5 = UserProfile.objects.create(**{
      'full_name': "orange",
      'preferred_name': "banana",
      'email': '*****@*****.**'
    })

    CommunityMember(community=self.COMMUNITY, user=self.USER1).save()
    CommunityMember(community=self.COMMUNITY, user=self.USER2).save()
    CommunityMember(community=self.COMMUNITY, user=self.USER3).save()
    CommunityMember(community=self.COMMUNITY, user=self.USER4).save()
    CommunityMember(community=self.COMMUNITY, user=self.USER5).save()

    goal = Goal(name="Community Goal", 
                target_number_of_actions="10000", 
                target_number_of_households="5000", 
                target_carbon_footprint_reduction="10000000", 
                initial_carbon_footprint_reduction="1000000")
    goal.save()

    self.COMMUNITY.goal = goal
    self.COMMUNITY.save()
    self.COMMUNITY2.save()
Esempio n. 10
0
    def setUpClass(self):

        print("\n---> Testing Teams <---\n")

        self.client = Client()

        self.USER, self.CADMIN, self.SADMIN = createUsers()

        signinAs(self.client, self.SADMIN)

        setupCC(self.client)

        COMMUNITY_NAME = "test_teams"
        self.COMMUNITY = Community.objects.create(
            **{
                'subdomain': COMMUNITY_NAME,
                'name': COMMUNITY_NAME.capitalize(),
                'accepted_terms_and_conditions': True
            })

        self.COMMUNITY2 = Community.objects.create(
            **{
                'subdomain': "community2",
                'name': "community2",
                'accepted_terms_and_conditions': True
            })

        admin_group_name = f"{self.COMMUNITY.name}-{self.COMMUNITY.subdomain}-Admin-Group"
        self.COMMUNITY_ADMIN_GROUP = CommunityAdminGroup.objects.create(
            name=admin_group_name, community=self.COMMUNITY)
        self.COMMUNITY_ADMIN_GROUP.members.add(self.CADMIN)

        self.USER1 = UserProfile.objects.create(
            **{
                'full_name': "Josh Katofksy",
                'email': '*****@*****.**',
                'accepts_terms_and_conditions': True
            })
        self.USER2 = UserProfile.objects.create(
            **{
                'full_name': "Kosh Jatofsky",
                'email': '*****@*****.**',
                'accepts_terms_and_conditions': True
            })
        self.USER3 = UserProfile.objects.create(
            **{
                'full_name': "owen plesko",
                'email': '*****@*****.**',
                'accepts_terms_and_conditions': True
            })
        self.USER4 = UserProfile.objects.create(
            **{
                'full_name': "plesko owen",
                'email': '*****@*****.**',
                'accepts_terms_and_conditions': True
            })
        self.USER5 = UserProfile.objects.create(
            **{
                'full_name': "oweeen",
                'preferred_name': "owen plesko",
                'email': '*****@*****.**',
                'accepts_terms_and_conditions': False
            })

        self.TEAM1 = Team.objects.create(primary_community=self.COMMUNITY,
                                         name="Les Montréalais",
                                         is_published=True)
        self.TEAM1.communities.add(self.COMMUNITY)

        self.TEAM2 = Team.objects.create(primary_community=self.COMMUNITY,
                                         name="McGill CS Students")
        self.TEAM2.communities.add(self.COMMUNITY)

        self.TEAM3 = Team.objects.create(primary_community=self.COMMUNITY,
                                         name="monkey")
        self.TEAM3.communities.add(self.COMMUNITY)

        self.TEAM4 = Team.objects.create(primary_community=self.COMMUNITY,
                                         name="kindred")
        self.TEAM4.communities.add(self.COMMUNITY)

        self.TEAM5 = Team.objects.create(primary_community=self.COMMUNITY,
                                         name="testing teams!")
        self.TEAM5.communities.add(self.COMMUNITY)

        self.ADMIN1 = TeamMember(team=self.TEAM1, user=self.USER1)
        self.ADMIN1.is_admin = True
        self.ADMIN1.save()

        self.ADMIN2 = TeamMember(team=self.TEAM2, user=self.USER2)
        self.ADMIN2.is_admin = True
        self.ADMIN2.save()

        self.ADMIN5 = TeamMember(team=self.TEAM5, user=self.USER2)
        self.ADMIN5.is_admin = True
        self.ADMIN5.save()
        TeamMember(team=self.TEAM5,
                   user=self.USER5).save()  # add a user who didn't accept TOC

        self.TEAM1.save()
        self.TEAM2.save()
        self.TEAM3.save()
        self.TEAM4.save()
        self.TEAM5.save()