def test_actual_queue_message(self): client = Factory.create(Components.ServiceClients.SQS, queue_name='qm-queue') self.assertTrue(client.send_message(QueueMessage(**DUMMY_MESSAGE))) message = client.receive_message() self.assertIsNotNone(message) client.complete_message(message)
def test_purge(self): mock = MagicMock() client = Factory.create(Components.ServiceClients.SQS, queue_name=DUMMY, client=mock) self.assertTrue(client.purge()) mock.purge_queue.side_effect = Exception self.assertFalse(client.purge())
def test_actual_sqs(self): client = Factory.create(Components.ServiceClients.SQS, queue_name='test') model = QueueMessage() model.message = 'This is a test ___' model.name = 'ODB' model.value = 420 self.assertTrue(client.send_message(model)) message = client.receive_message() self.assertEqual(message.name, model.name) client.complete_message(message)
def test_full_queue(self): mock = MagicMock() mock.create_queue.return_value = mock mock.get_queue_by_name.return_value = mock mock.receive_message.return_value = MOCK_RESPONSE client = Factory.create(Components.ServiceClients.SQS, queue_name=DUMMY, client=mock) self.assertIsNotNone(client) self.assertTrue(client.send_message(TEST_MESSAGE)) mock.send_message.assert_called() message = client.receive_message() self.assertTrue(message) self.assertTrue(client.complete_message(message)) mock.send_message.side_effect = Exception self.assertFalse(client.send_message(TEST_MESSAGE)) mock.receive_message.side_effect = Exception self.assertFalse(client.receive_message()) mock.delete_message.side_effect = Exception self.assertFalse(client.complete_message(message))
def test_queue_lost_message(self): client = Factory.create(Components.ServiceClients.SQS, queue_name='test', endpoint_url=LOCAL_SQS) message = QueueMessage() message.product = "site.reliability" message.account_name = "reliabilly_ps" message.portfolio = "Platform Services" message.threshold = "5" message.slo_type = "error_rate" message.component = "reliabillyecs_cluster" message.query = "SELECT sum(`provider.httpCodeTarget5XXCount.Sum`) from LoadBalancerSample where " \ "`label.serverclass` like 'lighthouse' and `provider.awsRegion` = 'us-west-2'" message.query_executor = "newrelic" message.id = "0000000-ae7a-4896-a957-9b736128eaf3" message.name = "lighthouse-error_rate-uat" client.send_message(message) received_message = client.receive_message() self.assertEqual(message.message_id, received_message.message_id) client.complete_message(received_message)
def test_auth_factory(self): client = Factory.create(Components.ServiceClients.AUTH) self.assertTrue(isinstance(client, Authorization))
def test_dynamo_factory(self): client = Factory.create(Components.DataClients.DYNAMODB) self.assertIsNotNone(client)