Beispiel #1
0
class LegacyPassword(DRPTestCase):
    """Tests for a case where a legacy password is set but no new password has been entered."""
    def setUp(self):
        """instantiate the labgroup."""
        self.labGroup = LabGroup(title="LegacyPassTest1",
                                 address='1, war drobe, Narnia',
                                 email='*****@*****.**',
                                 legacy_access_code='old_magic')
        formData = {
            'title': 'LegacyPasstest1',
            'address': '1, war drobe',
            'email': '*****@*****.**',
            'users': []
        }
        self.form = LabGroupForm(formData, instance=self.labGroup)
        self.labGroup.save()

    def test_validation(self):
        """Assert that the test worked."""
        valid = self.form.is_valid()
        errString = ''
        for e, m in self.form.errors.items():
            errString += '{0}: {1}\n'.format(e, m)
        self.assertTrue(valid, errString)

    def test_databaseChange(self):
        """Test that saving the form (changing the databases) makes the appropriate changes."""
        self.form.save()
        self.labGroup = LabGroup.objects.get(pk=self.labGroup.id)
        self.assertEqual(self.labGroup.legacy_access_code, '')
        self.assertTrue(check_password('old_magic', self.labGroup.access_code))

    def tearDown(self):
        """Get rid of the things created for this test."""
        self.labGroup.delete()
Beispiel #2
0
class LegacyPassword2(DRPTestCase):

    """Test for a case where a legacy password is set and a new password has been entered."""

    def setUp(self):
        """instantiate the labgroup."""
        self.labGroup = LabGroup(title="LegacyPassTest2", address='2, war drobe, Narnia',
                                 email='*****@*****.**', legacy_access_code='old_magic')
        self.labGroup.save()
        formData = {'title': 'LegacyPasstest2', 'address': '2, war drobe',
                    'email': '*****@*****.**', 'accessCode': 'new_magic'}
        self.form = LabGroupForm(formData, instance=self.labGroup)

    def test_validation(self):
        """Evaluate whether the test should pass or fail."""
        self.assertTrue(self.form.is_valid())

    def test_databaseChange(self):
        """Evaluate that a new password is updated correctly from a legacy password."""
        self.form.save()
        self.labGroup = LabGroup.objects.get(pk=self.labGroup.id)
        self.assertEqual(self.labGroup.legacy_access_code, '')
        self.assertTrue(check_password('new_magic', self.labGroup.access_code))

    def tearDown(self):
        """Delete lab group created for this test."""
        self.labGroup.delete()
Beispiel #3
0
class LegacyPassword2(DRPTestCase):
    """Test for a case where a legacy password is set and a new password has been entered."""
    def setUp(self):
        """instantiate the labgroup."""
        self.labGroup = LabGroup(title="LegacyPassTest2",
                                 address='2, war drobe, Narnia',
                                 email='*****@*****.**',
                                 legacy_access_code='old_magic')
        self.labGroup.save()
        formData = {
            'title': 'LegacyPasstest2',
            'address': '2, war drobe',
            'email': '*****@*****.**',
            'accessCode': 'new_magic'
        }
        self.form = LabGroupForm(formData, instance=self.labGroup)

    def test_validation(self):
        """Evaluate whether the test should pass or fail."""
        self.assertTrue(self.form.is_valid())

    def test_databaseChange(self):
        """Evaluate that a new password is updated correctly from a legacy password."""
        self.form.save()
        self.labGroup = LabGroup.objects.get(pk=self.labGroup.id)
        self.assertEqual(self.labGroup.legacy_access_code, '')
        self.assertTrue(check_password('new_magic', self.labGroup.access_code))

    def tearDown(self):
        """Delete lab group created for this test."""
        self.labGroup.delete()
Beispiel #4
0
class LegacyPassword(DRPTestCase):

    """Tests for a case where a legacy password is set but no new password has been entered."""

    def setUp(self):
        """instantiate the labgroup."""
        self.labGroup = LabGroup(title="LegacyPassTest1", address='1, war drobe, Narnia',
                                 email='*****@*****.**', legacy_access_code='old_magic')
        formData = {'title': 'LegacyPasstest1', 'address': '1, war drobe',
                    'email': '*****@*****.**', 'users': []}
        self.form = LabGroupForm(formData, instance=self.labGroup)
        self.labGroup.save()

    def test_validation(self):
        """Assert that the test worked."""
        valid = self.form.is_valid()
        errString = ''
        for e, m in self.form.errors.items():
            errString += '{0}: {1}\n'.format(e, m)
        self.assertTrue(valid, errString)

    def test_databaseChange(self):
        """Test that saving the form (changing the databases) makes the appropriate changes."""
        self.form.save()
        self.labGroup = LabGroup.objects.get(pk=self.labGroup.id)
        self.assertEqual(self.labGroup.legacy_access_code, '')
        self.assertTrue(check_password('old_magic', self.labGroup.access_code))

    def tearDown(self):
        """Get rid of the things created for this test."""
        self.labGroup.delete()
Beispiel #5
0
 def test_duplicateTitle(self):
     """Ensure that a duplicate lab group title is accepted."""
     form = LabGroupForm({
         'title': 'DuplicateValues',
         'address': '2, war drobe, Narnia',
         'email': '*****@*****.**',
         'accessCode': 'old_magic'
     })
     self.assertFalse(form.is_valid())
Beispiel #6
0
 def setUp(self):
     """instantiate the labgroup."""
     self.labGroup = LabGroup(title="LegacyPassTest1",
                              address='1, war drobe, Narnia',
                              email='*****@*****.**',
                              legacy_access_code='old_magic')
     formData = {
         'title': 'LegacyPasstest1',
         'address': '1, war drobe',
         'email': '*****@*****.**',
         'users': []
     }
     self.form = LabGroupForm(formData, instance=self.labGroup)
     self.labGroup.save()
