Exemple #1
0
    def test_create_eventhub_consumer_groups(self, consumer_group_fun, victim):
        groups = [
            EventHubConsumerGroup(
                EventHub('my-group', 'my-namespace', 'entity1'), 'group1',
                False),
            EventHubConsumerGroup(
                EventHub('my-group', 'my-namespace', 'entity2'), 'group2',
                True),
        ]

        with mock.patch(
                "takeoff.azure.configure_eventhub.ConfigureEventHub._eventhub_exists",
                return_value=True):
            with mock.patch(
                    "takeoff.azure.configure_eventhub.ConfigureEventHub._group_exists",
                    return_value=False):
                victim.create_eventhub_consumer_groups(groups)

        calls = [
            mock.call(group=EventHubConsumerGroup(
                EventHub('my-group', 'my-namespace', 'entity1'), 'group1',
                False)),
            mock.call(group=EventHubConsumerGroup(
                EventHub('my-group', 'my-namespace', 'entity2'), 'group2',
                True))
        ]

        consumer_group_fun.assert_has_calls(calls)
Exemple #2
0
    def test_get_unique_eventhubs(self, victim):
        groups = [
            EventHubConsumerGroup(
                EventHub("sdhdev", "sdheventhubdev", "hub1dev"),
                "your-app-name-group1", False),
            EventHubConsumerGroup(
                EventHub("sdhdev", "sdheventhubdev", "hub1dev"),
                "your-app-name-group2", False),
            EventHubConsumerGroup(
                EventHub("sdhdev", "sdheventhubdev", "hub2dev"),
                "your-app-name-group1", False),
        ]

        uniques = victim._get_unique_eventhubs(groups)

        assert len(uniques) == 2
        assert all(_ in map(lambda x: x.name, uniques)
                   for _ in ("hub1dev", "hub2dev"))
    def test_create_eventhub_consumer_group(self, victim):
        group = EventHubConsumerGroup(EventHub('my-rg', 'my-namespace', 'my-entity'), 'my-group', True, True)
        with mock.patch('takeoff.azure.configure_eventhub.ConfigureEventHub.create_databricks_secrets') as databricks_call:
            victim._create_consumer_group(group)

        victim.eventhub_client.consumer_groups.create_or_update.assert_called_with('my-rg',
                                                                                   'my-namespace',
                                                                                   'my-entity',
                                                                                   'my-group')

        databricks_call.assert_called_once()
 def test_eventhub_not_exists(self, victim):
     group = EventHubConsumerGroup(EventHub('some_resource_group', 'some_namespace', 'idontexist'), 'some_group', False, False)
     with pytest.raises(ValueError):
         victim._eventhub_exists(group)
 def test_eventhub_exists(self, victim):
     hub = EventHubConsumerGroup(EventHub('some_resource_group', 'some_namespace', 'hub1'), 'some_group', False, False)
     assert victim._eventhub_exists(hub)
 def test_group_not_exists(self, victim):
     group = EventHubConsumerGroup(EventHub('some_resource_group', 'some_namespace', 'some_hub'), 'idontexist', False, False)
     assert not victim._group_exists(group)