예제 #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()
예제 #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()
예제 #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()
예제 #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()
예제 #5
0
파일: LabGroupForm.py 프로젝트: nihaoCC/DRP
class DuplicateUniqueValues(DRPTestCase): 
  '''Verifies that values which should be unique validate as false'''

  def setUp(self):
    self.labGroup = LabGroup(title="DuplicateValues", address='2, war drobe, Narnia', email='*****@*****.**', legacy_access_code='old_magic')
    self.labGroup.save()
  
  def test_duplicateTitle(self):
    form = LabGroupForm({'title':'DuplicateValues', 'address':'2, war drobe, Narnia', 'email':'*****@*****.**', 'accessCode':'old_magic'})
    self.assertFalse(form.is_valid())
    
  def tearDown(self):
    self.labGroup.delete()
예제 #6
0
class LegacyPassword(DRPTestCase):
  '''Tests for a legacy password check set but no new password has been entered'''

  def setUp(self):
    self.labGroup = LabGroup(title="LegacyPassTest1", address='1, war drobe, Narnia', email='*****@*****.**', legacy_access_code='old_magic')
    self.labGroup.save()
    formData = {'labGroup':self.labGroup.id, 'accessCode':'old_magic'}
    self.form = LabGroupJoiningForm(formData)

  def test_validation(self):
    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 tearDown(self):
    self.labGroup.delete()
예제 #7
0
class DuplicateUniqueValues(DRPTestCase):

    """Verifies that values which should be unique validate as false."""

    def setUp(self):
        """Set up lab group."""
        self.labGroup = LabGroup(title="DuplicateValues", address='2, war drobe, Narnia',
                                 email='*****@*****.**', legacy_access_code='old_magic')
        self.labGroup.save()

    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())

    def tearDown(self):
        """Delete labgroup created for this test."""
        self.labGroup.delete()
예제 #8
0
class DuplicateUniqueValues(DRPTestCase):
    """Verifies that values which should be unique validate as false."""
    def setUp(self):
        """Set up lab group."""
        self.labGroup = LabGroup(title="DuplicateValues",
                                 address='2, war drobe, Narnia',
                                 email='*****@*****.**',
                                 legacy_access_code='old_magic')
        self.labGroup.save()

    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())

    def tearDown(self):
        """Delete labgroup created for this test."""
        self.labGroup.delete()
예제 #9
0
class LegacyPassword(DRPTestCase):
    """Test for a legacy password check set but no new password has been entered."""
    def setUp(self):
        """Test for a legacy password check set but no new password has been entered."""
        self.labGroup = LabGroup(title="LegacyPassTest1",
                                 address='1, war drobe, Narnia',
                                 email='*****@*****.**',
                                 legacy_access_code='old_magic')
        self.labGroup.save()
        formData = {'labGroup': self.labGroup.id, 'accessCode': 'old_magic'}
        self.form = LabGroupJoiningForm(formData)

    def test_validation(self):
        """Validate test."""
        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 tearDown(self):
        """Remove lab group created for this test."""
        self.labGroup.delete()