Ejemplo n.º 1
0
 def testEventStreamsPassword(self):
     try:
         test = EventStreamsServiceBindingCredentials(api_key=1,
                                                      kafka_admin_url=1,
                                                      kafka_brokers_sasl=1,
                                                      user=1,
                                                      password=1)
         test.password()
         assert False == True
     except:
         assert True
Ejemplo n.º 2
0
    def testCreateService2(self):
        serviceBinding = EventStreamsServiceBindingCreateRequest(
            name="test-eventstreams",
            description="Test EventStreams instance",
            credentials=EventStreamsServiceBindingCredentials(
                api_key=self.EVENTSTREAMS_API_KEY,
                user=self.EVENTSTREAMS_USER,
                password=self.EVENTSTREAMS_PASSWORD,
                kafka_admin_url=self.EVENTSTREAMS_ADMIN_URL,
                kafka_brokers_sasl=[
                    self.EVENTSTREAMS_BROKER1,
                    self.EVENTSTREAMS_BROKER2,
                    self.EVENTSTREAMS_BROKER3,
                    self.EVENTSTREAMS_BROKER4,
                    self.EVENTSTREAMS_BROKER5,
                ],
            ),
        )

        createdService = self.appClient.serviceBindings.create(serviceBinding)

        assert createdService.name, "test-eventstreams"
        assert createdService.bindingMode, "manual"
        assert createdService.bindingType, "eventstreams"
        assert createdService.description, "Test EventStreams instance"
        assert isinstance(createdService.created, datetime)
        assert isinstance(createdService.updated, datetime)

        createdConnector = self.appClient.dsc.create(
            name="test-connector-eventstreams",
            type="eventstreams",
            serviceId=createdService.id,
            timezone="UTC",
            description="A test connector",
            enabled=True,
        )

        assert isinstance(createdConnector.created, datetime)
        assert "A test connector" == createdConnector.description
        assert createdService.id == createdConnector.serviceId
        assert "eventstreams" == createdConnector.connectorType
        assert isinstance(createdConnector.updated, datetime)
        assert "test-connector-eventstreams" == createdConnector.name
        assert False == createdConnector.adminDisabled
        assert True == createdConnector.enabled
        assert self.WIOTP_API_KEY == createdConnector.updatedBy
        assert self.WIOTP_API_KEY == createdConnector.createdBy
        assert "UTC" == createdConnector.timezone
        assert None == createdConnector.configuration

        with pytest.raises(ApiException) as e:
            del self.appClient.serviceBindings[createdService.id]
            # You should not be able to delete this binding as there is a connector associated with it
            assert "CUDSS0021E" == e.value.id

        del self.appClient.dsc[createdConnector.id]
        del self.appClient.serviceBindings[createdService.id]
Ejemplo n.º 3
0
 def testEventStreamsServiceBindingParametersNone(self):
     with pytest.raises(Exception) as e:
         EventStreamsServiceBindingCredentials()
         assert (
             "api_key, kakfa_admin_url, host, port, username, & password are required parameters for a Cloudant Service Binding: "
             in str(e.value))