Ejemplo n.º 1
0
    def test_sets_the_location(self):
        lon, lat = self.user.lon, self.user.lat

        with meetups.app.test_request_context():
            logic.sync_user(self.user)

        self.assertEqual(self.user.loc, (lon, lat))
Ejemplo n.º 2
0
    def test_sets_the_location(self):
        lon, lat = self.user.lon, self.user.lat

        with meetups.app.test_request_context():
            logic.sync_user(self.user)

        self.assertEqual(self.user.loc, (lon, lat))
Ejemplo n.º 3
0
    def test_refreshes_if_needed(self):
        data = {"meta": {"next": ""}, "results": []}
        self.meetup.get.return_value.data = data

        with meetups.app.test_request_context():
            logic.sync_user(self.user, maximum_staleness=100)
        self.user.refresh_if_needed.assert_called_once_with(100)
Ejemplo n.º 4
0
    def test_saves_the_user(self):
        data = {"meta": {"next": ""}, "results": []}
        self.meetup.get.return_value.data = data

        with meetups.app.test_request_context():
            logic.sync_user(self.user)

        self.assertTrue(self.user.save.called)
Ejemplo n.º 5
0
    def test_sets_the_location(self):
        data = {"meta": {"next": ""}, "results": []}
        self.meetup.get.return_value.data = data
        lon, lat = self.user.lon, self.user.lat

        with meetups.app.test_request_context():
            logic.sync_user(self.user)

        self.assertEqual(self.user.loc, (lon, lat))
Ejemplo n.º 6
0
    def test_creates_events(self):
        create_events = self.patch("meetups.logic.create_events")

        with meetups.app.test_request_context():
            logic.sync_user(self.user)

        create_events.assert_called_once_with(self.meetup.events.return_value)
        self.assertEqual(self.meetup.events.call_args[1]["group_ids"],
                         self.user.member_of)
Ejemplo n.º 7
0
    def test_creates_venues_with_taglists(self):
        create_venues = self.patch("meetups.logic.create_venues")

        with meetups.app.test_request_context():
            logic.sync_user(self.user)

        create_venues.assert_called_once_with(self.meetup.venues.return_value)
        self.assertEqual(self.meetup.venues.call_args[1]["group_ids"],
                         self.user.member_of)
        self.assertIn("taglist", self.meetup.venues.call_args[1]["fields"])
Ejemplo n.º 8
0
    def test_creates_events(self):
        create_events = self.patch("meetups.logic.create_events")

        with meetups.app.test_request_context():
            logic.sync_user(self.user)

        create_events.assert_called_once_with(self.meetup.events.return_value)
        self.assertEqual(
            self.meetup.events.call_args[1]["group_ids"],
            self.user.member_of
        )
Ejemplo n.º 9
0
    def test_creates_venues_with_taglists(self):
        create_venues = self.patch("meetups.logic.create_venues")

        with meetups.app.test_request_context():
            logic.sync_user(self.user)

        create_venues.assert_called_once_with(self.meetup.venues.return_value)
        self.assertEqual(
            self.meetup.venues.call_args[1]["group_ids"],
            self.user.member_of
        )
        self.assertIn("taglist", self.meetup.venues.call_args[1]["fields"])
Ejemplo n.º 10
0
    def test_syncs_the_groups(self):
        sync_groups = self.patch("meetups.logic.sync_groups")

        with meetups.app.test_request_context():
            logic.sync_user(self.user)

        sync_groups.assert_called_once_with(self.user,
                                            self.meetup.groups.return_value)
        self.assertEqual(
            self.meetup.groups.call_args[1]["member_id"],
            self.user._id,
        )
Ejemplo n.º 11
0
    def test_syncs_the_groups(self):
        sync_groups = self.patch("meetups.logic.sync_groups")

        with meetups.app.test_request_context():
            logic.sync_user(self.user)

        sync_groups.assert_called_once_with(
            self.user, self.meetup.groups.return_value
        )
        self.assertEqual(
            self.meetup.groups.call_args[1]["member_id"],
            self.user._id,
        )
Ejemplo n.º 12
0
    def test_updates_with_the_groups_on_the_current_page(self):
        groups = [{"id": 1}, {"id": 12}]
        member_of = [group["id"] for group in groups]

        def get(endpoint, *args, **kwargs):
            if "groups" in endpoint:
                data = {"meta": {"next": ""}, "results": groups}
            else:
                data = {"meta": {"next": ""}, "results": []}
            return mock.MagicMock(data=data)

        self.meetup.get.side_effect = get

        with meetups.app.test_request_context():
            logic.sync_user(self.user)

        self.assertEqual(self.user.member_of, member_of)
Ejemplo n.º 13
0
    def test_saves_the_user(self):
        with meetups.app.test_request_context():
            logic.sync_user(self.user)

        self.assertTrue(self.user.save.called)
Ejemplo n.º 14
0
 def test_refreshes_if_needed(self):
     with meetups.app.test_request_context():
         logic.sync_user(self.user, maximum_staleness=100)
     self.user.refresh_if_needed.assert_called_once_with(100)
Ejemplo n.º 15
0
    def test_saves_the_user(self):
        with meetups.app.test_request_context():
            logic.sync_user(self.user)

        self.assertTrue(self.user.save.called)
Ejemplo n.º 16
0
 def test_refreshes_if_needed(self):
     with meetups.app.test_request_context():
         logic.sync_user(self.user, maximum_staleness=100)
     self.user.refresh_if_needed.assert_called_once_with(100)