def setUp(self): super().setUp() self.user = get_test_user() get_test_user_api_key(user=self.user, webhook_url='https://test') get_test_user_api_key(user=get_test_user(), webhook_url='https://blargh') self.assertEqual(0, Webhook.objects.count())
def test_get_user(self): user = get_test_user() key = UserAPIKey.objects.create_key('The_fate_of_monocultures', user=user) plain_password = key.get_plain_password() self.assertEqual( user, UserAPIKey.objects.get_user(key.username, plain_password))
def test_display(self): user = get_test_user() table = UserAPIKeysTable(user, {}) description = 'Blah blah blah.' api_keys_widget = APIKeysWidget( None, table, 'User API Keys', description) html = api_keys_widget.as_html() self.assertTrue(html.find('Blah blah blah.') > 0)
def test_create_and_use_token(self): self.assertIsNone(use_token_and_return_user('token_does_not_exist')) user = get_test_user() token_str = new_login_token(user).token self.assertTrue(isinstance(token_str, str)) self.assertTrue(len(token_str) >= 7) self.assertEqual(user, use_token_and_return_user(token_str)) self.assertIsNone(use_token_and_return_user(token_str))
def test_send(self): user = get_test_user() user_email_sender = Mock(spec=UserEmailSender) email = LoginEmail( 'https', 'tracktime.tech', user, next_url=reverse('sign_up_email_preview'), user_email_sender=user_email_sender) email.send() self.assertEqual(1, len(user_email_sender.send_mail.call_args_list))
def setUp(self): super().setUp() user = get_test_user() self.other = get_test_my_fake_model(name='Other', user=user) self.request_data = { 'small_int': 1, 'large_int': 2, 'my_date': '2020-05-28', 'my_date_time': '2020-05-28T12:00:00.000000-04:00', 'my_char': 'Gourmet surprise', 'my_text': 'for dinner', 'my_fake_model': self.other.pk, 'my_money': 100, 'my_money_currency': 'AUD' } self.user_api_key = get_test_user_api_key(user=user)
def test_display(self): user = get_test_user(email='*****@*****.**') settings_widget = SettingsWidget(reverse('to_do'), user) html = settings_widget.as_html() self.assertTrue(html.find('*****@*****.**') > 0)
def setUp(self): super().setUp() self.user = get_test_user() # Different user. Irrelevant. get_test_user_api_key()
def get_test_user_api_key(**kwargs): user = kwargs.get('user', None) if not user: user = get_test_user() return set_api_key_stuff(UserAPIKey(user=user), **kwargs)
def get_test_my_fake_model(**kwargs): user = kwargs.get('user', None) if not user: user = get_test_user() return MyFakeModel.objects.create( name=kwargs.get('name', 'Testname'), user=user)