diff options
Diffstat (limited to 'ishtar_common/tests.py')
| -rw-r--r-- | ishtar_common/tests.py | 64 | 
1 files changed, 64 insertions, 0 deletions
| diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py index 10584e4f2..cdf6ce330 100644 --- a/ishtar_common/tests.py +++ b/ishtar_common/tests.py @@ -334,6 +334,70 @@ class MergeTest(TestCase):                           init_mc) +class ShortMenuTest(TestCase): +    def setUp(self): +        from archaeological_operations.models import OperationType +        self.username = 'username666' +        self.password = 'dcbqj7xnjkxnjsknx!@%' +        self.user = User.objects.create_superuser( +            self.username, "nomail@nomail.com", self.password) +        self.other_user = User.objects.create_superuser( +            'John', "nomail@nomail.com", self.password) +        self.ope_type = OperationType.objects.create() + +    def testNotConnected(self): +        c = Client() +        response = c.get(reverse('shortcut-menu')) +        # no content if not logged +        self.assertFalse("shortcut-menu" in response.content) +        c = Client() +        c.login(username=self.username, password=self.password) +        # no content because the user owns no object +        response = c.get(reverse('shortcut-menu')) +        self.assertFalse("shortcut-menu" in response.content) +        from archaeological_operations.models import Operation +        Operation.objects.create( +            operation_type=self.ope_type, +            history_modifier=self.user) +        # content is here +        response = c.get(reverse('shortcut-menu')) +        self.assertTrue("shortcut-menu" in response.content) + +    def testOperation(self): +        from archaeological_operations.models import Operation +        c = Client() +        c.login(username=self.username, password=self.password) +        ope = Operation.objects.create( +            operation_type=self.ope_type, +            history_modifier=self.other_user, +            year=2042, operation_code=54 +        ) +        # not available at first +        response = c.get(reverse('shortcut-menu')) +        self.assertFalse(str(ope.cached_label) in response.content) + +        # available because is the creator +        ope.history_creator = self.user +        ope.save() +        response = c.get(reverse('shortcut-menu')) +        self.assertTrue(str(ope.cached_label) in response.content) + +        # available because is in charge +        ope.history_creator = self.other_user +        ope.in_charge = self.user.ishtaruser.person +        ope.save() +        response = c.get(reverse('shortcut-menu')) +        self.assertTrue(str(ope.cached_label) in response.content) + +        # available because is the scientist +        ope.history_creator = self.other_user +        ope.in_charge = None +        ope.scientist = self.user.ishtaruser.person +        ope.save() +        response = c.get(reverse('shortcut-menu')) +        self.assertTrue(str(ope.cached_label) in response.content) + +  class ImportTest(TestCase):      def testDeleteRelated(self):          town = models.Town.objects.create(name='my-test') | 
