def test_r_package_usage_from_custom_script(self): import r_index_logging r_index_logging.clear_log_entries() service = Service([ Stanza('package://race', {}), Stanza('package://boot', {}) ]) scriptlib.add(service, 'test', """ library(race) add <- function(a,b) { c = a+b return(c) } result = add(4,10) output = data.frame(Result=c(result)) """) _, rows = r(service, None, 'test.r') indexed_events = r_index_logging.get_log_entries() def is_indexed(text): for e in indexed_events: if text in e: return True return False self.assertTrue(is_indexed('action=\"package_usage\"')) self.assertTrue(is_indexed('package_name=\"race\"'))
def test_r_package_usage(self): import r_index_logging r_index_logging.clear_log_entries() service = Service([ Stanza('package://race', {}), Stanza('package://boot', {}) ]) _, rows = r(service, None, ''' library(race) library(boot) library(race) output = data.frame(h1=c('v1')) ''') indexed_events = r_index_logging.get_log_entries() def is_indexed(text): for e in indexed_events: if text in e: return True return False self.assertTrue(is_indexed('action=\"package_usage\"')) self.assertTrue(is_indexed('package_name=\"race\"')) self.assertTrue(is_indexed('action=\"package_usage\"')) self.assertTrue(is_indexed('package_name=\"boot\"'))
def test_get_r_config_file(self): import r_index_logging r_index_logging.clear_log_entries() r_index_logging.log(__file__, {'f1': 'v1'}) log_entries = r_index_logging.get_log_entries() self.assertEqual(len(log_entries), 1) self.assertTrue('f1=\"v1\"' in log_entries[0])
def test_get_r_config_file(self): import r_index_logging r_index_logging.clear_log_entries() r_index_logging.log(__file__, { 'f1': 'v1' }) log_entries = r_index_logging.get_log_entries() self.assertEqual(len(log_entries), 1) self.assertTrue('f1=\"v1\"' in log_entries[0])
def test_get_r_config_file(self): r_index_logging.clear_log_entries() service = Service() r_packages.add(service, 'boot') r_stats.r_stats(service) indexed_events = r_index_logging.get_log_entries() self.assertEqual(len(indexed_events), 2) self.assertTrue('stats_package_name=\"boot\"' in indexed_events[0]) self.assertTrue('stats_number_of_packages=\"1\"' in indexed_events[1])
def test_get_r_config_file(self): r_index_logging.clear_log_entries() service = Service() r_packages.add(service,'boot') r_stats.r_stats(service) indexed_events = r_index_logging.get_log_entries() self.assertEqual(len(indexed_events), 2) self.assertTrue('stats_package_name=\"boot\"' in indexed_events[0]) self.assertTrue('stats_number_of_packages=\"1\"' in indexed_events[1])