コード例 #1
0
    def test_valid_format_but_inexistent_should_raise_bad_requset(self, mock_search):
        params = {'format_id': '1234'}
        
        mock_search.return_value = MockQuery(None)

        request = testing.DummyRequest(post=params)
        request.context = testing.DummyResource()

        with self.assertRaises(HTTPBadRequest):
            extract_format(request)
コード例 #2
0
    def test_valid_format_but_inexistent_should_raise_bad_requset(
            self, mock_search):
        params = {'format_id': '1234'}

        mock_search.return_value = MockQuery(None)

        request = testing.DummyRequest(post=params)
        request.context = testing.DummyResource()

        with self.assertRaises(HTTPBadRequest):
            extract_format(request)
コード例 #3
0
    def test_valid_format_should_return_ids(self, mock_search):
        params = {'format_id': '1234'}
        format = factory.EdamFactory.build()

        mock_search.return_value = MockQuery(format)

        request = testing.DummyRequest(post=params)
        request.context = testing.DummyResource()

        self.assertEqual(extract_format(request), format)
コード例 #4
0
    def test_valid_format_should_return_ids(self, mock_search):
        params = {'format_id': '1234'}
        format = factory.EdamFactory.build()
        
        mock_search.return_value = MockQuery(format)

        request = testing.DummyRequest(post=params)
        request.context = testing.DummyResource()

        self.assertEqual(extract_format(request), format)