Beispiel #1
0
 def test_non_real_meetup_raises_validation_error(self):
     self.mock_agent.return_value.exists.return_value = False
     meetup = Meetup(name="Meetup1",
                     meetup_url='http://www.meetup.com/la-la-la/')
     with self.assertRaisesRegexp(ValidationError,
                                  'Meetup not found on meetup.com'):
         meetup.full_clean()
    def post(self):
        title = self.request.POST['title']
        count = int(self.request.POST['count'])
        address = self.request.POST.get('address')
        name = self.request.POST.get('name')
        event_date = self.get_event_date()

        interests = self.request.POST.get('interests')
        if interests: interests = interests.split(',')
        moods = self.request.POST.get('moods')
        if moods: moods = moods.split(',')

        meetup = Meetup(
            creator=self.email,
            title=title,
            time=event_date,
            moods=moods,
            interests=interests,
            count=count,
        )
        meetup.put()

        um = UserMeetup(
            name=name,
            email=self.email,
            meetup=meetup.key,
            address=address,
            moods=moods,
            interests=interests,
        )
        um.put()

        self.out(dict(
            event_id=meetup.key.id(),
        ))
class TestMeetupPresenter(TestCase):

  def setUp(self):
    self.meetup = Meetup(name="Meetup1", meetup_url='http://www.meetup.com/papers-we-love/')
    self.raw_parsed_response = {'venue'           : 'The Lexington',
                                'next_event_topic': 'Code & Coffee',
                                'datetime'        : 1458730800000,
                                'lat'             : 40.75501251220703,
                                'lon'             : -73.97337341308594}
    self.parsed_meetup_response = ParsedMeetupResponse(self.raw_parsed_response)

    self.presenter = MeetupPresenter(self.meetup, self.parsed_meetup_response)

  def test_meetup_presenter_returns_meetup_url(self):
    self.assertEquals(self.presenter.meetup_url(), 'http://www.meetup.com/papers-we-love/')

  def test_meetup_presenter_returns_meetup_name(self):
    self.assertEquals(self.presenter.meetup_name(), 'Meetup1')

  def test_meetup_presenter_returns_meetup_venue(self):
    self.assertEquals('The Lexington', self.presenter.meetup_venue())

  def test_meetup_presenter_returns_meetup_next_topic(self):
    self.assertEquals('Code & Coffee', self.presenter.meetup_next_event_topic())

  def test_meetup_presenter_returns_meetup_datetime(self):
    self.assertEquals("03/23/2016, 07:00:00 AM EDT", self.presenter.meetup_datetime())

  def test_meetup_presenter_returns_meetup_map_url(self):
    self.assertEquals("https://www.google.com/maps?q=40.75501251220703,-73.97337341308594", self.presenter.meetup_map_url())

  def test_meetup_presenter_returns_pizza_place_presenters(self):
    self.meetup.save()
    self.meetup.pizza_places.create(name="Pizza place", yelp_url='https://www.yelp.com/biz/prince-st-pizza-new-york')
    self.assertIsInstance(self.presenter.meetup_pizza_places()[0], PizzaPlacePresenter)
    def setUp(self):
        self.meetup = Meetup(
            name="Meetup1", meetup_url='http://www.meetup.com/papers-we-love/')
        self.raw_parsed_response = {
            'venue': 'The Lexington',
            'next_event_topic': 'Code & Coffee',
            'datetime': 1458730800000,
            'lat': 40.75501251220703,
            'lon': -73.97337341308594
        }
        self.parsed_meetup_response = ParsedMeetupResponse(
            self.raw_parsed_response)

        self.presenter = MeetupPresenter(self.meetup,
                                         self.parsed_meetup_response)
Beispiel #5
0
    def get(self):
        id = self.request.GET['event_id']
        meetup = Meetup.get_by_id(id)
        users = UserMeetup.query(UserMeetup.meetup == meetup.key)

        self.out(
            dict(creator=meetup.creator,
                 title=meetup.title,
                 event_date=meetup.time.isoformat(),
                 moods=meetup.moods,
                 interests=meetup.interests,
                 count=meetup.count,
                 crated=meetup.created.isoformat(),
                 midpoint=meetup.midpoint(user_meetups=users),
                 users=[
                     dict(
                         email=u.email,
                         name=u.name,
                         address=u.address,
                         moods=u.moods,
                         interests=u.interests,
                         statuses=u.statuses,
                         location=dict(
                             lat=u.location.lat,
                             lng=u.location.lon,
                         ) if u.location else None,
                     ) for u in users
                 ]))
