Example #1
0
    def test_translated_competition_entry_stored_against_the_main_lang(self):
        client = Client()
        client.login(username='superuser', password='pass')

        en_comp = YourWordsCompetition(
            title='Test Competition',
            description='This is the description',
            slug='test-competition')
        self.competition_index.add_child(instance=en_comp)
        en_comp.save_revision().publish()

        self.client.post(reverse(
            'add_translation', args=[en_comp.id, 'fr']))
        fr_comp = YourWordsCompetition.objects.get(
            slug='french-translation-of-test-competition')
        fr_comp.save_revision().publish()

        client.post(
            reverse('molo.yourwords:competition_entry', args=[fr_comp.slug]), {
                'story_name': 'this is a french story',
                'story_text': 'The text',
                'terms_or_conditions_approved': 'true'})

        entry = YourWordsCompetitionEntry.objects.all().first()
        self.assertEqual(entry.story_name, 'this is a french story')
        self.assertEqual(entry.competition.id, en_comp.id)
class TestComprehensiveTheming(ModuleStoreTestCase):
    """Tests for comprehensive theming of wiki pages."""

    def setUp(self):
        """Test setup."""
        super(TestComprehensiveTheming, self).setUp()

        self.wiki = get_or_create_root()

        self.course_math101 = CourseFactory.create(org='edx', number='math101', display_name='2014',
                                                   metadata={'use_unique_wiki_id': 'false'})
        self.course_math101_instructor = InstructorFactory(course_key=self.course_math101.id, username='instructor',
                                                           password='secret')
        self.wiki_math101 = URLPath.create_article(self.wiki, 'math101', title='math101')

        self.client = Client()
        self.client.login(username='instructor', password='secret')

    @skip("Fails when run immediately after lms.djangoapps.course_wiki.tests.test_middleware")
    @with_comprehensive_theme('red-theme')
    def test_themed_footer(self):
        """
        Tests that theme footer is used rather than standard
        footer when comprehensive theme is enabled.
        """
        response = self.client.get('/courses/edx/math101/2014/wiki/math101/')
        self.assertEqual(response.status_code, 200)
        # This string comes from themes/red-theme/lms/templates/footer.html
        self.assertContains(response, "super-ugly")
Example #3
0
def visitar_pagina_listagem():
    with Mock() as delivery:
        from delivery.models import Remedio
        Remedio.objects.all() >> scc.remedios
    client = Client()
    scc.response = client.get('/delivery/remedios')
    delivery.validate()
Example #4
0
    def test_confirm(self):
        c = Client()
        acc = Account()
        acc.username='010001'
        acc.password='010001'
        acc.fullname='foouser'
        acc.created = datetime.datetime.now()
        acc.contract = '010001'
        acc.save()
        TransactionType.objects.create(name='EasyPay', internal_name = 'payments.easypay')
        
        response = c.post(reverse('getpaid-easypay-pay'), """<Request>
<DateTime>yyyy-MM-ddTHH:mm:ss</DateTime>
<Sign></Sign>
<Payment>
<ServiceId>1</ServiceId>
<OrderId>1</OrderId>
<Account>010001</Account>
<Amount>10.11</Amount>
</Payment>
</Request>""", content_type='text/xml')
        print response.content
        bs = BeautifulSoup(response.content)
        response = c.post(reverse('getpaid-easypay-pay'), """<Request>
<DateTime>yyyy-MM-ddTHH:mm:ss</DateTime>
<Sign></Sign>
<Confirm>
<ServiceId>1</ServiceId>
<PaymentId>%s</PaymentId>
</Confirm>
</Request>""" % bs.response.paymentid, content_type='text/xml')
        
        print 'TRANSACTION=', Transaction.objects.get(type__internal_name='payments.easypay', bill='1')
        
        print response.content
