Repository: lk-geimfari/mimesis

Issue:
Hardcoded parameters used for random.randint() in Person.username()
Looking at the ```username()``` function in ```providers/person.py``` I found this line:

```
date = self.random.randint(1800, 2070)
```

@lk-geimfari Do you know why these parameters are hardcoded? For #561, I need to calculate all the possible unique combinations the ```username()``` function can return and I want to avoid hardcoding any numbers in the formula I use. If this range of random integers gets changed in the future, it will break my implementation. 


Discussion:
It was hardcoded because it's like a birthday of the user, but you can change it if you want.

Resolving patch:
diff --git a/mimesis/providers/person.py b/mimesis/providers/person.py
--- a/mimesis/providers/person.py
+++ b/mimesis/providers/person.py
@@ -180,7 +180,9 @@ def username(self, template: Optional[str] = None) -> str:
         _name = self.random.choice(USERNAMES).capitalize()
 
         name = self.random.choice(USERNAMES)
-        date = self.random.randint(1800, 2070)
+        MIN_DATE = 1800
+        MAX_DATE = 2070
+        date = self.random.randint(MIN_DATE, MAX_DATE)
 
         templates = ('U-d', 'U.d', 'UU-d', 'UU.d', 'UU_d', 'U_d',
                      'Ud', 'l-d', 'l.d', 'l_d', 'ld', 'default')


Test patch:
diff --git a/tests/test_providers/patterns.py b/tests/test_providers/patterns.py
--- a/tests/test_providers/patterns.py
+++ b/tests/test_providers/patterns.py
@@ -20,8 +20,6 @@
 
 EMAIL_REGEX = r'(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)'
 
-USERNAME_REGEX = r'^[a-zA-Z0-9_.-]+$'
-
 CREDIT_CARD_REGEX = r'[\d]+((-|\s)?[\d]+)+'
 
 PROVIDER_STR_REGEX = r'^(Business|Clothing|Code|Development' \
diff --git a/tests/test_providers/test_person.py b/tests/test_providers/test_person.py
--- a/tests/test_providers/test_person.py
+++ b/tests/test_providers/test_person.py
@@ -1,5 +1,6 @@
 # -*- coding: utf-8 -*-
 
+import random
 import re
 
 import pytest
@@ -74,8 +75,30 @@ def test_password(self, _person):
         ],
     )
     def test_username(self, _person, template):
+
+        templates = ('U-d', 'U.d', 'UU-d', 'UU.d', 'UU_d', 'U_d',
+                     'Ud', 'l-d', 'l.d', 'l_d', 'ld', 'default')
+
+        template_patterns = {
+            'U-d': r'^[A-Z][a-z]+-[0-9]+$',
+            'U.d': r'^[A-Z][a-z]+\.[0-9]+$',
+            'U_d': r'^[A-Z][a-z]+_[0-9]+$',
+            'UU-d': r'^[A-Z][a-z]+[A-Z][a-z]+-[0-9]+$',
+            'UU.d': r'^[A-Z][a-z]+[A-Z][a-z]+\.[0-9]+$',
+            'UU_d': r'^[A-Z][a-z]+[A-Z][a-z]+_[0-9]+$',
+            'Ud': r'^[A-Z][a-z]+[0-9]+$',
+            'l-d': r'^[a-z]+-[0-9]+$',
+            'l.d': r'^[a-z]+\.[0-9]+$',
+            'l_d': r'^[a-z]+_[0-9]+$',
+            'ld': r'^[a-z]+[0-9]+$',
+            'default': r'^[a-z]+\.[0-9]+',
+        }
+
+        if template is None:
+            template = random.choice(templates)
+
         result = _person.username(template=template)
-        assert re.match(patterns.USERNAME_REGEX, result)
+        assert re.match(template_patterns[template], result)
 
     def test_username_unsupported_template(self, _person):
         with pytest.raises(KeyError):