Exemple #1
0
 def test_valid_form(self):
     u = self.create_userservice()
     data = {'user': u.user, 'name': u.name, 'token': ''}
     if u.name.auth_required and u.name.self_hosted:
         data = {'user': u.user, 'name': u.name, 'token': u.token,
                 'host': 'http://localhost/',
                 'username': '******',
                 'password': '******',
                 'client_id': 'the_id',
                 'client_secret': 'the_secret'
                 }
         data2 = {'user': u.user, 'name': u.name, 'token': u.token,
                  'host': 'http://localhost/',
                  'username': '',
                  'password': '******',
                  'client_id': 'the_id',
                  'client_secret': 'the_secret'}
     initial = {'user': self.user}
     # create a second service to be able to cover the "else" in
     # activated_services()
     user = self.user
     ServicesActivated.objects.create(name='ServiceRss',
                                      status=True,
                                      auth_required=True,
                                      description='Service Rss')
     form = UserServiceForm(data=data, initial=initial)
     self.assertTrue(form.is_valid())
     form.clean()
     form.save(user=user)
     # form is not valid because auth +
     # self_host are true but username is missing
     form = UserServiceForm(data=data2, initial=initial)
     self.assertFalse(form.is_valid())
     form.clean()
 def test_invalid_form(self):
     data = {'duration': 'x'}
     form = UserServiceForm(data=data,
                            initial={
                                'user': self.user,
                                'name': 'ServiceRss'
                            })
     self.assertFalse(form.is_valid())
 def test_valid_form(self):
     u = self.create_userservice()
     if u.name.auth_required:
         data = {'user': u.user, 'name': u.name, 'token': u.token}
     else:
         data = {'user': u.user, 'name': u.name, 'token': ''}
     initial = {'user': self.user}
     form = UserServiceForm(data=data, initial=initial)
     self.assertTrue(form.is_valid())
 def test_valid_form(self):
     u = self.create_userservice()
     if u.name.auth_required:
         data = {'user': u.user, 'name': u.name, 'token': u.token}
     else:
         data = {'user': u.user, 'name': u.name, 'token': ''}
     initial = {'user': self.user}
     form = UserServiceForm(data=data, initial=initial)
     self.assertTrue(form.is_valid())
 def test_valid_form(self):
     u = self.create_userservice()
     data = {'user': u.user, 'name': u.name, 'token': ''}
     if u.name.auth_required:
         data = {'user': u.user, 'name': u.name, 'token': u.token}
     initial = {'user': self.user}
     # create a second service to be able to cover the "else" in activated_services()
     user = self.user
     ServicesActivated.objects.create(name='ServiceRss',
                                      status=True,
                                      auth_required=True,
                                      description='Service Rss')
     form = UserServiceForm(data=data, initial=initial)
     self.assertTrue(form.is_valid())
     form.save(user=user)
 def test_valid_form(self):
     u = self.create_userservice()
     data = {'user': u.user, 'name': u.name, 'token': ''}
     if u.name.auth_required:
         data = {'user': u.user, 'name': u.name, 'token': u.token}
     initial = {'user': self.user}
     # create a second service to be able to cover the "else" in activated_services()
     user = self.user
     ServicesActivated.objects.create(name='ServiceRss',
                                      status=True,
                                      auth_required=True,
                                      description='Service Rss')
     form = UserServiceForm(data=data, initial=initial)
     self.assertTrue(form.is_valid())
     form.save(user=user)
 def test_invalid_form(self):
     data = {'user': '', 'name': '', 'token': ''}
     initial = {'user': self.user}
     form = UserServiceForm(data=data, initial=initial)
     self.assertFalse(form.is_valid())
 def test_valid_form(self):
     u = self.create_userservice()
     data = {'user': u.user, 'name': u.name, 'token': ''}
     if u.name.auth_required and u.name.self_hosted:
         data = {'user': u.user, 'name': u.name, 'token': u.token,
                 'host': 'http://localhost/',
                 'username': '******',
                 'password': '******',
                 'client_id': 'the_id',
                 'client_secret': 'the_secret',
                 'duration': 'd',
                 }
         data2 = {'user': u.user, 'name': u.name, 'token': u.token,
                  'host': 'http://localhost/',
                  'username': '',
                  'password': '******',
                  'client_id': 'the_id',
                  'client_secret': 'the_secret'}
     initial = {'user': self.user}
     # create a second service to be able to cover the "else" in
     # activated_services()
     user = self.user
     ServicesActivated.objects.create(name='ServiceRss',
                                      status=True,
                                      auth_required=True,
                                      description='Service Rss')
     form = UserServiceForm(data=data, initial=initial)
     self.assertTrue(form.is_valid())
     form.clean()
     form.save(user=user)
     # form is not valid because auth +
     # self_host are true but username is missing
     form = UserServiceForm(data=data2, initial=initial)
     self.assertFalse(form.is_valid())
     form.clean()
 def test_invalid_form(self):
     data = {'user': '', 'name': '', 'token': ''}
     initial = {'user': self.user}
     form = UserServiceForm(data=data, initial=initial)
     self.assertFalse(form.is_valid())
 def test_invalid_form(self):
     data = {'duration': 'x'}
     form = UserServiceForm(data=data, initial={'user': self.user, 'name': 'ServiceRss'})
     self.assertFalse(form.is_valid())