Beispiel #6
0
    def post(self):
        event_id = self.request.POST['event_id']
        name = self.request.POST.get('name')
        address = self.request.POST.get('address')

        interests = self.request.POST.get('interests')
        if interests: interests = interests.split(',')
        moods = self.request.POST.get('moods')
        if moods: moods = moods.split(',')

        meetup = Meetup.get_by_id(event_id)
        um = UserMeetup.query(UserMeetup.meetup == meetup.key,
                              UserMeetup.email == self.email).get()
        if not um:
            um = UserMeetup(
                email=self.email,
                meetup=meetup.key,
            )

        if name:
            um.name = name
        if address:
            um.address = address
        if moods:
            um.moods = moods
        if interests:
            um.interests = interests

        um.put()

        self.out(dict(status='ok'))
class TestMeetupPresenter(TestCase):
    def setUp(self):
        self.meetup = Meetup(
            name="Meetup1", meetup_url='http://www.meetup.com/papers-we-love/')
        self.raw_parsed_response = {
            'venue': 'The Lexington',
            'next_event_topic': 'Code & Coffee',
            'datetime': 1458730800000,
            'lat': 40.75501251220703,
            'lon': -73.97337341308594
        }
        self.parsed_meetup_response = ParsedMeetupResponse(
            self.raw_parsed_response)

        self.presenter = MeetupPresenter(self.meetup,
                                         self.parsed_meetup_response)

    def test_meetup_presenter_returns_meetup_url(self):
        self.assertEquals(self.presenter.meetup_url(),
                          'http://www.meetup.com/papers-we-love/')

    def test_meetup_presenter_returns_meetup_name(self):
        self.assertEquals(self.presenter.meetup_name(), 'Meetup1')

    def test_meetup_presenter_returns_meetup_venue(self):
        self.assertEquals('The Lexington', self.presenter.meetup_venue())

    def test_meetup_presenter_returns_meetup_next_topic(self):
        self.assertEquals('Code & Coffee',
                          self.presenter.meetup_next_event_topic())

    def test_meetup_presenter_returns_meetup_datetime(self):
        self.assertEquals("03/23/2016, 07:00:00 AM EDT",
                          self.presenter.meetup_datetime())

    def test_meetup_presenter_returns_meetup_map_url(self):
        self.assertEquals(
            "https://www.google.com/maps?q=40.75501251220703,-73.97337341308594",
            self.presenter.meetup_map_url())

    def test_meetup_presenter_returns_pizza_place_presenters(self):
        self.meetup.save()
        self.meetup.pizza_places.create(
            name="Pizza place",
            yelp_url='https://www.yelp.com/biz/prince-st-pizza-new-york')
        self.assertIsInstance(self.presenter.meetup_pizza_places()[0],
                              PizzaPlacePresenter)
Beispiel #8
0
def meetups(request):
    form = PostMeetup()
    if request.method == "POST":
        form = PostMeetup(request.POST)
        if form.is_valid():
            post_meetup = Meetup(title=form.cleaned_data["title"],
                                 venue=form.cleaned_data["venue"],
                                 when=form.cleaned_data["when"],
                                 description=form.cleaned_data["description"],
                                 created_by=request.user)
            post_meetup.save()

        return redirect("/meetups")
    else:
        meetups = Meetup.objects.all().order_by('-created_on')

    return render(request, 'admin.html', {"meetups": meetups, "form": form})
  def setUp(self):
    self.meetup = Meetup(name="Meetup1", meetup_url='http://www.meetup.com/papers-we-love/')
    self.raw_parsed_response = {'venue'           : 'The Lexington',
                                'next_event_topic': 'Code & Coffee',
                                'datetime'        : 1458730800000,
                                'lat'             : 40.75501251220703,
                                'lon'             : -73.97337341308594}
    self.parsed_meetup_response = ParsedMeetupResponse(self.raw_parsed_response)

    self.presenter = MeetupPresenter(self.meetup, self.parsed_meetup_response)
