Exemplo n.º 1
0
 def hasJson(self, key, value=''):
     response = json.loads(self.container.make('Response'))
     if isinstance(key, dict):
         for item_key, value in key.items():
             if not Dot().dot(item_key, response, False) == value:
                 return False
         return True
     return Dot().dot(key, response, False)
Exemplo n.º 2
0
 def assertHasJson(self, key, value):
     response = json.loads(self.container.make('Response'))
     if isinstance(key, dict):
         for item_key, key_value in key.items():
             assert Dot().dot(item_key, response, False) == key_value
     else:
         assert Dot().dot(key, response, False) == value, "Key '{}' with the value of '{}' could not find a match in {}".format(key, value, response)
     return self
Exemplo n.º 3
0
    def assertJsonContains(self, key, value):
        response = json.loads(self.container.make('Response'))
        if not isinstance(response, list):
            raise ValueError("This method can only be used if the response is a list of elements.")

        found = False
        for element in response:
            if Dot().dot(key, element, False):
                assert Dot().dot(key, element, False)
                found = True

        if not found:
            raise AssertionError("Could not find a key of: {} that had the value of {}".format(key, value))
        return self
Exemplo n.º 4
0
    def test_dict_dot_works_for_deep_dictionaries(self):
        dictionary = {
            'storage': {
                'drivers': {
                    'disk': {
                        'location': {
                            'uploading': 'uploads/'
                        }
                    }
                }
            }
        }

        self.assertEqual(
            Dot().dict_dot('storage.drivers.disk.location',
                           dictionary)['uploading'], 'uploads/')
Exemplo n.º 5
0
 def test_dot_dict(self):
     assert Dot().dict_dot('async.driver', {'async': {
         'driver': 'me'
     }}, 'you') == 'me'
Exemplo n.º 6
0
 def test_dict_dot_returns_value(self):
     assert Dot().dict_dot('s3.test', {'s3': {
         'test': 'value'
     }}, '') == 'value'
Exemplo n.º 7
0
 def test_dot_dict(self):
     self.assertEqual(
         Dot().dict_dot('async.driver', {'async': {
             'driver': 'me'
         }}, 'you'), 'me')
Exemplo n.º 8
0
 def test_dict_dot_returns_value(self):
     self.assertEqual(
         Dot().dict_dot('s3.test', {'s3': {
             'test': 'value'
         }}, ''), 'value')