forked from sundowndev/phoneinfoga
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3f462fe
commit 6b5037a
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,54 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding:utf-8 -*- | ||
# | ||
# @name : PhoneInfoga - Phone numbers OSINT tool | ||
# @url : https://github.com/sundowndev | ||
# @author : Raphael Cerveaux (sundowndev) | ||
|
||
import unittest | ||
from unittest.mock import patch | ||
|
||
from lib.format import formatNumber, replaceVariables | ||
|
||
|
||
class TestFormat(unittest.TestCase): | ||
""" | ||
We want to be sure re.sub is imported and called | ||
""" | ||
|
||
@patch("re.sub") | ||
def test_formatNumberCallingSub(self, subMock): | ||
subMock.return_value = "" | ||
|
||
result = formatNumber("000") | ||
|
||
subMock.assert_called_with("(?:\+)?(?:[^[0-9]*)", "", "000") | ||
self.assertEqual(result, "") | ||
|
||
""" | ||
We verify the function formats the number the right way | ||
""" | ||
|
||
def test_formatNumber(self): | ||
self.assertEqual(formatNumber("+33 81495357"), "3381495357") | ||
self.assertEqual(formatNumber("0 81 49 53 57"), "081495357") | ||
self.assertEqual(formatNumber("+1 555-444-888"), "1555444888") | ||
|
||
def test_replaceVariables(self): | ||
number = { | ||
"input": "+33651580074", | ||
"default": "33651580074", | ||
"local": "651580074", | ||
"international": "+33 6 51 58 00 74", | ||
"country": "France", | ||
"countryCode": "+33", | ||
"countryIsoCode": "FR", | ||
"location": "France", | ||
"carrier": "", | ||
} | ||
|
||
self.assertEqual(replaceVariables("test $n", number), "test 33651580074") | ||
self.assertEqual( | ||
replaceVariables("test $i", number), "test +33 6 51 58 00 74" | ||
) | ||
self.assertEqual(replaceVariables("test $l", number), "test 6 51 58 00 74") |