Beispiel #10
0
    def get(self, request, *args, **kwargs):
        user, categories = request.user, request.GET.get("categories", [])
        coords = [
            request.GET.get('latitude'),
            request.GET.get('longitude'),
            request.GET.get("radius", 25)
        ]
        today = date.today()
        start, end = request.GET.get("startDate", str(today)), request.GET.get(
            "endDate", str(today + timedelta(days=7)))
        meetup_type = request.GET.get('type', 'public')
        latitude, longitude, radius = get_user_coordinates(coords, request)

        if meetup_type == "public":
            meetups = Meetup.get_public(categories, coords, request, start,
                                        end)
        elif meetup_type == "private":
            meetups = Meetup.get_private(categories, coords, request, user,
                                         start, end)
        else:
            return Response(status=status.HTTP_400_BAD_REQUEST)

        meetups_json = {}

        if meetups:
            for meetup in meetups.all():
                serializer = MeetupSerializer(meetup, context={"user": user})
                meetups_json[meetup.uri] = serializer.data

        return Response({
            "meetups": meetups_json,
            'count': len(meetups_json),
            "coords": {
                "latitude": float(latitude),
                "longitude": float(longitude)
            }
        })
Beispiel #11
0
    def get(self, room_id):
        self.confirm_user()
        meetup = Meetup.get_by_id(room_id)

        users = UserMeetup.query(UserMeetup.meetup==meetup.key).fetch()
        if self.email not in [u.email for u in users]:
            um = UserMeetup(
                email=self.email,
                meetup=meetup.key,
            )
            um.put()
            users.append(um)

        self.context = {
            'current_user': self.email,
            'room_id': room_id,
            'meetup': meetup,
            'users': users,
        }

        self.render('pages/room.html')
 def test_error_raised_if_no_trailing_slash_in_meetup_url(self):
   meetup = Meetup(name="Meetup1", meetup_url='http://www.meetup.com/hackerhours')
   with self.assertRaisesRegexp(ValidationError, self.invalid_url_format_message):
     meetup.full_clean()
 def test_error_raised_if_url_does_not_point_to_meetupdotcom(self):
   meetup = Meetup(name="Meetup1", meetup_url='http://www.example.com/')
   with self.assertRaisesRegexp(ValidationError, self.invalid_url_format_message):
     meetup.full_clean()
 def test_service_gets_info_from_meetup_client(self):
   meetup = Meetup(name="Ms. Meetup", meetup_url=valid_meetup_url)
   client_info = MeetupService(meetup).get_decorated_meetup()
   self.assertEquals('Ms. Meetup', client_info.meetup_name())
Beispiel #15
0
 def test_error_raised_if_no_trailing_slash_in_meetup_url(self):
     meetup = Meetup(name="Meetup1",
                     meetup_url='http://www.meetup.com/hackerhours')
     with self.assertRaisesRegexp(ValidationError,
                                  self.invalid_url_format_message):
         meetup.full_clean()
Beispiel #16
0
 def test_blank_meetup_url_raises_integrity_error(self):
     meetup = Meetup(meetup_url='http://meetup.com/some-meetup')
     self.assertRaises(IntegrityError, meetup.save)
Beispiel #17
0
 def test_error_raised_if_url_does_not_point_to_meetupdotcom(self):
     meetup = Meetup(name="Meetup1", meetup_url='http://www.example.com/')
     with self.assertRaisesRegexp(ValidationError,
                                  self.invalid_url_format_message):
         meetup.full_clean()
 def test_url_with_dashes_in_urlname_passes(self):
   meetup = Meetup(name="Meetup1", meetup_url='http://www.meetup.com/papers-we-love/')
   errors_raiesed_by_meetup = meetup.full_clean()
   self.assertIsNone(errors_raiesed_by_meetup)
