Conditions | 2 |
Total Lines | 62 |
Code Lines | 49 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | #!/usr/bin/env python |
||
65 | @pytest.mark.dependency(depends=["test_00_environment_clear"]) |
||
66 | def test_01_install(): |
||
67 | """Creates a new default instances and clears it without archiving""" |
||
68 | pytest.reset_base(unset_instance=True) |
||
69 | import os |
||
70 | import pwd |
||
71 | |||
72 | def get_username(): |
||
73 | """Return current username""" |
||
74 | return pwd.getpwuid(os.getuid())[0] |
||
75 | |||
76 | _ = pytest.run_cli(isotool, ['instance', 'create'], full_log=True) |
||
77 | _ = pytest.run_cli(isotool, ['instance', 'set', 'user', get_username()], |
||
78 | full_log=True) |
||
79 | _ = pytest.run_cli(isotool, ['environment', 'clear', '--no-archive'], full_log=True) |
||
80 | |||
81 | assert os.path.exists('/tmp/isomer-test/etc/isomer/instances/' + |
||
82 | pytest.INSTANCENAME + '.conf') |
||
83 | assert os.path.exists('/tmp/isomer-test/var/lib/isomer/' + |
||
84 | pytest.INSTANCENAME + '/green') |
||
85 | |||
86 | repo_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '../..')) |
||
87 | |||
88 | result = pytest.run_cli( |
||
89 | isotool, |
||
90 | ['environment', 'install', '--no-sudo', '--source', 'copy', |
||
91 | '--url', repo_path, '--skip-provisions', '--skip-frontend'], |
||
92 | full_log=True |
||
93 | ) |
||
94 | |||
95 | assert result.exit_code == 0 |
||
96 | |||
97 | assert os.path.exists('/tmp/isomer-test/var/lib/isomer/' + |
||
98 | pytest.INSTANCENAME + '/green') |
||
99 | assert os.path.exists('/tmp/isomer-test/var/cache/isomer/' + |
||
100 | pytest.INSTANCENAME + '/green') |
||
101 | assert os.path.exists('/tmp/isomer-test/var/local/isomer/' + |
||
102 | pytest.INSTANCENAME + '/green') |
||
103 | assert os.path.exists( |
||
104 | '/tmp/isomer-test/var/lib/isomer/' + |
||
105 | pytest.INSTANCENAME + '/green/venv/bin/python3') |
||
106 | assert os.path.exists('/tmp/isomer-test/var/lib/isomer/' + |
||
107 | pytest.INSTANCENAME + '/green/venv/bin/iso') |
||
108 | assert os.path.exists('/tmp/isomer-test/var/lib/isomer/' + |
||
109 | pytest.INSTANCENAME + '/green/repository') |
||
110 | assert os.path.exists( |
||
111 | '/tmp/isomer-test/var/lib/isomer/' + |
||
112 | pytest.INSTANCENAME + '/green/repository/frontend') |
||
113 | |||
114 | instance_configuration = load_instance(pytest.INSTANCENAME) |
||
115 | environment = instance_configuration['environments']['green'] |
||
116 | |||
117 | assert environment['installed'] is True |
||
118 | assert environment['provisioned'] is False |
||
119 | assert environment['migrated'] is True |
||
120 | assert environment['frontend'] is False |
||
121 | assert environment['tested'] is False |
||
122 | assert environment['database'] == pytest.INSTANCENAME + '_green' |
||
123 | |||
124 | if result.exit_code != 0: |
||
125 | print(result.output) |
||
126 | print("For more information on possibly failed subtasks, " |
||
127 | "consult /tmp/isomer_test_run_cli_logfile") |
||
128 |