def test_validate_doc_cached_rfc(self, mock_extract_files: mock.MagicMock): mock_extract_files.return_value = 'test' request = self.factory.post('/yangvalidator/v2/rfc', {'rfc': '1'}, content_type='application/json') result = v.validate_doc(request) self.assertEqual(result, 'test') mock_extract_files.assert_called_with(request, 'test/rfc/rfc1.txt', True, mock.ANY)
def test_validate_doc_missing_draft(self): request = self.factory.post('/yangvalidator/v2/draft', {}, content_type='application/json') result = v.validate_doc(request) response = json.loads(result.content) self.assertEqual(result.headers['Content-Type'], 'application/json') self.assertEqual(result.status_code, 400) self.assertIn('Error', response) self.assertEqual(response.get('Error'), 'Required property "draft" is missing or empty')
def test_validate_doc_uncached_draft(self, mock_extract_files: mock.MagicMock): mock_extract_files.return_value = 'test' request = self.factory.post('/yangvalidator/v2/draft', {'draft': 'test.txt'}, content_type='application/json') result = v.validate_doc(request) self.assertEqual(result, 'test') mock_extract_files.assert_called_with( request, 'https://tools.ietf.org/id/test.txt', True, mock.ANY)