def test_invalid_key_suffix(self):
     self.assertRaises(
         ValueError,
         lambda:
         ExporterOptions(instrumentation_key=
                         "1234abcd-5678-4efa-8abc-1234567890abtest"),
     )
 def test_parse_connection_string_suffix(self):
     options = ExporterOptions(
         connection_string=
         "Authorization=ikey;EndpointSuffix=123;Location=US",
         instrumentation_key=self._valid_instrumentation_key,
     )
     self.assertEqual(options.endpoint, "https://US.dc.123/v2/track")
 def test_process_options_ikey_env_ikey(self):
     os.environ[
         "APPINSIGHTS_INSTRUMENTATIONKEY"] = self._valid_instrumentation_key
     options = ExporterOptions(connection_string=None,
                               instrumentation_key=None)
     self.assertEqual(options.instrumentation_key,
                      self._valid_instrumentation_key)
 def test_process_options_endpoint_default(self):
     options = ExporterOptions(
         connection_string=None,
         instrumentation_key=self._valid_instrumentation_key,
     )
     self.assertEqual(options.endpoint,
                      "https://dc.services.visualstudio.com/v2/track")
 def test_process_options_proxies_set_proxies(self):
     options = ExporterOptions(
         connection_string=None,
         instrumentation_key=self._valid_instrumentation_key,
         proxies={"https": "https://test-proxy.com"},
     )
     self.assertEqual(options.proxies, {"https": "https://test-proxy.com"})
 def test_process_options_proxies_default(self):
     options = ExporterOptions(
         connection_string=None,
         instrumentation_key=self._valid_instrumentation_key,
         proxies={},
     )
     self.assertEqual(options.proxies, {})
 def test_parse_connection_string_invalid_auth(self):
     self.assertRaises(
         ValueError,
         lambda: ExporterOptions(
             connection_string="Authorization=asd",
             instrumentation_key=self._valid_instrumentation_key,
         ),
     )
 def test_process_options_endpoint_env_cs(self):
     os.environ[
         "APPLICATIONINSIGHTS_CONNECTION_STRING"] = "Authorization=ikey;IngestionEndpoint=456"
     options = ExporterOptions(
         connection_string=None,
         instrumentation_key=self._valid_instrumentation_key,
     )
     self.assertEqual(options.endpoint, "456/v2/track")
 def __init__(self, **options):
     self._telemetry_processors = []
     self.options = ExporterOptions(**options)
     self.storage = LocalFileStorage(
         path=self.options.storage_path,
         max_size=self.options.storage_max_size,
         maintenance_period=self.options.storage_maintenance_period,
         retention_period=self.options.storage_retention_period,
     )
 def test_process_options_ikey_env_cs(self):
     os.environ["APPLICATIONINSIGHTS_CONNECTION_STRING"] = (
         "Authorization=ikey;InstrumentationKey=" +
         self._valid_instrumentation_key)
     os.environ["APPINSIGHTS_INSTRUMENTATIONKEY"] = "101112"
     options = ExporterOptions(connection_string=None,
                               instrumentation_key=None)
     self.assertEqual(options.instrumentation_key,
                      self._valid_instrumentation_key)
 def test_invalid_key_section5_length(self):
     self.assertRaises(
         ValueError,
         lambda: ExporterOptions(instrumentation_key=
                                 "234abcd-678-4efa-8abc-11234567890ab"),
     )
 def test_invalid_key_empty(self):
     self.assertRaises(ValueError,
                       lambda: ExporterOptions(instrumentation_key=""))
 def test_parse_connection_string_invalid(self):
     self.assertRaises(ValueError,
                       lambda: ExporterOptions(connection_string="asd"))
 def test_validate_instrumentation_key(self):
     options = ExporterOptions(
         instrumentation_key=self._valid_instrumentation_key)
     self.assertEqual(options.instrumentation_key,
                      self._valid_instrumentation_key)