def test_input_bad_ip(self):
     res = fetch_binding.fetch_binding([{
         'url': 'http://hyver-security.com',
         'target_ip': '0'
     }])
     self.assertEqual(res, [{
         'url': 'http://hyver-security.com',
         'target_ip': '0',
         'error': 'bad ip'
     }])
 def test_input_good_url_and_ip(self):
     res = fetch_binding.fetch_binding(self.input_2)
     self.assertEqual(res, self.expected_output_2)
 def test_input_bad_url(self):
     res = fetch_binding.fetch_binding([{'url': 'http://'}])
     self.assertEqual(res, [{'url': 'http://', 'error': 'bad url'}])
 def test_input_empty_dictionary(self):
     res = fetch_binding.fetch_binding([{}])
     self.assertEqual(res, [{'error': 'wrong format'}])
 def test_input_wrong_input(self):
     res = fetch_binding.fetch_binding("")
     self.assertEqual(res, [{'error': 'wrong format'}])
 def test_input_empty_list(self):
     res = fetch_binding.fetch_binding([])
     self.assertEqual(res, [])
示例#7
0
def api_bindings():
    binding = request.get_json()
    res = fetch_binding.fetch_binding(binding)
    return jsonify(res)