Exemplo n.º 1
0
 def test_get_dict_properties_with_strict_and_invalid_property(self):
     d = {
         'comment': {
             'message': 'some text',
         }
     }
     pysharedutils.get_dict_properties(
         d,
         True,
         'comment.user.username'
     )
Exemplo n.º 2
0
 def test_get_dict_properties_with_nested_dict(self):
     d = {
         'first_name': 'Foo',
         'last_name': 'Bar',
         'comment': {
             'message': 'some text',
             'user': {
                 'username': '******'
             }
         }
     }
     output = pysharedutils.get_dict_properties(
         d,
         False,
         'first_name',
         'zipcode',
         'comment.message',
         'comment.location',
         'comment.user.username'
     )
     expected_output = {
         'first_name': 'Foo',
         'zipcode': None,
         'comment.message': 'some text',
         'comment.location': None,
         'comment.user.username': '******'
     }
     assert_equal(output, expected_output)
Exemplo n.º 3
0
 def test_get_dict_properties_without_strict_and_invalid_property(self):
     d = {
         'comment': {
             'message': 'some text',
         }
     }
     output = pysharedutils.get_dict_properties(
         d,
         False,
         'comment.user.username'
     )
     assert_equal(output, {'comment.user.username': None})
Exemplo n.º 4
0
 def test_get_dict_properties_with_non_existing_property(self):
     d = {
         'first_name': 'Foo',
         'last_name': 'Bar'
     }
     output = pysharedutils.get_dict_properties(
         d, False, 'first_name', 'zipcode'
     )
     assert_equal(
         output,
         {'first_name': 'Foo', 'zipcode': None}
     )
Exemplo n.º 5
0
 def test_simple_get_dict_properties(self):
     d = {
         'first_name': 'Foo',
         'last_name': 'Bar'
     }
     output = pysharedutils.get_dict_properties(
         d, False, 'first_name'
     )
     assert_equal(
         output,
         {'first_name': 'Foo'}
     )