def test_request_body(): # Arrange endpoint = "unittest.endpoint.com" port = 25 tenant_ids = ["1234-2134-1234", "1234-5678"] recipient = "recipient.com" sender = "sender.com" timeout = 20.0 ret = None with open("./tests/victoria_email/test_with_mutiple_filetypes.yaml", "r") as f: file_content = f.read() yaml_obj = yaml.load(file_content) # Act email_schema = schemas.EmailConfigSchema() ret = email_schema.load(yaml_obj) # Act req_body = { "endpoint": endpoint, "port": int(port), "tenant_ids": [str(tenant_id) for tenant_id in tenant_ids], "recipient": recipient, "sender": sender, "timeout": timeout, "load": ret.load_test.load } print(".") # Assert assert 'load' in req_body
def test_make_with_generated_random_attachment_count(): with open("./tests/victoria_email/test_with_generated_random_data.yaml", "r") as f: file_content = f.read() yaml_obj = yaml.load(file_content) # Act email_schema = schemas.EmailConfigSchema() ret = email_schema.load(yaml_obj) assert len(ret.load_test.load.attachment_count) == 5
def test_make_config_multiple_tenants(): # Arrange with open("./tests/victoria_email/test_multi_tenant.yaml", "r") as f: file_content = f.read() yaml_obj = yaml.load(file_content) # Act email_schema = schemas.EmailConfigSchema() ret = email_schema.load(yaml_obj) # Assert assert len(ret.load_test.tenant_ids) == 2
def test_make_config_with_load_config(): # Arrange with open("./tests/victoria_email/test_with_mutiple_filetypes.yaml", "r") as f: file_content = f.read() yaml_obj = yaml.load(file_content) # Act email_schema = schemas.EmailConfigSchema() ret = email_schema.load(yaml_obj) # Assert assert len(ret.load_test.load.attachment_count) == 3
def test_loadtest_cli_without_args(): runner = CliRunner() with open("./tests/victoria_email/test_with_generated_random_data.yaml", "r") as f: file_content = f.read() yaml_obj = yaml.load(file_content) email_schema = schemas.EmailConfigSchema() config = email_schema.load(yaml_obj) args = ['-e', '0.0.0.0'] result = runner.invoke(loadtest, args, obj=config) assert result.exit_code == 0
def test_make_config_single_tenant(): # Arrange with open("./tests/victoria_email/test_single_tenant.yaml", "r") as f: file_content = f.read() yaml_obj = yaml.load(file_content) # Act email_schema = schemas.EmailConfigSchema() ret = email_schema.load(yaml_obj) # Assert assert str(ret.load_test.tenant_ids[0] ) == "973037a8-eb2c-4637-9e6e-fd2bb1cf0e58" assert len(ret.load_test.tenant_ids) == 1
def test_loadtest_cli_with_args(): runner = CliRunner() with open("./tests/victoria_email/test_with_mutiple_filetypes.yaml", "r") as f: file_content = f.read() yaml_obj = yaml.load(file_content) email_schema = schemas.EmailConfigSchema() config = email_schema.load(yaml_obj) args = [ '-e', '0.0.0.0', '-s', '*****@*****.**', '-r', '*****@*****.**' ] result = runner.invoke(loadtest, args, obj=config) assert result.exit_code == 0