コード例 #1
0
    def test_get_all_event_joined_by_user_1(self):
        """
        Test get_all_ongoing_event_by_user
        Case1: user has joined some events
        """
        latitude = 40.730610
        longitude = -73.935242
        for i in range(5):
            latitude += 0.01
            longitude += 0.01
            time = datetime.strptime("2020-12-12 12:12:12", "%Y-%m-%d %H:%M:%S")
            tmp_event = Event(user=self.useremail,
                              name="testevent" + str(i),
                              address="address" + str(i),
                              zipcode=10025,
                              event_time=time,
                              longitude=longitude,
                              latitude=latitude)
            tmp_event.category = "test"
            tmp_event_id = Event.create_event(tmp_event)
            self.event_ids.append(tmp_event_id)

            join = Join(self.useremail, tmp_event_id)
            Join.create_join(join)
            if i % 2 == 0:
                like = Like(self.useremail, tmp_event_id)
                Like.create_like(like)

        result = Event.get_all_event_joined_by_user(self.useremail)
        for res in result:
            self.assertTrue(res.event_id in self.event_ids)
        self.assertEqual(5, len(result))
コード例 #2
0
 def test_get_join_by_event_2(self) -> None:
     """
     test get_join_by_event: event doesn't exist
     """
     Join.create_join(Join(self.user, self.event))
     joins = Join.get_join_by_event('1')
     users = [join.user for join in joins]
     self.assertListEqual(users, [])
コード例 #3
0
 def test_get_join_by_event_1(self) -> None:
     """
     test get_join_by_event: event exists
     """
     Join.create_join(Join(self.user, self.event))
     joins = Join.get_join_by_event(self.event)
     users = [join.user for join in joins]
     self.assertListEqual(users, [self.user])
コード例 #4
0
 def test_get_join_by_user_2(self) -> None:
     """
     test get_join_by_user: user doesn't exist
     """
     Join.create_join(Join(self.user, self.event))
     joins = Join.get_join_by_user('')
     events = [join.event for join in joins]
     self.assertListEqual(events, [])
コード例 #5
0
 def test_get_join_by_user_1(self) -> None:
     """
     test get_join_by_user: user exists
     """
     Join.create_join(Join(self.user, self.event))
     joins = Join.get_join_by_user(self.user)
     events = [join.event for join in joins]
     self.assertListEqual(events, [self.event])
コード例 #6
0
 def test_delete_join_4(self) -> None:
     """
     test delete_join: user and event don’t exist
     """
     Join.create_join(Join(self.user, self.event))
     self.assertTrue(Join.user_is_attend(self.user, self.event))
     Join.delete_join(Join('1', '1'))
     self.assertTrue(Join.user_is_attend(self.user, self.event))
コード例 #7
0
 def test_delete_join_3(self) -> None:
     """
     test delete_join: user doesn’t exist, event exists
     """
     Join.create_join(Join(self.user, self.event))
     self.assertTrue(Join.user_is_attend(self.user, self.event))
     Join.delete_join(Join('1', self.event))
     self.assertTrue(Join.user_is_attend(self.user, self.event))
コード例 #8
0
 def test_get_attendees_by_event_1(self):
     """
     Test function get_attendees_by_event
     Event exist
     """
     user = "******"
     event = create_event()
     event.category = "test"
     event_id = Event.create_event(event)
     Join.create_join(Join(user, event_id))
     users = User.get_attendees_by_event(event_id)
     self.assertEqual(users[0].email, user)
     Join.delete_join(Join(user, event_id))
     Event.delete_event_by_id(event_id)
コード例 #9
0
 def test_user_is_attend_1(self) -> None:
     """
     test user_is_attend: user and event exist
     """
     Join.create_join(Join(self.user, self.event))
     self.assertTrue(Join.user_is_attend(self.user, self.event))
コード例 #10
0
 def test_user_is_attend_4(self) -> None:
     """
     test user_is_attend: user and event don’t exist
     """
     Join.create_join(Join(self.user, self.event))
     self.assertFalse(Join.user_is_attend('1', '1'))
コード例 #11
0
 def test_user_is_attend_3(self) -> None:
     """
     test user_is_attend: user doesn’t exist, event exists
     """
     Join.create_join(Join(self.user, self.event))
     self.assertFalse(Join.user_is_attend('1', self.event))
コード例 #12
0
 def test_user_is_attend_2(self) -> None:
     """
     test user_is_attend: user exists, event doesn’t exist
     """
     Join.create_join(Join(self.user, self.event))
     self.assertFalse(Join.user_is_attend(self.user, '1'))