Exemple #1
0
    def test_username_field(self):
        ''' again, just setting defaults on username field '''
        instance = fields.UsernameField()
        self.assertEqual(instance.activitypub_field, 'preferredUsername')
        self.assertEqual(instance.max_length, 150)
        self.assertEqual(instance.unique, True)
        with self.assertRaises(ValidationError):
            instance.run_validators('one two')
            instance.run_validators('a*&')
            instance.run_validators('trailingwhite ')
        self.assertIsNone(instance.run_validators('aksdhf'))

        self.assertEqual(instance.field_to_activity('*****@*****.**'),
                         'test')
Exemple #2
0
    def test_username_field(self):
        """again, just setting defaults on username field"""
        instance = fields.UsernameField()
        self.assertEqual(instance.activitypub_field, "preferredUsername")
        self.assertEqual(instance.max_length, 150)
        self.assertEqual(instance.unique, True)
        with self.assertRaises(ValidationError):
            instance.run_validators("mouse")
            instance.run_validators("mouseexample.com")
            instance.run_validators("[email protected]")
            instance.run_validators("@example.com")
            instance.run_validators("mouse@examplecom")
            instance.run_validators("one [email protected]")
            instance.run_validators("a*&@exampke.com")
            instance.run_validators("[email protected] ")
        self.assertIsNone(instance.run_validators("*****@*****.**"))
        self.assertIsNone(instance.run_validators("*****@*****.**"))
        self.assertIsNone(instance.run_validators("*****@*****.**"))

        self.assertEqual(instance.field_to_activity("*****@*****.**"),
                         "test")