def test_private_func__parse_subject(self): """ Test private function _parse_subject(subject) it handles a missing fields :return: """ class FakeSubject: """ Class for faking x509'th subject. """ def __init__(self): self.nid = {"Darth Vader": 1} def __getattr__(self, item): if item != "nid": raise TypeError( "A star wars satellite accidentally blew up the WAN." ) subj = FakeSubject() x509._parse_subject(subj) assert x509.log.trace.call_args[0][0] == "Missing attribute '%s'. Error: %s" assert x509.log.trace.call_args[0][1] == list(subj.nid.keys())[0] assert isinstance(x509.log.trace.call_args[0][2], TypeError)
def test_private_func__parse_subject(self): ''' Test private function _parse_subject(subject) it handles a missing fields :return: ''' class FakeSubject(object): ''' Class for faking x509'th subject. ''' def __init__(self): self.nid = {'Darth Vader': 1} def __getattr__(self, item): if item != 'nid': raise TypeError('A star wars satellite accidentally blew up the WAN.') subj = FakeSubject() x509._parse_subject(subj) x509.log.trace.assert_called_once() assert x509.log.trace.call_args[0][0] == "Missing attribute '%s'. Error: %s" assert x509.log.trace.call_args[0][1] == list(subj.nid.keys())[0] assert isinstance(x509.log.trace.call_args[0][2], TypeError)