def test_flush(self, mocker): """Test the Telemetry.flush method.""" # Setup Test tst_tele = Telemetry(True) tst_tele._telemetry_client.flush = mocker.MagicMock() # Call Function tst_tele.flush() # Assert Results tst_tele._telemetry_client.flush.assert_called_once() # Delete Telemetry Instance del tst_tele
def test_track_event(self, mocker, tst_event_name, tst_event_props, tst_event_meas): """Test the Telemetry.track_event method.""" # Setup Test tst_tele = Telemetry(True) tst_tele._telemetry_client.track_event = mocker.MagicMock() # Call Function tst_tele.track_event(tst_event_name, tst_event_props, tst_event_meas) # Assert Results tst_tele._telemetry_client.track_event.assert_called_with(tst_event_name, tst_event_props, tst_event_meas) # Delete Telemetry Instance del tst_tele
def test_track_metric(self, mocker, tst_name, tst_value, tst_type, tst_count, tst_min, tst_max, tst_std_dev, tst_properties): """Test the Telemetry.track_metric method.""" # Setup Test tst_tele = Telemetry(True) tst_tele._telemetry_client.track_metric = mocker.MagicMock() # Call Function tst_tele.track_metric(tst_name, tst_value, tst_type, tst_count, tst_min, tst_max, tst_std_dev, tst_properties) # Assert Results tst_tele._telemetry_client.track_metric.assert_called_with(tst_name, tst_value, tst_type, tst_count, tst_min, tst_max, tst_std_dev, tst_properties) # Delete Telemetry Instance del tst_tele
def test_init(self, mocker, tst_toggle): """Test the Telemetry.__init__ method.""" # Setup Test # Call Function tst_tele = Telemetry(tst_toggle) # Assert Results if tst_toggle: assert tst_tele._telemetry_client is not None assert tst_tele._telemetry_channel is not None else: assert tst_tele._telemetry_channel is None assert tst_tele._telemetry_client is None # Delete Telemetry Instance del tst_tele
def test_get_matches(self, mocker): """Test the _get_matches method.""" # Setup, mock, etc. tst_hld_generator = HLD_Generator(self.tst_args) tst_cc = [Component("Test-Component")] mock_matcher = mocker.patch.object(tst_hld_generator, 'matcher') mock_matcher.match_components = mocker.MagicMock() test_telemetry = Telemetry(True) # Call function tst_hld_generator._get_matches(tst_cc) # Assert results mock_matcher.match_components.assert_called_once() # Delete Telemetry Instance del test_telemetry
def test_get_component_definitions(self, mocker): """Test the _get_component_definitions method.""" # Setup, mock, etc. tst_hld_generator = HLD_Generator(self.tst_args) mock_scraper = mocker.patch(f'{self.MODULE}.Scraper') mock_scraper.return_value.get_repo_components = mocker.MagicMock() test_telemetry = Telemetry(True) # Call function tst_hld_generator._get_component_definitions() # Assert results mock_scraper.assert_called_once() mock_scraper.return_value.get_repo_components.assert_called_once() # Delete Telemetry Instance del test_telemetry
def test_get_cluster_components(self, mocker): """Test the _get_cluster_components method.""" # Setup, mock, etc. tst_hld_generator = HLD_Generator(self.tst_args) mock_cluster = mocker.patch.object(tst_hld_generator, 'cluster') mock_cluster.connect_to_cluster = mocker.MagicMock() mock_cluster.get_components = mocker.MagicMock() test_telemetry = Telemetry(True) # Call function tst_hld_generator._get_cluster_components() # Assert results mock_cluster.connect_to_cluster.assert_called_once() mock_cluster.get_components.assert_called_once() # Delete Telemetry Instance del test_telemetry
def test_generate_HLD(self, mocker, tst_args): """Test the _generate_HLD method.""" # Setup, mock, etc. tst_hld_generator = HLD_Generator(tst_args) tst_data = "test-data" tst_match_categories = ["full", "partial", "none"] mock_stdout = mocker.patch(f'{self.MODULE}.stdout') mock_set_subcomponents = mocker.patch( f'{self.CLASS}._set_subcomponents', return_value=tst_data) mock_dump_yaml = mocker.patch(f'{self.CLASS}.dump_yaml', return_value=None) test_telemetry = Telemetry(True) # Call function tst_hld_generator._generate_HLD(tst_match_categories) # Assert results mock_set_subcomponents.assert_called() if tst_args.dry_run: mock_dump_yaml.assert_called_with(tst_data, mock_stdout) mock_dump_yaml.assert_called_once() # Delete Telemetry Instance del test_telemetry