Integration
from random import random
from semver import VersionInfo
from typing import List, Optional
from pulumi import Config, export
from pulumi.automation import (
create_stack,
create_or_select_stack,
CommandError,
ConfigMap,
ConfigValue,
EngineEvent,
InvalidVersionError,
LocalWorkspace,
LocalWorkspaceOptions,
OpType,
PluginInfo,
ProjectSettings,
StackSummary,
Stack,
StackSettings,
StackAlreadyExistsError,
fully_qualified_stack_name,
)
from pulumi.automation._local_workspace import _validate_pulumi_version
extensions = ["json", "yaml", "yml"]
version_tests = [
("100.0.0", True, False),
("1.0.0", True, False),
("2.22.0", False, False),
("2.1.0", True, False),
("2.21.2", False, False),
("2.21.1", False, False),
("2.21.0", True, False),
# Note that prerelease < release so this case will error
("2.21.1-alpha.1234", True, False),
# Test opting out of version check
("2.20.0", False, True),
("2.22.0", False, True)
]
test_min_version = VersionInfo.parse("2.21.1")
def test_path(*paths):
return os.path.join(os.path.dirname(os.path.abspath(__file__)), *paths)
def get_test_org():
test_org = "pulumi-test"
env_var = os.getenv("PULUMI_TEST_ORG")
if env_var is not None:
test_org = env_var
return test_org
def pulumi_program():
config = Config()
export("exp_static", "foo")
export("exp_cfg", config.get("bar"))
export("exp_secret", config.get_secret("buzz"))
3. System test
System testni bajarishimiz uchun bizga
pip install systest
shu
kutubxonni urnatishdan boshlaymiz.
Dastur kodi :
import
logging
import
systest
LOGGER = logging.getLogger(__name__)
# Define a testcase.
class
MyTestCase
(systest.TestCase):
"""Test case description.
"""
def
__init__(
self
, name):
super
(MyTestCase,
self
).__init__()
self
.name =
"my_testcase_"
+ name
def
run
(
self
):
LOGGER.info(
"Hello!"
)
self
.assert_equal(
1
,
1
)
self
.assert_true(
1
==
1
)
self
.assert_in(
1
in
[
1
,
2
])
self
.assert_none(
None
)
with
self
.assert_raises(
RuntimeError
)
as
cm:
raise
RuntimeError
(
'foo'
)
self
.assert_equal(
str
(cm.exception),
'foo'
)
sequencer = systest.setup(
"my_sequence"
)
sequencer.run(MyTestCase(
"1"
),
(
MyTestCase(
"2"
),
[
MyTestCase(
"3"
),
MyTestCase(
"4"
)
]
),
MyTestCase(
"5"
))
sequencer.report_and_exit()
Nateja :
Name: my_testcase_5
Description:
Test case description.
Hello!
my_testcase_5: PASSED in 0 seconds
---------------------- Test summary begin ----------------------
[
my_testcase_1: PASSED in 0 seconds,
(
my_testcase_2: PASSED in 0 seconds,
[
my_testcase_3: PASSED in 0 seconds,
my_testcase_4: PASSED in 0 seconds
]
),
my_testcase_5: PASSED in 0 seconds
]
Execution time: 0.02 seconds
Result: PASSED (5 passed, 5 total)
----------------------- Test summary end -----------------------
Do'stlaringiz bilan baham: |