- Timestamp:
- Oct 22, 2019, 2:30:49 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ipp-259_genericise_backups/tools/backups/jira_backup_test.py
r40952 r40962 7 7 8 8 import backups.backup as bckup 9 import backups.jira_backup as jbck_mod 10 import backups.utils.errors as errs 11 from backups.jira_backup import JiraBackup 12 from backups.utils.errors import ValidationError 13 from backups.utils.config_parse_helper import ConfigSchema 9 import jira_backup as jbck_mod 10 from jira_backup import JiraBackup 11 from utils.errors import ValidationError 12 from utils.config_parse_helper import ConfigSchema 14 13 15 14 JIRA_TEST_CONFIG = os.path.join(os.path.dirname(__file__), './testing/jira_test.config') … … 121 120 assert not os.path.exists(default_config) 122 121 123 with pytest.raises( errs.ValidationError) as e:122 with pytest.raises(ValidationError) as e: 124 123 JiraBackup() 125 124 assert "ValidationError: Config filepath does not exist" in str(e) … … 174 173 175 174 def test_nonexistant_config_file_raises_error(self): 176 with pytest.raises( errs.ValidationError) as e:175 with pytest.raises(ValidationError) as e: 177 176 JiraBackup("not a real file path") 178 177 assert "ValidationError: Config filepath does not exist" in str(e) 179 178 180 179 def test_main_loads_default_and_fails_due_to_missing_paths(self): 181 with pytest.raises( errs.ValidationError) as e:180 with pytest.raises(ValidationError) as e: 182 181 jbck_mod.main() 183 182 assert "ValidationError: Config filepath does not exist" in str(e) 183 184 185 class TestFullRunFromMain(object): 186 187 def test_main_loads_and_runs_fine_when_given_config(self, tmpdir): 188 config = configparser.ConfigParser() 189 config.add_section("atlassian_backups") 190 bpath1 = os.path.join(tmpdir, "path/1") 191 bpath2 = os.path.join(tmpdir, "path/2") 192 config['DEFAULT'] = \ 193 { 'backup_paths' : f"{bpath1}, {bpath2}" 194 , 'source_machine' : 'rocket' 195 , 'verbose' : 'True' 196 } 197 copy_source = os.path.join(tmpdir, "copy/source") 198 jira_backup_name = JiraBackup.get_jira_backup_date_format() + "_jira_test_file.zip" 199 config['COPY'] = \ 200 { 'sources' : f'{copy_source}' 201 } 202 tar_source = os.path.join(tmpdir, "tar/source") 203 config['TAR'] = \ 204 { 'sources' : f"{tar_source}" 205 , 'additional_args' : "--verbose -z -p -cf" 206 , 'target_filename' : 'jira.tar.gz' 207 , 'prefix_date' : 'False' 208 } 209 os.makedirs(bpath1) 210 os.makedirs(bpath2) 211 os.makedirs(copy_source) 212 os.makedirs(tar_source) 213 Path(os.path.join(copy_source, jira_backup_name)).touch() 214 215 schema = ConfigSchema(None) 216 schema.add_section(bckup.DEFAULT_SCHEMA_SECTION) 217 schema.add_section(bckup.COPY_SCHEMA_SECTION) 218 schema.add_section(bckup.TAR_SCHEMA_SECTION) 219 220 jbck_mod.main(config, schema) 221 assert True is True 184 222 185 223
Note:
See TracChangeset
for help on using the changeset viewer.
