Example #1
0
    def test_reassign_role_owner_to_editor(self):
        self._publish_transportation_form()
        alice = self._create_user('alice', 'alice')

        self.assertFalse(OwnerRole.has_role(alice, self.xform))

        OwnerRole.add(alice, self.xform)

        self.assertTrue(OwnerRole.has_role(alice, self.xform))

        EditorRole.add(alice, self.xform)

        self.assertFalse(OwnerRole.has_role(alice, self.xform))
        self.assertTrue(EditorRole.has_role(alice, self.xform))
Example #2
0
 def test_publish_xlsform(self):
     view = XFormViewSet.as_view({
         'post': 'create'
     })
     data = {
         'owner': 'http://testserver/api/v1/users/bob',
         'public': False,
         'public_data': False,
         'description': u'transportation_2011_07_25',
         'downloadable': True,
         'allows_sms': False,
         'encrypted': False,
         'sms_id_string': u'transportation_2011_07_25',
         'id_string': u'transportation_2011_07_25',
         'title': u'transportation_2011_07_25',
         'bamboo_dataset': u''
     }
     path = os.path.join(
         settings.PROJECT_ROOT, "apps", "main", "tests", "fixtures",
         "transportation", "transportation.xls")
     with open(path) as xls_file:
         post_data = {'xls_file': xls_file}
         request = self.factory.post('/', data=post_data, **self.extra)
         response = view(request)
         self.assertEqual(response.status_code, 201)
         xform = self.user.xforms.all()[0]
         data.update({
             'url':
             'http://testserver/api/v1/forms/%s' % xform.pk
         })
         self.assertDictContainsSubset(data, response.data)
         self.assertTrue(OwnerRole.has_role(self.user, xform))
Example #3
0
    def test_reassign_role_owner_to_editor(self):
        self._publish_transportation_form()
        alice = self._create_user('alice', 'alice')

        self.assertFalse(OwnerRole.user_has_role(alice, self.xform))

        OwnerRole.add(alice, self.xform)

        self.assertTrue(OwnerRole.user_has_role(alice, self.xform))
        self.assertTrue(
            OwnerRole.has_role(perms_for(alice, self.xform), self.xform))

        EditorRole.add(alice, self.xform)

        self.assertFalse(OwnerRole.user_has_role(alice, self.xform))
        self.assertTrue(EditorRole.user_has_role(alice, self.xform))
        self.assertFalse(
            OwnerRole.has_role(perms_for(alice, self.xform), self.xform))
        self.assertTrue(
            EditorRole.has_role(perms_for(alice, self.xform), self.xform))
Example #4
0
    def test_reassign_role_owner_to_editor(self):
        """
        Test role reassignment owner to editor.
        """
        self._publish_transportation_form()
        alice = self._create_user('alice', 'alice')

        self.assertFalse(OwnerRole.user_has_role(alice, self.xform))

        OwnerRole.add(alice, self.xform)

        self.assertTrue(OwnerRole.user_has_role(alice, self.xform))
        self.assertTrue(
            OwnerRole.has_role(perms_for(alice, self.xform), self.xform))

        EditorRole.add(alice, self.xform)

        self.assertFalse(OwnerRole.user_has_role(alice, self.xform))
        self.assertTrue(EditorRole.user_has_role(alice, self.xform))
        self.assertFalse(
            OwnerRole.has_role(perms_for(alice, self.xform), self.xform))
        self.assertTrue(
            EditorRole.has_role(perms_for(alice, self.xform), self.xform))