def test_should_return_content_on_valid_connection_data(self):
     # update connection.conf
     self.load_config()
     dr = DailyReport(host=self.host, port=self.port, username=self.username,
         password=self.password)
     output = dr.get_report(index_name=self.index_name)
     self.assertTrue(len(output) > 0)
    def test_should_return_empty_index_name_on_invalid_config_file(self):
        expected_index_name = None
        splunk_home = 'test_splunk'
        input_string = '%s/etc/apps/app3/local/dailyreport.conf' % splunk_home

        dr = DailyReport()
        index_name = dr.get_index_app_config(input_string)
        self.assertEquals(expected_index_name, index_name)
    def test_should_return_title(self):
        expected_title = 'email title'
        splunk_home = 'test_splunk'
        input_string = '%s/etc/apps/app1/local/dailyreport.conf' % splunk_home

        dr = DailyReport()
        nothing, output_title = dr.get_email_app_config(input_string)
        self.assertEquals(expected_title, output_title)
    def test_should_return_two_email_addresses(self):
        expected_email_addresses = ['*****@*****.**', '*****@*****.**']
        splunk_home = 'test_splunk'
        input_string = '%s/etc/apps/app1/local/dailyreport.conf' % splunk_home

        dr = DailyReport()
        emailAddresses, title = dr.get_email_app_config(input_string)
        self.assertEquals(expected_email_addresses, emailAddresses)
    def test_should_return_empty_list_on_invalid_config_file(self):
        expected_email_addresses = []
        splunk_home = 'test_splunk'
        input_string = '%s/etc/apps/app3/local/dailyreport.conf' % splunk_home

        dr = DailyReport()
        emailAddresses, title = dr.get_email_app_config(input_string)
        self.assertEquals(expected_email_addresses, emailAddresses)
 def test_should_return_app_names_with_dailyreport_config(self):
     splunk_home = 'test_splunk'
     expected_item = ['%s/etc/apps/app1/local/dailyreport.conf' % splunk_home,
                      '%s/etc/apps/app3/local/dailyreport.conf' % splunk_home,
                      '%s/etc/apps/app5/local/dailyreport.conf' % splunk_home]
     dr = DailyReport(splunk_home=splunk_home)
     apps_with_config = dr.get_apps()
     self.assertEquals(expected_item, apps_with_config)
 def run(self):
     self.load_config()
     dr = DailyReport(splunk_home=self.splunk_home,  config=self.config_file, no_email=self.no_email, debug=self.debug)
     dr.do_daily_report(filter_name=self.filter_name)
 def test_should_return_empty_list_on_wrong_splunk_home_path(self):
     expected_list = []
     dr = DailyReport()
     apps_with_config = dr.get_apps()
     self.assertEquals(expected_list, apps_with_config)
 def test_should_return_no_content_on_invalid_credentials(self):
     self.load_config()
     expected_content = ''
     dr = DailyReport(host=self.host, port=self.port, username='******', password='******')
     output = dr.get_report(index_name='lalala')
     self.assertEquals(expected_content, output)