def test_wf_module_update_settings(self):
        settings = {
            'auto_update_data': True,
            'update_interval': 5,
            'update_units': 'weeks'
        }

        request = self.factory.patch('/api/wfmodules/%d' % self.wfmodule1.id,
                                     settings)
        force_authenticate(request, user=self.user)
        response = wfmodule_detail(request, pk=self.wfmodule1.id)
        self.assertIs(response.status_code, status.HTTP_204_NO_CONTENT)

        # see that we get the new values back
        response = self.client.get('/api/wfmodules/%d/' % self.wfmodule1.id)
        self.assertIs(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['auto_update_data'], True)
        self.assertEqual(response.data['update_interval'], 5)
        self.assertEqual(response.data['update_units'], 'weeks')

        # Now check for error checking! As usual, this is most of the work
        missing_units_key = {'auto_update_data': True, 'update_interval': 1000}
        request = self.factory.patch('/api/wfmodules/%d' % self.wfmodule1.id,
                                     missing_units_key)
        force_authenticate(request, user=self.user)
        response = wfmodule_detail(request, pk=self.wfmodule1.id)
        self.assertIs(response.status_code, status.HTTP_400_BAD_REQUEST)

        missing_interval_key = {
            'auto_update_data': True,
            'update_units': 'days'
        }
        request = self.factory.patch('/api/wfmodules/%d' % self.wfmodule1.id,
                                     missing_interval_key)
        force_authenticate(request, user=self.user)
        response = wfmodule_detail(request, pk=self.wfmodule1.id)
        self.assertIs(response.status_code, status.HTTP_400_BAD_REQUEST)

        bad_units_key = {
            'auto_update_data': True,
            'update_interval': 66,
            'update_units': 'pajama'
        }
        request = self.factory.patch('/api/wfmodules/%d' % self.wfmodule1.id,
                                     bad_units_key)
        force_authenticate(request, user=self.user)
        response = wfmodule_detail(request, pk=self.wfmodule1.id)
        self.assertIs(response.status_code, status.HTTP_400_BAD_REQUEST)
示例#2
0
 def test_wf_module_update_settings_missing_interval(self):
     settings = {'auto_update_data': True, 'update_units': 'days'}
     request = self._build_patch('/api/wfmodules/%d' % self.wf_module1.id,
                                 settings,
                                 user=self.user)
     response = wfmodule_detail(request, pk=self.wf_module1.id)
     self.assertIs(response.status_code, status.HTTP_400_BAD_REQUEST)
示例#3
0
    def test_wf_module_notes_post(self):
        request = self._build_patch('/api/wfmodules/%d' % self.wf_module1.id,
                                    {'notes': 'wow such doge'},
                                    user=self.user)
        response = wfmodule_detail(request, pk=self.wf_module1.id)
        self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)

        # see that we get the new value back
        response = self.client.get('/api/wfmodules/%d/' % self.wf_module1.id)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['notes'], 'wow such doge')

        # Test for error on missing notes field (and no other patachable fields)
        request = self._build_patch('/api/wfmodules/%d' % self.wf_module1.id,
                                    {'notnotes': 'forthcoming error'},
                                    user=self.user)
        response = wfmodule_detail(request, pk=self.wf_module1.id)
        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
示例#4
0
 def test_wf_module_update_settings_bad_units(self):
     settings = {
         'auto_update_data': True,
         'update_interval': 66,
         'update_units': 'pajama'
     }
     request = self.factory.patch('/api/wfmodules/%d' % self.wfmodule1.id,
                                  settings)
     force_authenticate(request, user=self.user)
     response = wfmodule_detail(request, pk=self.wfmodule1.id)
     self.assertIs(response.status_code, status.HTTP_400_BAD_REQUEST)
示例#5
0
    def test_wf_module_update_settings(self):
        settings = {'auto_update_data': True, 'update_interval': 5,
                    'update_units': 'weeks'}

        request = self._build_patch('/api/wfmodules/%d/' % self.wf_module1.id,
                                    settings, user=self.user)
        response = wfmodule_detail(request, pk=self.wf_module1.id)
        self.assertIs(response.status_code, status.HTTP_204_NO_CONTENT)

        # see that we set the values
        self.wf_module1.refresh_from_db()
        self.assertEqual(self.wf_module1.auto_update_data, True)
        self.assertEqual(self.wf_module1.update_interval, 3024000)

        # Check we logged the event
        # #160041803
        self.log_patch.assert_called_once()
        self.assertEqual(self.log_patch.call_args[0][1], 'Enabled auto-update')
示例#6
0
    def test_wf_module_update_settings(self):
        settings = {
            'auto_update_data': True,
            'update_interval': 5,
            'update_units': 'weeks'
        }

        request = self.factory.patch('/api/wfmodules/%d' % self.wfmodule1.id,
                                     settings)
        force_authenticate(request, user=self.user)
        response = wfmodule_detail(request, pk=self.wfmodule1.id)
        self.assertIs(response.status_code, status.HTTP_204_NO_CONTENT)

        # see that we get the new values back
        response = self.client.get('/api/wfmodules/%d/' % self.wfmodule1.id)
        self.assertIs(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['auto_update_data'], True)
        self.assertEqual(response.data['update_interval'], 5)
        self.assertEqual(response.data['update_units'], 'weeks')
示例#7
0
    def test_wf_module_update_settings(self):
        settings = {'auto_update_data': True,
                    'update_interval': 5,
                    'update_units': 'weeks'}

        request = self._build_patch('/api/wfmodules/%d' % self.wfmodule1.id,
                                    settings, user=self.user)
        response = wfmodule_detail(request, pk=self.wfmodule1.id)
        self.assertIs(response.status_code, status.HTTP_204_NO_CONTENT)

        # see that we get the new values back
        response = self.client.get('/api/wfmodules/%d/' % self.wfmodule1.id)
        self.assertIs(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['auto_update_data'], True)
        self.assertEqual(response.data['update_interval'], 5)
        self.assertEqual(response.data['update_units'], 'weeks')

        # Check we logged the event
        # #160041803
        self.log_patch.assert_called_once()
        self.assertEqual(self.log_patch.call_args[0][1], 'Enabled auto-update')