Example #5
0
 def test_non_downloadable_resource_for_normal_organization_members(self):
     """
     Verifies that a resource with an MS Commons license cannot be downloaded
     by a user of an organization which does not have the META-SHARE full
     member permission.
     """
     test_passwd = 'secret'
     test_user = test_utils.create_organization_member(
         'organization_member_non_ms', 'om_non_ms@example.com', test_passwd,
         (Organization.objects.create(name='test_organization_non_ms'),))
     client = Client()
     client.login(username=test_user.username, password=test_passwd)
     # make sure the license page is shown:
     response = client.get(reverse(views.download,
                 args=(self.ms_commons_resource.storage_object.identifier,)),
         follow = True)
     self.assertTemplateUsed(response, 'repository/licence_agreement.html',
                             "license agreement page expected")
     self.assertContains(response,
         'licences/META-SHARE_COMMONS_BYNCSA_v1.0.htm', msg_prefix="the " \
             "correct license appears to not be shown in an iframe")
     # make sure the download cannot be started:
     response = client.post(
         reverse(views.download,
                 args=(self.ms_commons_resource.storage_object.identifier,)),
         { 'in_licence_agree_form': 'True', 'licence_agree': 'True',
           'licence': 'MSCommons-BY-NC-SA' },
         follow = True)
     self.assertTemplateUsed(response, 'repository/licence_agreement.html',
         msg_prefix="a download should not have been started")
Example #6
0
    def testEditChanges(self):
        user, info = test_user()
        _, change_info = test_user(create=False)

        c = Client()
        self.assertTrue(c.login(username=info['username'],
                                password=info['password']), "Can't log in?")

        c.post(reverse('account:edit'), {
            'email': change_info['email'],
            'preferred_name': change_info['preferred_name'],
            'real_name': change_info['real_name'],
        })

        # refresh the user
        # user.refresh_from_db() # we don't get this until dj1.8...
        user = User.objects.get(pk=user.pk)
        self.assertFalse(user.userdata.email_verified)
        self.assertTrue(user.emailverification_set.all().exists())
        self.assertEqual(user.first_name, user.userdata.preferred_name)
        self.assertEqual(user.last_name, '')
        self.assertEqual(user.userdata.preferred_name,
                         change_info['preferred_name'])
        self.assertEqual(user.userdata.real_name, change_info['real_name'])
        self.assertEqual(user.email, change_info['email'])
Example #7
0
class TestLogin(TransactionTestCase):
    fixtures = ['init_panda.json']

    def setUp(self):
        self.user = utils.get_panda_user()
        
        self.client = Client()

    def test_login_success(self):
        response = self.client.post('/login/', { 'email': 'user@pandaproject.net', 'password': 'user' }) 

        self.assertEqual(response.status_code, 200)

        body = json.loads(response.content)

        self.assertEqual(body['email'], 'user@pandaproject.net')
        self.assertEqual(body['api_key'], 'edfe6c5ffd1be4d3bf22f69188ac6bc0fc04c84c')
        self.assertEqual(body['notifications'], [])

    def test_login_disabled(self):
        self.user.is_active = False
        self.user.save()

        response = self.client.post('/login/', { 'email': 'user@pandaproject.net', 'password': 'user' }) 

        self.assertEqual(response.status_code, 400)

        body = json.loads(response.content)

        self.assertIn('disabled', body['__all__'])

        self.user.is_active = True
        self.user.save()

    def test_login_invalid_email(self):
        response = self.client.post('/login/', { 'email': 'NOTPANDA@pandaproject.net', 'password': 'panda' }) 

        self.assertEqual(response.status_code, 400)

        body = json.loads(response.content)

        self.assertIn('incorrect', body['__all__'])

    def test_login_incorrect_password(self):
        response = self.client.post('/login/', { 'email': 'user@pandaproject.net', 'password': 'NOPANDA' }) 

        self.assertEqual(response.status_code, 400)

        body = json.loads(response.content)

        self.assertIn('incorrect', body['__all__'])

    def test_no_get(self):
        response = self.client.get('/login/', { 'email': 'user@pandaproject.net', 'password': 'NOPANDA' }) 

        self.assertEqual(response.status_code, 400)

        body = json.loads(response.content)

        self.assertEqual(body, None)
Example #8
0
 def test_contact_form_error(self):
     data = {'nome': 'Fulano de tal', 'email': '', 'message': ''}
     client = Client()
     path = reverse('courses:detail', args=[self.course.slug])
     response = client.post(path, data)
     self.assertFormError(response, 'form', 'email', 'Este campo é obrigatório.')
     self.assertFormError(response, 'form', 'message', 'Este campo é obrigatório.')