Beispiel #19
0
 def test_url_with_dashes_in_urlname_passes(self):
     meetup = Meetup(name="Meetup1",
                     meetup_url='http://www.meetup.com/papers-we-love/')
     errors_raiesed_by_meetup = meetup.full_clean()
     self.assertIsNone(errors_raiesed_by_meetup)
Beispiel #20
0
 def test_meetup_raises_error_on_invalid_url(self):
     meetup = Meetup(name="Meetup1", meetup_url='hi/ok/what')
     self.assertRaises(ValidationError, meetup.full_clean)
Beispiel #21
0
 def get_meetup(self, id):
     if not hasattr(self, '_get_meetup'):
         self._get_meetup = Meetup.get_by_id(id)
     return self._get_meetup
Beispiel #22
0
 def test_string_representation_of_meetup_is_its_name(self):
     m = Meetup(name="Mr. Meetup",
                meetup_url='http://meetup.com/some-other-meetup')
     self.assertEquals("Mr. Meetup", str(m))
Beispiel #23
0
 def test_meetup_name_can_not_be_over_500_characters(self):
     name = 'x' * 501
     meetup = Meetup(name=name, meetup_url='http://meetup.com/some-meetup')
     self.assertRaises(DataError, meetup.save)
Beispiel #24
0
 def test_blank_meetup_name_raises_integrity_error(self):
     meetup = Meetup(name='papers we love')
     self.assertRaises(IntegrityError, meetup.save)
 def test_error_raised_if_multiple_urlnames(self):
   meetup = Meetup(name="Meetup1", meetup_url='http://www.meetup.com/hackerhours/events/')
   with self.assertRaisesRegexp(ValidationError, self.invalid_url_format_message):
     meetup.full_clean()
 def test_meetup_url_with_urlname_and_trailing_slash_passes(self):
   meetup = Meetup(name="Meetup1", meetup_url='http://www.meetup.com/hackerhours/')
   errors_raiesed_by_meetup = meetup.full_clean()
   self.assertTrue(errors_raiesed_by_meetup == None)
Beispiel #27
0
 def test_meetup_url_with_urlname_and_trailing_slash_passes(self):
     meetup = Meetup(name="Meetup1",
                     meetup_url='http://www.meetup.com/hackerhours/')
     errors_raiesed_by_meetup = meetup.full_clean()
     self.assertTrue(errors_raiesed_by_meetup == None)
 def test_non_real_meetup_raises_validation_error(self):
   self.mock_agent.return_value.exists.return_value = False
   meetup = Meetup(name="Meetup1", meetup_url='http://www.meetup.com/la-la-la/')
   with self.assertRaisesRegexp(ValidationError, 'Meetup not found on meetup.com'):
     meetup.full_clean()
Beispiel #29
0
 def test_error_raised_if_multiple_urlnames(self):
     meetup = Meetup(name="Meetup1",
                     meetup_url='http://www.meetup.com/hackerhours/events/')
     with self.assertRaisesRegexp(ValidationError,
                                  self.invalid_url_format_message):
         meetup.full_clean()
Beispiel #30
0
 def test_meetup_url_is_unique(self):
     Meetup.objects.create(name="Meetup",
                           meetup_url='http://meetup.com/some-meetup')
     n = Meetup(name="Meetup new",
                meetup_url='http://meetup.com/some-meetup')
     self.assertRaises(IntegrityError, n.save)
Beispiel #31
0
 def test_valid_meetup_has_name_and_url(self):
     meetup = Meetup(name='papers we love',
                     meetup_url='http://meetup.com/some-meetup')
     self.assertEquals(meetup.name, 'papers we love')
     self.assertEquals(meetup.meetup_url, 'http://meetup.com/some-meetup')
Beispiel #32
0
 def test_meetup_is_a_thing(self):
     meetup = Meetup()
     self.assertIsInstance(meetup, Meetup)
Beispiel #33
0
 def test_get_private_meetups_no_categories(self):
     meetups = Meetup.get_private([], [34.228754, -118.2351192, 25], None,
                                  self.user, yesterday, tomorrow)
     self.assertEqual(meetups.count(), 1)
     self.assertEqual(meetups.first(), self.private)