Skip to content

Commit

Permalink
add more tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
n1nj4t4nuk1 committed Apr 11, 2021
1 parent 5f71d4e commit 94c63bb
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 2 deletions.
45 changes: 45 additions & 0 deletions tests/unit/deep_get_by_type_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import unittest

from deepgetter.deep_get import deep_get


class TestGetByType(unittest.TestCase):
def test_with_basic_number(self):
"""
Test basic number
"""
data: int = 39
result = deep_get(data, '')
self.assertEqual(result, 39)

def test_with_number_in_dict(self):
"""
Test basic number inside structure
"""
data: dict = {
'value': 39,
}
result = deep_get(data, 'value')
self.assertEqual(result, 39)

def test_with_basic_str(self):
"""
Test basic string
"""
data: str = 'test str'
result = deep_get(data, '')
self.assertEqual(result, 'test str')

def test_with_str_in_dict(self):
"""
Test basic string inside structure
"""
data: dict = {
'value': 'test str',
}
result = deep_get(data, 'value')
self.assertEqual(result, 'test str')


if __name__ == '__main__':
unittest.main()
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from deepgetter.deep_get import deep_get


class TestSum(unittest.TestCase):
class TestFindInDeep(unittest.TestCase):
def test_dict_with_0_lvl(self):
"""
Test basic dictionary with no profundity level.
Expand All @@ -26,7 +26,7 @@ def test_dict_with_1_lvl(self):

def test_dict_with_2_lvl(self):
"""
Test basic dictionary with two profundity levels.
Test basic dictionary with 2 profundity levels.
"""
data: dict = {
'value': {
Expand All @@ -36,6 +36,20 @@ def test_dict_with_2_lvl(self):
result = deep_get(data, 'value.subdata')
self.assertEqual(result, 39)

def test_dict_with_3_lvl(self):
"""
Test basic dictionary with 3 profundity levels.
"""
data: dict = {
'value': {
'sub-data': {
'sub-sub-data': 39,
},
},
}
result = deep_get(data, 'value.sub-data.sub-sub-data')
self.assertEqual(result, 39)


if __name__ == '__main__':
unittest.main()

0 comments on commit 94c63bb

Please sign in to comment.