Example #9
0
def test_xblock_with_handlers():
    # Tests of handler urls.
    client = Client()

    # The view sends a list of URLs to try.
    response = client.get("/view/with-handlers/")
    parsed = response.content.split(":::")
    assert_equals(len(parsed), 3)
    urls = json.loads(parsed[1])

    # These have to correspond to the urls in XBlockWithHandlers.student_view above.
    expecteds = [
        {"suffix": "", "a": "no-a", "b": "no-b"},
        {"suffix": "with_some_suffix", "a": "no-a", "b": "no-b"},
        {"suffix": "", "a": "123", "b": "no-b"},
        {"suffix": "", "a": "123", "b": "456"},
        {"suffix": "another_suffix", "a": "123", "b": "456"},
        {"suffix": "", "a": "no-a", "b": "no-b"},
        {"suffix": "with_some_suffix", "a": "no-a", "b": "no-b"},
        {"suffix": "", "a": "123", "b": "no-b"},
        {"suffix": "", "a": "123", "b": "456"},
        {"suffix": "another_suffix", "a": "123", "b": "456"},
    ]

    for url, expected in zip(urls, expecteds):
        print url  # so we can see which one failed, if any.
        response = client.get(url)
        assert_equals(response.status_code, 200)
        actual = json.loads(response.content)
        assert_equals(actual, expected)
Example #10
0
class AdminTest(TestCase):
    fixtures = ['l10n-data.yaml', 'sample-store-data.yaml', 'products.yaml', 'initial_data.yaml']

    def setUp(self):
        self.client = Client()
        user = User.objects.create_user('fredsu', 'fred@root.org', 'passwd')
        user.is_staff = True
        user.is_superuser = True
        user.save()
        self.client.login(username='fredsu', password='passwd')

    def tearDown(self):
        cache_delete()

    def test_index(self):
        response = self.client.get('/admin/')
        self.assertContains(response, "contact/contact/", status_code=200)

    #def test_product(self):
        response = self.client.get('/admin/product/product/1/')
        self.assertContains(response, "Django Rocks shirt", status_code=200)

    #def test_configurableproduct(self):
        response = self.client.get('/admin/configurable/configurableproduct/1/')
        self.assertContains(response, "Small, Black", status_code=200)
Example #11
0
class PremioTest(TestCase):
    def setUp(self):
        self.client = Client()
        self.user = UserFactory()
        self.post_data = {'text': 'Esta pelicula es genial'}
        self.movie = MovieFactory()
        self.movie.save()
        self.client.login(username=self.user.username, password='1234')

    def test_premio(self):
        from django.utils import simplejson
        m = mocker.Mocker()
        obj = m.replace('random')
        obj.randint(1, 200)
        m.result(22)
        k = {'movie_id': self.movie.id}
        m.replay()

        response = self.client.post(reverse('add_review', kwargs=k), self.post_data)

        self.assertEquals(response.status_code, 201)
        self.assertEquals(self.movie.moviereview_set.count(), 1)
        d = simplejson.loads(response.content)

        self.assertTrue(d.has_key('premio'))
    def test_POST_delete_logo(self):
        """
        If the 'delete_logo' POST argument is present, the logo should be
        deleted.
        """
        self.profile.logo = File(self._data_file('logo.png'))
        self.profile.save()
        self.assertTrue(self.profile.logo)

        data = {
            'username': self.user.username,
            'name': self.user.get_full_name(),
            'email': self.user.email,
            'delete_logo': 'yes'
            }

        c = Client()
        c.login(username='user', password='password')
        response = c.post(self.url, data)
        self.assertStatusCodeEquals(response, 302)
        self.assertEqual(response['Location'],
                          'http://%s%s' % (
                self.site_settings.site.domain,
                self.url))

        user = User.objects.get(pk=self.user.pk)
        profile = user.get_profile()
        self.assertFalse(profile.logo)
    def test_POST_success(self):
        """
        Filling the ProfileForm with data should cause the Profile to be
        updated.
        """
        data = {
            'username': 'newusername',
            'name': 'First Last',
            'email': 'test@foo.bar.com',
            'description': 'New Description',
            'location': 'Where I am',
            'website': 'http://www.google.com'
            }
        c = Client()
        c.login(username='user', password='password')
        response = c.post(self.url, data)
        self.assertStatusCodeEquals(response, 302)
        self.assertEqual(response['Location'],
                          'http://%s%s' % (
                self.site_settings.site.domain,
                self.url))

        user = User.objects.get(pk=self.user.pk)
        self.assertEqual(user.username, 'newusername')
        self.assertEqual(user.first_name, 'First')
        self.assertEqual(user.last_name, 'Last')
        self.assertEqual(user.email, 'test@foo.bar.com')
        self.assertEqual(user.get_profile().description,
                          'New Description')
        self.assertEqual(user.get_profile().location, 'Where I am')
        self.assertEqual(user.get_profile().website,
                          'http://www.google.com/')
