def test_add_registry(self, mock_identify, mock_metadata_formats, mock_sets, mock_get): """ Test add registry Args: mock_identify: mock_metadata_formats: mock_sets: mock_get: Returns: """ # Arrange mock_identify.return_value = OaiPmhMock.mock_oai_identify( ), status.HTTP_200_OK mock_metadata_formats.return_value = OaiPmhMock.mock_oai_metadata_format(), \ status.HTTP_200_OK mock_sets.return_value = OaiPmhMock.mock_oai_set(), status.HTTP_200_OK text = '<test>Hello</test>' mock_get.return_value.status_code = status.HTTP_200_OK mock_get.return_value.text = text # Act result = oai_registry_api.add_registry_by_url( self.fixture.url, self.fixture.harvest_rate, self.fixture.harvest) # Assert self.assertIsInstance(result, OaiRegistry)
def test_add_registry_metadata_format(self, mock_identify, mock_metadata_formats, mock_sets, mock_get): """ Test add registry metadata formats Args: mock_identify: mock_metadata_formats: mock_sets: mock_get: Returns: """ # Arrange mock_identify.return_value = OaiPmhMock.mock_oai_identify( ), status.HTTP_200_OK list_metadata_formats = OaiPmhMock.mock_oai_metadata_format() mock_metadata_formats.return_value = list_metadata_formats, status.HTTP_200_OK mock_sets.return_value = [], status.HTTP_200_OK text = '<test>Hello</test>' mock_get.return_value.status_code = status.HTTP_200_OK mock_get.return_value.text = text # Act result = oai_registry_api.add_registry_by_url( self.fixture.url, self.fixture.harvest_rate, self.fixture.harvest) # Assert _assert_metadata_format(self, list_metadata_formats, result.id)
def test_update_registry(self, mock_identify, mock_metadata_formats, mock_sets, mock_get): # Arrange identify = OaiPmhMock.mock_oai_identify(version=2) mock_identify.return_value = identify, status.HTTP_200_OK first_metadata_format = OaiPmhMock.mock_oai_metadata_format(version=2) mock_metadata_formats.return_value = first_metadata_format, status.HTTP_200_OK first_set = OaiPmhMock.mock_oai_set(version=2) mock_sets.return_value = first_set, status.HTTP_200_OK text = '<test>Hello</test>' mock_get.return_value.status_code = status.HTTP_200_OK mock_get.return_value.text = text # Act result = oai_registry_api.update_registry_info(self.fixture.registry) # Assert _assert_identify(self, identify, result.id) _assert_metadata_format(self, first_metadata_format, result.id) _assert_set(self, first_set, result.id)
def test_update_registry_info(self, mock_identify, mock_metadata_formats, mock_sets, mock_get): # Arrange identify = OaiPmhMock.mock_oai_identify(version=2) mock_identify.return_value = identify, status.HTTP_200_OK first_metadata_format = OaiPmhMock.mock_oai_metadata_format(version=2) mock_metadata_formats.return_value = first_metadata_format, status.HTTP_200_OK first_set = OaiPmhMock.mock_oai_set(version=2) mock_sets.return_value = first_set, status.HTTP_200_OK text = '<test>Hello</test>' mock_get.return_value.status_code = status.HTTP_200_OK mock_get.return_value.text = text # Act response = RequestMock.do_request_patch( rest_oai_registry.InfoRegistry.as_view(), user=create_mock_user('1', is_staff=True), param=self.param) # Assert self.assertEqual(response.status_code, status.HTTP_200_OK)
def test_update_registry(self, mock_identify, mock_metadata_formats, mock_sets, mock_get): # Arrange mock_user = create_mock_user("1", is_superuser=True) mock_request = create_mock_request(user=mock_user) identify = OaiPmhMock.mock_oai_identify(version=2) mock_identify.return_value = identify, status.HTTP_200_OK first_metadata_format = OaiPmhMock.mock_oai_metadata_format(version=2) mock_metadata_formats.return_value = first_metadata_format, status.HTTP_200_OK first_set = OaiPmhMock.mock_oai_set(version=2) mock_sets.return_value = first_set, status.HTTP_200_OK text = "<test>Hello</test>" mock_get.return_value.status_code = status.HTTP_200_OK mock_get.return_value.text = text # Act result = oai_registry_api.update_registry_info(self.fixture.registry, request=mock_request) # Assert _assert_identify(self, identify, result.id) _assert_metadata_format(self, first_metadata_format, result.id) _assert_set(self, first_set, result.id)
def test_add_registry(self, mock_identify, mock_metadata_formats, mock_sets, mock_get): """Test add registry Args: mock_identify: mock_metadata_formats: mock_sets: mock_get: Returns: """ # Arrange mock_user = create_mock_user("1", is_superuser=True) mock_request = create_mock_request(user=mock_user) mock_identify.return_value = OaiPmhMock.mock_oai_identify( ), status.HTTP_200_OK mock_metadata_formats.return_value = ( OaiPmhMock.mock_oai_metadata_format(), status.HTTP_200_OK, ) mock_sets.return_value = OaiPmhMock.mock_oai_set(), status.HTTP_200_OK text = "<test>Hello</test>" mock_get.return_value.status_code = status.HTTP_200_OK mock_get.return_value.text = text # Act result = oai_registry_api.add_registry_by_url( self.fixture.url, self.fixture.harvest_rate, self.fixture.harvest, request=mock_request, ) # Assert self.assertIsInstance(result, OaiRegistry)