Beispiel #1
0
 def test_access_equality_op4(self):
     """
     match by group
     """
     g = Group(name="G")
     g.save()
     some_folder = Folder.objects.create(
         title="some_folder",
         user=self.uploader_user
     )
     a1 = Access(
         access_type=Access.ALLOW,
         access_inherited=False,
         node=some_folder,
         group=g
     )
     a2 = Access(
         access_type=Access.ALLOW,
         access_inherited=False,
         node=some_folder,
         group=g
     )
     a1.save()
     a2.save()
     # group attribute differ
     self.assertEqual(a1, a2)
Beispiel #2
0
 def test_access_equality_op3(self):
     """
     Group attribute differs => access models won't be equal.
     """
     g1 = Group(name="G1")
     g1.save()
     g2 = Group(name="G2")
     g2.save()
     some_folder = Folder.objects.create(
         title="some_folder",
         user=self.uploader_user
     )
     a1 = Access(
         access_type=Access.ALLOW,
         access_inherited=False,
         node=some_folder,
         group=g1
     )
     a2 = Access(
         access_type=Access.ALLOW,
         access_inherited=False,
         node=some_folder,
         group=g2
     )
     a1.save()
     a2.save()
     # group attribute differ
     self.assertNotEqual(a1, a2)
Beispiel #3
0
    def test_access_equality_op1(self):
        """
        test basic access model equality operation
        (same user)
        """

        some_folder = Folder.objects.create(
            title="some_folder",
            user=self.uploader_user
        )
        a1 = Access(
            access_type=Access.ALLOW,
            access_inherited=False,
            node=some_folder,
            user=self.uploader_user
        )
        a2 = Access(
            access_type=Access.ALLOW,
            access_inherited=False,
            node=some_folder,
            user=self.uploader_user
        )
        a1.save()
        a2.save()
        self.assertEqual(a1, a2)

        a1.permissions.add(self.R)
        a2.permissions.add(self.W)

        self.assertEqual(a1, a2)
Beispiel #4
0
    def test_access_equality_op2(self):
        """
        User attribute differs => access models won't be equal.
        """

        some_folder = Folder.objects.create(
            title="some_folder",
            user=self.uploader_user
        )
        a1 = Access(
            access_type=Access.ALLOW,
            access_inherited=False,
            node=some_folder,
            user=self.margaret_user
        )
        a2 = Access(
            access_type=Access.ALLOW,
            access_inherited=False,
            node=some_folder,
            user=self.uploader_user
        )
        a1.save()
        a2.save()
        # user attribute differs (margaret vs uploader)
        self.assertNotEqual(a1, a2)

        a1.permissions.add(self.R)
        a2.permissions.add(self.W)

        # permissions does not metter, users differ
        self.assertNotEqual(a1, a2)
 def test_access_equality_op_inheritance(self):
     """
     Inheritance flag does not matter.
     """
     some_folder = Folder.objects.create(title="some_folder",
                                         user=self.uploader_user)
     a1 = Access(access_type=Access.ALLOW,
                 access_inherited=False,
                 node=some_folder,
                 user=self.margaret_user)
     a2 = Access(
         access_type=Access.ALLOW,
         access_inherited=True,  # different, but it does not matter
         node=some_folder,
         user=self.margaret_user)
     a1.save()
     a2.save()
     # inheritance flag does not matter on eq op.
     self.assertEqual(a1, a2)