def test_access_nested_map_exception(self, values, path, expected): """ Testing errors """ with self.assertRaises(KeyError) as e: access_nested_map(values, path) self.assertEqual(expected, str(e.exception))
def test_access_nested_map_exception(self, nested_map, path, expected_value): """ Unittest for exception in a nested map function """ with self.assertRaises(KeyError) as error: access_nested_map(nested_map=nested_map, path=path) self.assertEqual(repr(error.exception), repr(expected_value))
def test_access_nested_map_exception(self, nested_map, path_map): """ Exception access nested method """ with self.assertRaises(KeyError) as error: access_nested_map(nested_map, path_map) self.assertEqual(f'KeyError({str(error.exception)})', repr(error.exception))
def test_access_nested_map_exception(self, mapping, path): """ Second unit test for nested_map function, (test exception nested map) Method that use the assertRaises context manager to test that a KeyError is generated for some inputs """ with self.assertRaises(KeyError): access_nested_map(mapping, path)
def test_access_nested_map_exception(self, mapp, path, error): """Testing failure of utils.access_nested_map method """ with self.assertRaises(KeyError): try: access_nested_map(mapp, path) except KeyError as e: self.assertEqual(e.args[0], error) raise
def test_access_nested_map_exception(self, nested_map, path, false_out): """[summary] Args: map ([type]): [description] path ([type]): [description] wrong_output ([type]): [description] """ with self.assertRaises(KeyError) as error: access_nested_map(nested_map, path) self.assertEquals(false_out, error.exception)
def test_access_nested_map_exception(self, nested_map: dict, path: tuple, expected): """ Tets the exceptions of the function :param nested_map: Dict to test :param path: Keys in the order to access :param expected: Value expected :return: Nothing """ with self.assertRaises(KeyError) as err: access_nested_map(nested_map=nested_map, path=path) self.assertEqual(repr(err.exception), repr(expected))
def test_access_nested_map_exception(self, nested_map, path_map): """ Exception access nested method args: nested_map: {} path: ("a",) return: ok if its correct """ with self.assertRaises(KeyError) as error: access_nested_map(nested_map, path_map) self.assertEqual(f'KeyError({str(error.exception)})', repr(error.exception))
def has_license(repo: Dict[str, Dict], license_key: str) -> bool: assert license_key is not None, "license_key cannot be None" try: has_license = access_nested_map(repo, ("license", "key")) == license_key except KeyError: return False return has_license
def test_access_nested_map(self, nested_map, path, expected): """[summary] Args: map ([type]): [description] path ([type]): [description] output ([type]): [description] """ output = access_nested_map(nested_map, path) self.assertEqual(output, expected)
def test_access_nested_map(self, nested_map: dict, path: tuple, expected: int): """ Take the parametrizer and test the access to a dict :param nested_map: Dict to test :param path: Keys in the order to access :param expected: Value expected :return: Nothing """ self.assertEqual(access_nested_map(nested_map=nested_map, path=path), expected)
def test_access_nested_map(self, nested_map, path_map, result_expec): """ Access nested method args: nested_map: {"a": 1}, path: ("a",) result_expec: 1 return Ok if its correct """ self.assertEqual(access_nested_map(nested_map, path_map), result_expec)
def test_access_nested_map_exception(self, expected, nested_map, path): """ Method that test acces nested map exception. """ with self.assertRaises(expected): access_nested_map(nested_map, path)
def test_access_nested_map(self, expected, nested_map, path): """ Method that test access nested map and returns what it is supposed to. """ self.assertEqual(access_nested_map(nested_map, path), expected)
def test_access_nested_map_exception(self, value, path, error): """ Test utils.test_access_nested_map exception """ with self.assertRaises(KeyError) as e: access_nested_map(value, path) self.assertEqual(error, str(e.exception))
def test_access_nested_map(self, value, path, expected): """Sucess testing for access_nested_map method""" self.assertEqual(access_nested_map(value, path), expected)
def test_access_nested_map_exception( self, map, path, expected): '''Testing access_nested_map exceptions''' with self.assertRaises(KeyError) as e: access_nested_map(map, path) self.assertEqual(expected, str(e.exception))
def test_access_nested_map(self, nested_map, path, map): """ Test access nested map """ self.assertEqual(access_nested_map(nested_map, path), map)
def test_access_nested_map(self, nested_map, path, answer): """ test that the method returns what it is supposed to""" self.assertEqual(access_nested_map(nested_map, path), answer)
def test_access_nested_map(self, nested_map, path, expected): """ Test function for utils.access_nested_map """ self.assertEqual(access_nested_map(nested_map, path), expected)
def test_access_nested_map_exception(self, map, path, wrong_output): """ Test method raises correct exception """ with self.assertRaises(KeyError) as e: access_nested_map(map, path) self.assertEqual(wrong_output, e.exception)
def test_access_nested_map(self, map, path, expected_output): """ Test method returns correct output """ real_output = access_nested_map(map, path) self.assertEqual(real_output, expected_output)
def test_access_nested_map(self, mapping, path, expected): """ First unit test for nested_map function, (test access nested map) Method to test that the method returns what it is supposed to """ self.assertEqual(access_nested_map(mapping, path), expected)
def test_access_nested_map(self, nested_map, path, expected): """ test the access_nested_map function """ self.assertEquals(access_nested_map(nested_map, path), expected)
#!/usr/bin/env python3 import requests from functools import wraps from typing import (Mapping, Sequence, Any, Dict, Callable,) from utils import access_nested_map nested_map = {} path = ("a",) print(access_nested_map(nested_map, path)) nested_map = {"a": 1} path = ("a", "b") print(access_nested_map(nested_map, path))
def test_access_nested_map(self, nested_map, path, expected_value): """ unittest for the function """ self.assertEqual(access_nested_map(nested_map, path), expected_value)
def test_access_nested_map_exception(self, nested_map, path, expected_msg): """ Test function for utils.access_nested_map throwing an exception """ with self.assertRaises(KeyError) as ke: access_nested_map(nested_map, path) self.assertEqual(ke, expected_msg)
def test_access_nested_map(self, map, path, expected): '''Testing access_nested_map''' actual = access_nested_map(map, path) self.assertEqual(actual, expected)
def test_access_nested_map_exception(self, nested_map, path): """ test that a KeyError is raised properly""" with self.assertRaises(KeyError) as error: access_nested_map(nested_map, path) self.assertEqual(error.exception.args[0], path[-1])
def test_access_nested_map_exception(self, nested_map, path): """ Test access nested map exception """ with self.assertRaises(KeyError): access_nested_map(nested_map, path)