Beispiel #7
0
 def setUp(self):
     """instantiate the labgroup."""
     self.labGroup = LabGroup(title="LegacyPassTest2",
                              address='2, war drobe, Narnia',
                              email='*****@*****.**',
                              legacy_access_code='old_magic')
     self.labGroup.save()
     formData = {
         'title': 'LegacyPasstest2',
         'address': '2, war drobe',
         'email': '*****@*****.**',
         'accessCode': 'new_magic'
     }
     self.form = LabGroupForm(formData, instance=self.labGroup)
Beispiel #8
0
 def setUp(self):
     """instantiate the labgroup."""
     self.labGroup = LabGroup(title="LegacyPassTest1", address='1, war drobe, Narnia',
                              email='*****@*****.**', legacy_access_code='old_magic')
     formData = {'title': 'LegacyPasstest1', 'address': '1, war drobe',
                 'email': '*****@*****.**', 'users': []}
     self.form = LabGroupForm(formData, instance=self.labGroup)
     self.labGroup.save()
Beispiel #9
0
 def setUp(self):
     """instantiate the labgroup."""
     self.labGroup = LabGroup(title="LegacyPassTest2", address='2, war drobe, Narnia',
                              email='*****@*****.**', legacy_access_code='old_magic')
     self.labGroup.save()
     formData = {'title': 'LegacyPasstest2', 'address': '2, war drobe',
                 'email': '*****@*****.**', 'accessCode': 'new_magic'}
     self.form = LabGroupForm(formData, instance=self.labGroup)
Beispiel #10
0
 def test_missingAddress(self):
   formData = copy(self.formData)
   del formData['address']
   form = LabGroupForm(formData)
   self.assertFalse(form.is_valid())
Beispiel #11
0
 def test_missingEmail(self):
   formData = copy(self.formData)
   del formData['email']
   form = LabGroupForm(formData)
   self.assertFalse(form.is_valid())
Beispiel #12
0
 def test_missingPass(self):
   formData = copy(self.formData)
   del formData['accessCode']
   form = LabGroupForm(formData)
   self.assertFalse(form.is_valid())
Beispiel #13
0
 def completeDataAndUsers(self):
     """Test to determine whether a LabGroupForm is correctly marked as valid when it has all required information and a list of user ids."""
     formData = copy(self.formData)
     formData['users'] = [u.id for u in self.users]
     form = LabGroupForm()
     self.assertTrue(form.is_valid())
Beispiel #14
0
 def completeData(self):
     """Test to determine whether a form is correctly marked as valid when it has all required information."""
     form = LabGroupForm(self.formData)
     self.assertTrue(form.is_valid())
Beispiel #15
0
 def test_missingPass(self):
     """Test to determine whether a form is correctly marked as invalid when a password is not present."""
     formData = copy(self.formData)
     del formData['accessCode']
     form = LabGroupForm(formData)
     self.assertFalse(form.is_valid())
Beispiel #16
0
 def completeData(self):
     """Test to determine whether a form is correctly marked as valid when it has all required information."""
     form = LabGroupForm(self.formData)
     self.assertTrue(form.is_valid())
Beispiel #17
0
 def test_missingTitle(self):
     """Test to determine whether a form is correctly marked as invalid when a title is not present."""
     formData = copy(self.formData)
     del formData['title']
     form = LabGroupForm(formData)
     self.assertFalse(form.is_valid())
Beispiel #18
0
 def completeDataAndUsers(self):
   formData = copy(self.formData)
   formData['users'] = [u.id for u in self.users]
   form = LabGroupForm()
   self.assertTrue(form.is_valid())
Beispiel #19
0
 def test_missingTitle(self):
     """Test to determine whether a form is correctly marked as invalid when a title is not present."""
     formData = copy(self.formData)
     del formData['title']
     form = LabGroupForm(formData)
     self.assertFalse(form.is_valid())
Beispiel #20
0
 def test_missingEmail(self):
     """Test to determine whether a form is correctly marked as invalid when an email address is not present."""
     formData = copy(self.formData)
     del formData['email']
     form = LabGroupForm(formData)
     self.assertFalse(form.is_valid())
Beispiel #21
0
 def test_duplicateTitle(self):
     """Ensure that a duplicate lab group title is accepted."""
     form = LabGroupForm({'title': 'DuplicateValues', 'address': '2, war drobe, Narnia',
                          'email': '*****@*****.**', 'accessCode': 'old_magic'})
     self.assertFalse(form.is_valid())
Beispiel #22
0
 def completeDataAndUsers(self):
     """Test to determine whether a LabGroupForm is correctly marked as valid when it has all required information and a list of user ids."""
     formData = copy(self.formData)
     formData['users'] = [u.id for u in self.users]
     form = LabGroupForm()
     self.assertTrue(form.is_valid())
Beispiel #23
0
 def test_missingTitle(self):
   formData = copy(self.formData)
   del formData['title']
   form = LabGroupForm(formData)
   self.assertFalse(form.is_valid())
Beispiel #24
0
 def test_missingEmail(self):
     """Test to determine whether a form is correctly marked as invalid when an email address is not present."""
     formData = copy(self.formData)
     del formData['email']
     form = LabGroupForm(formData)
     self.assertFalse(form.is_valid())
Beispiel #25
0
 def completeData(self):
   form = LabGroupForm(self.formData)
   self.assertTrue(form.is_valid())
Beispiel #26
0
 def test_missingPass(self):
     """Test to determine whether a form is correctly marked as invalid when a password is not present."""
     formData = copy(self.formData)
     del formData['accessCode']
     form = LabGroupForm(formData)
     self.assertFalse(form.is_valid())