-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Plate.test #2238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Fernandavazgit1
wants to merge
4
commits into
joke2k:master
Choose a base branch
from
Fernandavazgit1:plate.test
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Plate.test #2238
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from faker.providers import BaseProvider | ||
import random | ||
import string | ||
|
||
class Provider(BaseProvider): | ||
def passport_number(self): | ||
|
||
letters = ''.join(random.choices(string.ascii_uppercase, k=2)) | ||
numbers = ''.join(random.choices(string.digits, k=7)) | ||
return letters + numbers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import unittest | ||
from faker import Faker | ||
import re | ||
|
||
class TestPassportProvider(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.fake = Faker() | ||
self.provider = self.fake.passport_number | ||
|
||
def test_valid_passport_number(self): | ||
passport = self.provider() | ||
self.assertRegex(passport, r'^[A-Z]{2}[0-9]{7}$') | ||
|
||
|
||
def test_letters_are_uppercase(self): | ||
passport = self.provider() | ||
letters = passport[:2] | ||
self.assertTrue(all(l.isalpha() and l.isupper() for l in letters)) | ||
|
||
|
||
def test_letters_length(self): | ||
passport = self.provider() | ||
self.assertEqual(len(passport[:2]), 2) | ||
|
||
def test_digits_are_numbers(self): | ||
passport = self.provider() | ||
digits = passport[2:] | ||
self.assertTrue(digits.isdigit()) | ||
|
||
|
||
def test_digits_length(self): | ||
passport = self.provider() | ||
self.assertEqual(len(passport[2:]), 7) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import unittest | ||
from faker import Faker | ||
import re | ||
|
||
|
||
class TestPassportProvider(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.fake = Faker() | ||
self.provider = self.fake.passport_number | ||
|
||
def test_valid_passport_number(self): | ||
passport = self.provider() | ||
self.assertRegex(passport, r'^[A-Z]{2}[0-9]{7}$') | ||
|
||
def test_invalid_letters(self): | ||
passport = 'A11234567' | ||
self.assertFalse(re.match(r'^[A-Z]{2}[0-9]{7}$', passport)) | ||
|
||
def test_invalid_letter_length(self): | ||
passport = 'A1234567' | ||
self.assertFalse(re.match(r'^[A-Z]{2}[0-9]{7}$', passport)) | ||
|
||
def test_invalid_digit_characters(self): | ||
passport = 'AB1234A67' | ||
self.assertFalse(re.match(r'^[A-Z]{2}[0-9]{7}$', passport)) | ||
|
||
def test_invalid_digit_length(self): | ||
passport = 'AB123456' | ||
self.assertFalse(re.match(r'^[A-Z]{2}[0-9]{7}$', passport)) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
def test_latam_plate_brasil(): | ||
from faker import Faker | ||
fake = Faker() | ||
plate = fake.latam_plate(pais='brasil') | ||
assert isinstance(plate, str) | ||
assert '-' in plate | ||
assert len(plate) == 8 | ||
|
||
def test_latam_plate_argentina(): | ||
from faker import Faker | ||
fake = Faker() | ||
plate = fake.latam_plate(pais='argentina') | ||
assert ' ' in plate | ||
|
||
def test_latam_plate_chile(): | ||
from faker import Faker | ||
fake = Faker() | ||
plate = fake.latam_plate(pais='chile') | ||
assert '-' in plate |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you push the right code? Looks like this is generating a passport number, not a Latin American license plate