def test_logger_formatter_includes_timestamp(self): logger = logger_for_module("something") logger.warning("SPAM ho!") expect(self.last_message()).to(start_with("%d-" % datetime.now().year))
def test_filename_starts_with_artifact_group(self): group = "782a" kind = "raspberry" publish_artifact(artifact_group=group, artifact_type=kind) run_id, _, suite, test, name = self.extract_key_parts() expect(name).to(start_with("%s-%s" % (group, kind)))
def test_filename_starts_with_artifact_group(self): group = "782a" kind = "raspberry" publish(artifact_group=group, artifact_type=kind) path, name = os.path.split(self.fake_file.filename) expect(name).to(start_with("%s-%s" % (group, kind)))
def the_html_has_the_expected_title(katamari): expect(katamari.response.status_code).to(equal(HTTPStatus.OK)) expect(katamari.data).to(start_with("<!doctype html>")) expect(katamari.soup.title.string).to(equal(TITLE)) expect(katamari.data).to(end_with("</html>")) return
def it_outputs_the_help_message(katamari): expect(katamari.result.output).to(start_with("Usage")) return
with context('and pod exists'): with it('returns true'): expect(self.kubernetes_client.exists_pod('nginx')).to(be_true) with context('and pod does not exist'): with it('returns false'): self.kubernetes_client.delete_pod('nginx') expect(self.kubernetes_client.exists_pod('nginx')).to(be_false) with it('finds node running pod'): self._create_nginx_pod() node = self.kubernetes_client.find_node_running_pod('nginx') expect(node).to(start_with('gke-sysdig-work-default-pool')) with it('taints node'): self._create_nginx_pod() node_name = self.kubernetes_client.find_node_running_pod('nginx') node = self.kubernetes_client.taint_node(node_name, 'playbooks', 'true', 'NoSchedule') expect(node.spec.taints[0].effect).to(equal('NoSchedule')) expect(node.spec.taints[0].key).to(equal('playbooks')) expect(node.spec.taints[0].value).to(equal('true')) with it('adds label to a pod'): self._create_nginx_pod()
expect(call).to(be_successful_api_call) with context("when it's created with an incorrect scope"): with it("fails if the scope is not a string"): ok, res = self.client.create_dashboard_from_template(dashboard_name=f"{_DASHBOARD_NAME}_2", template=self.test_dashboard, scope={}) expect(ok).to(be_false) expect(res).to(equal("Invalid scope format: Expected a string")) with it("fails if the scope has incorrect format"): ok, res = self.client.create_dashboard_from_template(dashboard_name=f"{_DASHBOARD_NAME}_2", template=self.test_dashboard, scope="foobarbaz") expect(ok).to(be_false) expect(res).to(start_with("invalid scope: foobarbaz")) with it("is able to create a dashboard from a configuration"): self.test_dashboard["name"] = f"{_DASHBOARD_NAME}_2" call = self.client.create_dashboard_with_configuration(self.test_dashboard) expect(call).to(be_successful_api_call) with context("when creating a dashboard from other dashboard"): with it("creates the dashboard correctly if the template exists"): ok, res = self.client.create_dashboard_from_dashboard(newdashname=f"{_DASHBOARD_NAME}_2", templatename=_DASHBOARD_NAME, filter=None) expect((ok, res)).to(be_successful_api_call) with it("returns an error saying the dashboard does not exist"): ok, res = self.client.create_dashboard_from_dashboard(newdashname=f"{_DASHBOARD_NAME}_2",
"displayName": "", "isVariable": False, "operand": "agent.id", "operator": "startsWith", "value": ["foo"] }]])) with it("returns ok, but empty if scope is None"): res = convert_scope_string_to_expression(None) expect(res).to(equal([True, []])) with it("returns error when parsing incorrect: agent.id starts with [foo, bar]"): param = "agent.id starts with [foo, bar]" ok, res = convert_scope_string_to_expression(param) expect(ok).to(be_false) expect(res).to(start_with(f"invalid scope: {param}")) with it("returns error when parsing incorrect: agent.id is [foo, bar]"): param = "agent.id is [foo, bar]" ok, res = convert_scope_string_to_expression(param) expect(ok).to(be_false) expect(res).to(start_with(f"invalid scope: {param}")) with it("returns error when parsing incorrect: agent.id contains [foo, bar]"): param = "agent.id contains [foo, bar]" ok, res = convert_scope_string_to_expression(param) expect(ok).to(be_false) expect(res).to(start_with(f"invalid scope: {param}")) with it("returns error when parsing incorrect: agent.id"): param = "agent.id"
def the_packets_command_outputs_a_help_string(katamari): expect(katamari.result.exit_code).to(equal(ExitCode.okay)) expect(katamari.result.output).to(start_with("Usage:")) return