Example #14
0
File: tests.py Project: jjdu/gbd
    def test_get_covariate_types(self):
        c = Client()

        url = reverse('gbd.covariate_data_server.views.get_covariate_types')
        response = c.get(url)
        self.assertRedirects(response, '/accounts/login/?next=%s'%url)
        # then login and do functional tests
        c.login(username='red', password='red')

        response = c.get(url)
        #import pdb;pdb.set_trace()
        resp_json = json.loads(response.content)['cov']
        
        self.assertEqual(resp_json[0]['slug'], 'GDP')
        self.assertEqual(resp_json[0]['uploader'], 'red')
        self.assertEqual(resp_json[0]['source'], 'web')
        self.assertEqual(resp_json[0]['notes'], 'notes')
        self.assertEqual(resp_json[0]['year range'], '1950-2010')
        self.assertEqual(resp_json[0]['region only'], 'False')
        self.assertEqual(resp_json[0]['mean'], 0.130)
        self.assertEqual(resp_json[0]['variance'], 0.004817)
        self.assertEqual(resp_json[1]['slug'], 'ABC')
        self.assertEqual(resp_json[1]['uploader'], 'red')
        self.assertEqual(resp_json[1]['source'], 'web')
        self.assertEqual(resp_json[1]['notes'], 'notes')
        self.assertEqual(resp_json[1]['year range'], '1950-2010')
        self.assertEqual(resp_json[1]['region only'], 'True')
        self.assertEqual(resp_json[1]['mean'], 0.095)
        self.assertEqual(resp_json[1]['variance'], 0.002692)
Example #15
0
    def test_teacher_attendance(self):
        """ Tests to ensure that we can take attendance. This test covers
                the submission_percentage dashlet and teacher_submission view. """
        self.setup()

        user = User.objects.get(username='dburke')
        user.set_password('aa') # Why is this needed?
        user.save()

        c = Client()

        c.login(username='dburke', password='aa')

        response = c.get('/admin/')
        self.assertEqual(response.status_code, 200)

        course_section = CourseSection.objects.get(name="Homeroom FX 2011")

        response = c.get('/attendance/teacher_attendance/' + str(course_section.id), follow=True)
        self.assertEqual(response.status_code, 200)

        AttendanceLog(user=user, course_section=self.course_section1).save()
        AttendanceLog(user=user, course_section=self.course_section2).save()

        homerooms = CourseSection.objects.filter(course__homeroom=True)
        for homeroom in homerooms:
            log = AttendanceLog.objects.filter(course_section=homeroom)
            assert log.count() > 0
Example #16
0
def test_xblock_no_student_view():
    # Try to get a response. Will try to render via WorkbenchRuntime.render;
    # since no view is provided in the XBlock, will return a Fragment that
    # indicates there is no view available.
    client = Client()
    response = client.get("/view/xblockwithoutstudentview/")
    assert_true("No such view" in response.content)
Example #17
0
 def testRegisterNoPreferredName(self):
     c = Client()
     _, d = test_user(create=False)
     del d['preferred_name']
     r = c.post(reverse('account:register'), d)
     self.assertTrue(r.status_code, 200)
     self.assertFalse(User.objects.filter(email=d['email']).exists())
Example #18
0
 def test_basic (self):
     """
     Tests that 1 + 1 always equals 2.
     """
     self.failUnlessEqual(1 + 1, 2)
     c = Client ()
     test_url_list = ['/erp/home/login/',
                      '/erp/home/login',
                      '/erp/home/',
                      '/erp/home',
                      '/erp/',
                      '/erp',
                      '/erp/h',
                      '/erp/home/',
                      '/erp/home',
                      '/erp/home/login/',
                      '/erp/home/login',
                      '/erp/home/forgot_password',
                      '/erp/home/forgot_password/',
                      '/erp/home/logout',
                      '/erp/home/logout/',
                      '/erp/ee09b001/users',
                      '/erp/ee09b001/users/',
                      '/erp/ee09b001/users/register/',
                      '/erp/ee09b001/users/register',
                      '/erp/ee09b001/users/register/new',
                      '/erp/ee09b001/users/invite/',
                      '/erp/ee09b001/users/edit_profile/',
                      ]
     for url in test_url_list:
         response = c.get (url)
         try:
             print url, response.status_code
         except:
             pass
