def tearDown(self): self.client.close() for consumer_ref in self._cleanup_consumers: self.assertTrue(isinstance(consumer_ref, models.ConsumerReference)) consumer_ref = models.ConsumerReference.objects.get(id=consumer_ref.id) # reloads!! logic.withdraw_consumer(self.client, consumer_ref)
def tearDown(self): self.client.close() for consumer_ref in self._cleanup_consumers: self.assertTrue(isinstance(consumer_ref, models.ConsumerReference)) consumer_ref = models.ConsumerReference.objects.get( id=consumer_ref.id) # reloads!! logic.withdraw_consumer(self.client, consumer_ref)
def test_withdraw_consumer(self): # Create consumer_ref consumer_ref = ConsumerReferenceFactory(username=fake.consumer_name()) # Publish logic.synchronize_consumer(self.client, consumer_ref) self.assertTrue(consumer_ref.synchronized) # Check kong result = self.client.consumers.retrieve(consumer_ref.kong_id) self.assertIsNotNone(result) self.assertEqual(result['username'], consumer_ref.username) # Store kong_id kong_id = consumer_ref.kong_id # You can delete afterwards logic.withdraw_consumer(self.client, consumer_ref) self.assertFalse(consumer_ref.synchronized) # Check kong with self.assertRaises(ValueError): _ = self.client.consumers.retrieve(kong_id)
def test_withdraw_consumer_oauth2(self): # Create consumer_ref consumer_ref = ConsumerReferenceFactory(username=fake.consumer_name()) # Create auth auth_ref = OAuth2ReferenceFactory(consumer=consumer_ref) # Publish logic.synchronize_consumer(self.client, consumer_ref) self.assertTrue(consumer_ref.synchronized) # Reload auth_ref = models.OAuth2Reference.objects.get(id=auth_ref.id) self.assertIsNotNone(auth_ref.kong_id) self.assertTrue(auth_ref.synchronized) # Withdraw logic.withdraw_consumer(self.client, consumer_ref) self.assertFalse(consumer_ref.synchronized) # Reload auth_ref = models.OAuth2Reference.objects.get(id=auth_ref.id) self.assertIsNone(auth_ref.kong_id) self.assertFalse(auth_ref.synchronized)