~nskaggs/juju-ci-tools/update-templates

« back to all changes in this revision

Viewing changes to template_assess.py.tmpl

  • Committer: Nicholas Skaggs
  • Date: 2016-04-01 00:52:23 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20160401005223-xbj6hq3w5nhkk4i2
wip, fix unit tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
log = logging.getLogger("assess_TEMPLATE")
23
23
 
24
 
def make_charm(charm_dir, name='dummy'):
 
24
def make_charm(charm_dir, name='dummy', summary='summary', description='description', series=['xenial'], min_juju_version='2.0'):
25
25
    metadata = os.path.join(charm_dir, 'metadata.yaml')
26
26
    content = {}
27
27
    content['name'] = name
28
 
    content['summary'] = 'summary'
29
 
    content['description'] = 'description'
30
 
    content['series'] = ['xenial']
 
28
    content['summary'] = summary
 
29
    content['description'] = description
 
30
    content['min-juju-version'] = min_juju_version
 
31
    content['series'] = series
31
32
    with open(metadata, 'w') as f:
32
33
        yaml.dump(content, f, default_flow_style=False)
33
34
        
35
36
    current = client.get_version(juju_path=juju_path).split('-')[:-2]
36
37
    return '-'.join(current)
37
38
 
38
 
def assess_TEMPLATE(client):
 
39
def assess_TEMPLATE(client, args):
39
40
        # Deploy charms, there are several under ./repository
40
41
        if get_current_version(client, args.juju_bin).startswith('1.'):
41
 
                log.info("Testing TEMPLATE {}".format(ver))
 
42
                log.info("Testing TEMPLATE")
42
43
                charm_name = 'dummy'
43
44
                make_charm(charm_dir, charm_name)
44
45
                client.deploy('local:' + charm_name)
48
49
                # TODO: Add specific functional testing actions here.
49
50
        else:
50
51
                with temp_dir() as charm_dir:
51
 
                        log.info("Testing TEMPLATE {}".format(ver))
 
52
                        log.info("Testing TEMPLATE")
52
53
                        make_charm(charm_dir)
53
54
                        client.deploy(charm)
54
55
                        # Wait for the deployment to finish.
69
70
    configure_logging(args.verbose)
70
71
    bs_manager = BootstrapManager.from_args(args)
71
72
    with bs_manager.booted_context(args.upload_tools):
72
 
        assess_TEMPLATE(bs_manager.client)
 
73
        assess_TEMPLATE(bs_manager.client, args)
73
74
    return 0
74
75
 
75
76
if __name__ == '__main__':