Example #19
0
 def testLocalLogInRedirect(self):
     c = Client()
     response = c.post('/account/?next=/foo/', {
         'email': self.userinfo['email'],
         'password': self.userinfo['password']
     })
     self.assertRedirects(response, '/foo/', status_code=302, target_status_code=200)
Example #20
0
class TVTestCase(unittest.TestCase):

    def setUp(self):
        contracts = Contract.objects.all()
        self.contracts = []
        for contract in contracts:
            if contract.is_open():
                self.contracts.append(contract)

    	self.client = Client()
            	
    def test_tv(self):      
        for contract in self.contracts:
            self.client.post('/login', {'contract': contract.contract, 'password': contract.password})
            response = self.client.get('/tv')

            service = Service(contract=contract)

            # Check that the response is 200 OK.
            self.assertEqual(response.status_code, 200)

            title_exist   = True if 'Произошла ошибка!' in response.content else False
            message_exist = True if 'Данная услуга у вас не привязана к данному логину. Предварительно осуществите привязку.' in response.content else False

            if service.is_tv_activated():
                self.assertEqual(title_exist, False)
                self.assertEqual(message_exist, False)
            else:
                self.assertEqual(title_exist, True)
                self.assertEqual(message_exist, True)                

            #logout
            self.client.post('/logout')
Example #21
0
 def login_with_client(self, username='paulproteus',
                       password="paulproteus's unbreakable password"):
     client = Client()
     success = client.login(username=username,
                            password=password)
     self.assert_(success)
     return client
Example #22
0
class GroupCreateTests(TestCase):
    def setUp(self):
        self.c = Client()
        self.user = User.objects.create_user('dummy', 'dummy@henrique.email', 'dummy')
        self.user.save()

        self.user2 = User.objects.create_user('adummy', 'adummy@henrique.email', 'adummy')
        self.user2.save()

        self.user3 = User.objects.create_user('fdummy', 'fdummy@henrique.email', 'fdummy')
        self.user3.save()

        self.grupo_a = Group.objects.create(id=1, name="abcd", is_public=0, owner=self.user)
        self.grupo_a.save()

        acesso_a = Group_Access.objects.create(group=self.grupo_a, user=self.user3)
        acesso_a.save()


    def teste_usuario_anonimo_retorna_302(self):
        response = self.c.get(reverse("group_create"))
        self.assertEqual(response.status_code, 302)

    def teste_usuario_logado_retorna_200(self):
        self.c.login(username='dummy', password='dummy')
        response = self.c.get(reverse("group_create"))
        self.assertEqual(response.status_code, 200)
Example #23
0
 def test_downloadable_resource_for_organization_ms_full_members(self):
     """
     Verifies that a resource with an MS Commons license can be downloaded by
     a user of an organization which has the META-SHARE full member
     permission.
     """
     client = Client()
     client.login(username='organization_member_ms', password='secret')
     # make sure the license page is shown:
     response = client.get(
         reverse(views.download,
                 args=(self.ms_commons_resource.storage_object.identifier,)),
         follow = True)
     self.assertTemplateUsed(response, 'repository/licence_agreement.html',
                             "license agreement page expected")
     self.assertContains(response,
         'licences/META-SHARE_COMMONS_BYNCSA_v1.0.htm', msg_prefix="the " \
             "correct license appears to not be shown in an iframe")
     # make sure the download is started after accepting the license:
     response = client.post(
         reverse(views.download,
                 args=(self.ms_commons_resource.storage_object.identifier,)),
         { 'in_licence_agree_form': 'True', 'licence_agree': 'True',
           'licence': 'MSCommons-BY-NC-SA' },
         follow = True)
     self.assertTemplateNotUsed(response,
         'repository/licence_agreement.html',
         msg_prefix="a download should have been started")
     self.assertTemplateNotUsed(response,
         'repository/licence_selection.html',
         msg_prefix="a download should have been started")
     self.assertTemplateNotUsed(response,
         'repository/lr_not_downloadable.html',
         msg_prefix="a download should have been started")
Example #24
0
 def testNoPriority(self):
     c = Client()
     assert not Error.objects.count()
     ldata = data.copy()
     del ldata["priority"]
     c.post(reverse("error-post"), ldata)
     assert Error.objects.count() == 1
