예제 #1
0
 def test_get_new_result(self):
     '''
     tests the /new/ url response type
     '''
     random.seed(1)  # results will be 3, 10, 2
     for cur_type, type_name in self.response_type:
         request = self.factory.get(
             self.request_url+'&response_type='+cur_type)
         response = views.get_new_result(request)
         self.assertEqual(response.status_code, 200)
         self.assertEqual(response.__class__.__name__, type_name)
예제 #2
0
 def test_incorrect_param_types(self):
     '''
     Tests that an http 500 response is sent when a non Json parameter
     is passed.
     '''
     request = self.factory.get('/rand/get/?rand_parameters=bleh')
     response = views.get_result(request)
     self.assertEqual(response.status_code, 500)
     request = self.factory.get('/rand/new/?rand_parameters=bleh')
     response = views.get_new_result(request)
     self.assertEqual(response.status_code, 500)
예제 #3
0
 def test_no_params(self):
     '''
     Tests that an http 500 response is sent when no parameters
     are passed.
     '''
     request = self.factory.get('/rand/get/')
     response = views.get_result(request)
     self.assertEqual(response.status_code, 500)
     request = self.factory.get('/rand/new/')
     response = views.get_new_result(request)
     self.assertEqual(response.status_code, 500)
예제 #4
0
    def test_incorrect_randomizer_param(self):
        '''
        Tests that an http 500 response is sent when the randomizer raises
        a RandomizerError.
        '''
        dict_param = {'type': 'arithmetic sequence',
                      'first_value': 'a',
                      'nb_values': 'b',
                      'step': 'b'}
        json_param = json.dumps(dict_param)

        request = self.factory.get('/rand/get/?rand_parameters='+json_param)
        response = views.get_result(request)
        self.assertEqual(response.status_code, 500)
        request = self.factory.get('/rand/new/?rand_parameters='+json_param)
        response = views.get_new_result(request)
        self.assertEqual(response.status_code, 500)