コード例 #1
0
ファイル: main.py プロジェクト: eculicny/snowshu
def analyze(replica_file: click.Path,
            barf: bool):
    """Perform a "dry run" of the replica creation without actually executing, and return the expected results."""

    replica = ReplicaFactory()
    replica.load_config(replica_file)
    click.echo(replica.analyze(barf))
コード例 #2
0
ファイル: main.py プロジェクト: ankur112358/snowshu
def create(replica_file: click.Path,
           name: str,
           barf: bool):
    """Generate a new replica from a replica.yml file.
    """
    replica = ReplicaFactory()
    replica.load_config(replica_file)
    click.echo(replica.create(name, barf))
コード例 #3
0
def test_analyze_unsampled(docker_flush):

    replica = ReplicaFactory()

    config = os.path.join(PACKAGE_ROOT, "snowshu", "templates", "replica.yml")
    replica.load_config(config)
    result = replica.analyze(barf=False).split('\n')
    result.reverse()
    for line in result:
        if "ORDERS" in line:
            assert '\x1b[0;32m100 %\x1b[0m' in line
            break
コード例 #4
0
def test_loading_specified_replica_file(tmpdir, stub_creds, stub_configs):
    """ Verify that a different named config file is loaded properly. """
    replica_file = Path(tmpdir / 'my_custom_name.yml')
    cred_file = Path(tmpdir / 'my_cred_file.yml')
    stub_creds = stub_creds()
    stub_configs = stub_configs()
    stub_configs["credpath"] = str(cred_file.absolute())

    cred_file.write_text(json.dumps(stub_creds))
    replica_file.write_text(json.dumps(stub_configs))

    replica = ReplicaFactory()
    assert not replica.config  # no config in new obj
    replica.load_config(replica_file)
    assert replica.config  # config should now be loaded
コード例 #5
0
def tests_incremental_flag(graph, stub_configs):
    graph.return_value.graph = mock.Mock()
    replica = ReplicaFactory()
    replica.load_config(stub_configs())
    test_name = rand_string(10)
    replica.incremental = rand_string(10)
    adapter = replica.config.target_profile.adapter = mock.Mock(
        spec=BaseTargetAdapter)
    result = replica.create(test_name, False)
    adapter.initialize_replica.assert_called_once_with('default',
                                                       replica.incremental)
    adapter.build_catalog.assert_called()
    assert 'image up-to-date' in result
コード例 #6
0
def tests_replica_rename(_, build_graph, get_graphs, stub_configs):
    replica = ReplicaFactory()
    replica.load_config(stub_configs())
    test_name = rand_string(10)
    replica.create(test_name, False)
    assert build_graph.call_args[0][0].name == test_name