IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 22, 2019, 2:30:49 PM (7 years ago)
Author:
fairlamb
Message:

fixed calling as main + tests, removed argsparse from most

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ipp-259_genericise_backups/tools/backups/website_backup_test.py

    r40958 r40962  
    33from pathlib import Path
    44
    5 import backups.backup as bckup
    6 from backups.website_backup import WebsiteBackup
    7 from backups.utils.config_parse_helper import ConfigSchema
     5import backup as bckup
     6import website_backup as webbck_mod
     7from website_backup import WebsiteBackup
     8from utils.config_parse_helper import ConfigSchema
    89
    910WEBSITE_TEST_CONFIG = os.path.join(os.path.dirname(__file__),
     
    3132        wb = WebsiteBackup(config_file=WEBSITE_TEST_CONFIG)
    3233        self.assert_defaults(wb)
     34
     35
     36class TestFullRunFromMain(object):
     37
     38    def test_main_loads_and_runs_fine_when_given_config(self, tmpdir):
     39        config = configparser.ConfigParser()
     40        bpath1 = os.path.join(tmpdir, "path/1")
     41        bpath2 = os.path.join(tmpdir, "path/2")
     42        config['DEFAULT'] = \
     43            { 'backup_paths' :  f"{bpath1}, {bpath2}"
     44            , 'source_machine' : 'rocket'
     45            , 'verbose' : 'True'
     46            }
     47        tar_source =  os.path.join(tmpdir, "tar/source")
     48        config['TAR'] = \
     49            { 'sources' : f"{tar_source}"
     50            , 'additional_args' : "--verbose -z -p -cf"
     51            , 'target_filename' : 'svnroot.tar.gz'
     52            , 'prefix_date' : 'False'
     53            }
     54        os.makedirs(bpath1)
     55        os.makedirs(bpath2)
     56        os.makedirs(tar_source)
     57
     58        schema = ConfigSchema(None)
     59        schema.add_section(bckup.DEFAULT_SCHEMA_SECTION)
     60        schema.add_section(bckup.TAR_SCHEMA_SECTION)
     61
     62        webbck_mod.main(config, schema)
     63        assert True is True
    3364
    3465
Note: See TracChangeset for help on using the changeset viewer.