def test_golden(self): golden_response = Mock(spec=Response) golden_response.json.side_effect = [self.golden_response_output1, self.golden_response_output2] golden_response.status_code = 200 golden_output = {'get.return_value': golden_response} self.device = Mock(**golden_output) obj = Interface(device=self.device) parsed_output = obj.parse() self.assertEqual(parsed_output, self.golden_parsed_output)
def test_empty(self): empty_response = Mock(spec=Response) empty_response.json.return_value = {'response': []} empty_response.status_code = 200 empty_output = {'get.return_value': empty_response} self.device1 = Mock(**empty_output) obj = Interface(device=self.device1) with self.assertRaises(SchemaEmptyParserError): obj.parse()
def test_golden(self): self.device = Mock(**self.golden_output) obj = Interface(device=self.device) parsed_output = obj.parse() self.assertEqual(parsed_output, self.golden_parsed_output)
def test_empty(self): self.device1 = Mock(**self.empty_output) obj = Interface(device=self.device1) with self.assertRaises(SchemaEmptyParserError): parsed_output = obj.parse()