def test_one_successful_checks_with_violations(self): table = 'customer' expected_check_cnt = 1 expected_check_rc = '0' expected_run_rc = '0' expected_violation_cnt = '9' self._add_rule_check(table, expected_check_rc, expected_violation_cnt) report, run_rc = self.run_cmd() testtooling.report_checker(report, expected_check_cnt, expected_check_rc, expected_violation_cnt) assert str(run_rc) == expected_run_rc
def test_check_env_variable_table(self): table = 'customer' expected_check_cnt = 1 expected_check_rc = '0' expected_run_rc = '0' expected_violation_cnt = '0' self._add_env_rule_check(table, key='hapinsp_table', value='customer') report, run_rc = self.run_cmd() testtooling.report_checker(report, expected_check_cnt, expected_check_rc, expected_violation_cnt) assert str(run_rc) == expected_run_rc
def test_setup_then_check(self): table = 'customer' expected_check_cnt = 2 expected_check_rc = '0' expected_run_rc = '0' expected_violation_cnt = '0' self._add_setup_check(table, key='hapinsp_tablecustom_foo', value='bar') self._add_env_rule_check(table, key='hapinsp_tablecustom_foo', value='bar') report, run_rc = self.run_cmd() print(run_rc) print(report) testtooling.report_checker(report, expected_check_cnt, expected_check_rc, expected_violation_cnt) assert str(run_rc) == expected_run_rc
def test_one_successful_check_with_no_violations(self): table = 'customer' expected_check_cnt = 1 expected_check_rc = '0' expected_run_rc = '0' expected_violation_cnt = '0' self._add_rule_check(table, expected_check_rc, expected_violation_cnt) report, run_rc = self.run_cmd() print("Report: ") pp(report) testtooling.report_checker(report, expected_check_cnt, expected_check_rc, expected_violation_cnt) assert str(run_rc) == expected_run_rc self._print_logs()
def test_get_prior_setup(self): """ """ table = 'customer' print("") print("run #1 - everything should work, defines first hapinsp_tablecustom_foo value of 'inactive'") setup_fqfn = self._add_setup_check(table, key='hapinsp_tablecustom_foo', value='inactive') check_fqfn = self._add_env_rule_check(table, key='hapinsp_tablecustom_foo', value='inactive') report, run_rc = self.run_cmd() testtooling.report_checker(report, expected_check_cnt=2, expected_check_rc=0, expected_violation_cnt=0) time.sleep(1) print("") print("run #2 - change setup & recheck") self._add_setup_check(table, key='hapinsp_tablecustom_foo', value='active', fqfn=setup_fqfn) report, run_rc = self.run_cmd() testtooling.report_checker(report, expected_check_cnt=2, expected_check_rc=0, expected_violation_cnt=1) time.sleep(1) #---------- Run #3 -------------- print("") print("run #3 - must find prior hapinsp_tablecustom_foo value of 'active'") # override setup to require prior value: self._add_setup_check(table, required_key='hapinsp_tablecustom_foo_prior', required_value='active', fqfn=setup_fqfn) report, run_rc = self.run_cmd() testtooling.report_checker(report, expected_check_cnt=2, expected_check_rc=0, expected_violation_cnt=1)