def test_that_it_correctly_fetches_the_event(self, mock_render, mock_event_get):
        mock_user = Mock()
        mock_event = models.Event()
        mock_event_get.return_value = mock_event
        mock_wrapped_view = Mock()
        with patch.object(mock_event, 'verify_ownership') as mock_verify_ownership:
            mock_verify_ownership.return_value = True
            # mock_event.verify_ownership.return_value = True
            request = rf.get('/events/1/edit/')
            request.user = mock_user

            wrapped_view = views.verified_ownership(mock_wrapped_view)
            wrapped_view(request, event_hash = '1')
            mock_event_get.assert_called_with(models.Event, url_hash = '1')
            mock_verify_ownership.assert_called_with(mock_user)
            mock_wrapped_view.assert_called_with(request, mock_event)
 def add_event(self,
               name,
               venue,
               offset,
               public=True,
               verified=True,
               pending_deletion=False):
     start = datetime.datetime.now() + datetime.timedelta(days=offset)
     end = start + datetime.timedelta(hours=3)
     e = models.Event(name=name,
                      venue=venue,
                      organiser_email='*****@*****.**',
                      start=start,
                      end=end,
                      public=public,
                      verified=verified,
                      pending_deletion=pending_deletion)
     e.save()
     return e
    def test_that_a_new_Venue_for_a_new_Event_is_returned(self, MockVenue):
        mock_venue = Mock()
        MockVenue.return_value = mock_venue

        eq_(self.importer.venue_for_event(models.Event()), mock_venue)
        MockVenue.assert_called_with()
    def test_that_unset_ids_are_ignored_when_comparing_instances(self):
        e1 = models.Event(id=1, name="Hallo")
        e2 = models.Event(id=None, name="Hallo")

        ok_(models.EventAndVenueUpdater.are_model_instances_identical(e1, e2))
    def test_that_model_instances_of_different_classes_compare_false(self):
        e1 = models.Event(id=1, name="Hallo")
        e2 = models.Venue(id=1, name="Hallo")

        ok_(not models.EventAndVenueUpdater.are_model_instances_identical(
            e1, e2))
    def test_that_non_identical_model_instances_compare_false(self):
        e1 = models.Event(id=1, name="Hallo")
        e2 = models.Event(id=1, name="Boo hoo")

        ok_(not models.EventAndVenueUpdater.are_model_instances_identical(
            e1, e2))
    def test_that_identical_model_instances_can_be_compared_properly(self):
        e1 = models.Event(id=1, name="Hallo")
        e2 = models.Event(id=1, name="Hallo")

        ok_(models.EventAndVenueUpdater.are_model_instances_identical(e1, e2))
 def test_that_an_event_can_verify_a_user_is_not_its_creator(self):
     e = models.Event(name='An Event', organiser_email='*****@*****.**')
     user = auth_models.User(email='*****@*****.**')
     assert not e.verify_ownership(user)