Example #25
0
class AuthTests(TestCase):
    def setUp(self):
        self.c = Client()
        self.password = User.objects.make_random_password()
        self.username = "unitTester"
        self.email = "t.r.monks@gmail.com"
        u = User.objects.create_user(self.username, self.email, self.password)
        u.is_staff = True
        u.save()

    def tearDown(self):
        User.objects.get(username=self.username).delete()
    
    def testAddUser(self):
        testcase_username = 'testcase'
        testcase_password = User.objects.make_random_password()
        
        self.c.login(username=self.username, password=self.password)
        self.c.post('http://uwcs.co.uk/admin/auth/user/add/', {
            'username':testcase_username, 
            'password1':testcase_password, 
            'password2':testcase_password
        })
        #User.objects.get(username=testcase_username).delete()


    def testLogin(self):
       self.assertContains(self.c.post('/login/', {"username": self.username, "password": self.password, "next":""}, follow=True), "Logged in as")
Example #26
0
 def testGroupDelete(self):
     c = Client()
     c.post(reverse("error-post"), data)
     assert Group.objects.count() == 1, "Got %s groups, not 1" % Group.objects.count()
     assert Error.objects.count() == 1
     Error.objects.all()[0].delete()
     assert Group.objects.count() == 0
Example #27
0
class TestLoginRequiredMixin1(TestCase):
    # テスト用のURLパターンを使用します。
    urls = 'myapp.test_urls'

    def setUp(self):
        super().setUp()
        self.client = Client()
        # テスト用URL(test/sample1/login_required_mixin1/)を取得します。
        self.path = reverse('test_sample1_login_required_mixin1')

    def test_logged_in(self):
        """ログイン済みのテストです。"""
        # ユーザを作成し、ログインします。
        username = 'foo'
        password = 'secret'
        User.objects.create_user(username=username, password=password)
        self.client.login(username=username, password=password)

        # テスト対象を実行します。
        res = self.client.get(self.path)

        # テスト結果を確認します。
        self.assertEqual(res.status_code, 200)

    def test_not_logged_in(self):
        """ログインしていない場合のテストです。"""
        # テスト対象を実行します。
        res = self.client.get(self.path)

        # テスト結果を確認します。
        self.assertEqual(res.status_code, 302)
Example #28
0
 def testUnicodeTraceback(self):
     c = Client()
     assert not Error.objects.count()
     ldata = data.copy()
     ldata["traceback"] = "ɷo̚حٍ"
     c.post(reverse("error-post"), ldata)
     assert Error.objects.count() == 1
Example #29
0
class TestNewsletterFunction(unittest.TestCase):
    def setUp(self):
        self.client = Client()

    def test_get_form(self):
        response = self.client.get('/en-US/base/')
        doc = pq(response.content)
        assert_false(doc('#footer-email-errors'))
        ok_(doc('form#footer-email-form'))

    @patch.object(basket, 'subscribe', Mock())
    def test_post_correct_form(self):
        data = {
            'newsletter-footer': 'Y',
            'newsletter': 'mozilla-and-you',
            'email': 'foo@bar.com',
            'fmt': 'H',
            'privacy': 'Y',
        }
        response = self.client.post('/en-US/base/', data)
        doc = pq(response.content)
        assert_false(doc('form#footer-email-form'))
        ok_(doc('div#footer-email-form.thank'))

    def test_post_wrong_form(self):
        response = self.client.post('/en-US/base/', {'newsletter-footer': 'Y'})
        doc = pq(response.content)
        ok_(doc('#footer-email-errors'))
        ok_(doc('#footer-email-form.has-errors'))
Example #30
0
    def test_footprint_viewset(self):
        csrf_client = Client(enforce_csrf_checks=True)

        grp = GroupFactory(permissions=ADD_CHANGE_PERMISSIONS)
        contributor = UserFactory(group=grp)

        csrf_client.login(username=contributor.username, password="test")

        # get a csrf token
        url = reverse('create-footprint-view')
        response = csrf_client.get(url)

        footprint = FootprintFactory()
        data = {'pk': footprint.id, 'title': 'abcdefg'}
        content = encode_multipart('BoUnDaRyStRiNg', data)
        content_type = 'multipart/form-data; boundary=BoUnDaRyStRiNg'

        url = '/api/footprint/%s/' % footprint.id

        csrf_header = response.cookies['csrftoken'].value
        response = csrf_client.patch(url, content,
                                     content_type=content_type,
                                     HTTP_X_CSRFTOKEN=csrf_header)
        self.assertEquals(response.status_code, 200)

        footprint.refresh_from_db()
        self.assertEquals(footprint.title, 'abcdefg')