Ejemplo n.º 1
0
 def test_not_authenticated(self):
     self.client.logout()
     response = self.client.get(self.url)
     context = {'dummy': 'dummy'}
     common._set_managed_programs(response.wsgi_request, context)
     self.assertTrue(len(context) == 1)
     self.assertIsNone(context.get('is_faculty_manager', None))
     self.assertTrue(context.get('dummy', None) == 'dummy')
Ejemplo n.º 2
0
 def test_student(self):
     student = StudentFactory(person=self.person)
     self.client.force_login(student.person.user)
     response = self.client.get(self.url)
     context = {'dummy': 'dummy'}
     common._set_managed_programs(response.wsgi_request, context)
     self.assertFalse(context.get('is_faculty_manager', None))
     self.assertTrue(context.get('dummy', None) == 'dummy')
Ejemplo n.º 3
0
 def test_not_defined_and_not_exists(self):
     patcher = patch('base.views.api.get_managed_programs_as_dict')
     mock_api_call = patcher.start()
     mock_api_call.return_value = {}
     self.client.force_login(self.person.user)
     response = self.client.get(self.url)
     context = {'dummy': 'dummy'}
     common._set_managed_programs(response.wsgi_request, context)
     self.assertIsNone(self.client.session.get('managed_programs'))
     self.assertFalse(context.get('is_faculty_manager'))
     self.assertFalse(self.client.session.get('is_faculty_manager'))
     patcher.stop()
Ejemplo n.º 4
0
 def test_not_defined_and_exists(self):
     self.client.force_login(self.person.user)
     response = self.client.get(self.url)
     context = {'dummy': 'dummy'}
     common._set_managed_programs(response.wsgi_request, context)
     expected_managed_programs = {
         '2017': ['PHYS1BA', 'BIOL1BA'],
         '2018': ['PHYS1BA', 'BIOL1BA']
     }
     managed_programs = json.loads(
         self.client.session.get('managed_programs'))
     self.assertDictEqual(expected_managed_programs, managed_programs)
     self.assertTrue(context.get('is_faculty_manager'))
     self.assertTrue(self.client.session.get('is_faculty_manager'))
Ejemplo n.º 5
0
 def test_already_defined(self):
     # Test is True
     self.client.force_login(self.person.user)
     session = self.client.session
     session['is_faculty_manager'] = True
     session.save()
     response = self.client.get(self.url)
     context = {'dummy': 'dummy'}
     common._set_managed_programs(response.wsgi_request, context)
     self.assertTrue(context.get('is_faculty_manager'))
     self.assertTrue(context.get('dummy', None) == 'dummy')
     # Test is False
     session['is_faculty_manager'] = False
     session.save()
     response = self.client.get(self.url)
     context = {'dummy': 'dummy'}
     common._set_managed_programs(response.wsgi_request, context)
     self.assertFalse(context.get('is_faculty_manager'))
     self.assertTrue(context.get('dummy', None) == 'dummy')