def sync(info, data): """ Sync Jumpcloud with a data file """ click.echo("Sync data on jumpcloud with data in " + data) users = get_users_from_file(data) groups = get_groups_from_file(data) if users is None: raise MissingRequiredArgumentError("A sync requires a config file") sync_users(info.key, users)
def sync(ctx, dry_run, data): # pylint: disable-msg=too-many-locals # pylint: disable-msg=too-many-branches """ Sync Jumpcloud with a data file """ if dry_run: LOGGER.setLevel(logging.DEBUG) LOGGER.debug("--- sync groups ----") groups = jccli_helpers.get_groups_from_file(data) sync_groups(ctx, groups) LOGGER.debug("--- sync users ----") users = jccli_helpers.get_users_from_file(data) sync_users(ctx, users)
def test_get_groups_from_file_no_groups_in_data(self): users = jccli_helpers.get_groups_from_file(TEST_DATA_PATH+"test_data_no_groups.json") assert (len(users) == 0), "Invalid number of groups"
def test_get_groups_from_file_no_file(self): with pytest.raises(FileNotFoundError): users = jccli_helpers.get_groups_from_file(TEST_DATA_PATH+"invalid.json")
def test_get_groups_from_yaml_file_groups_in_data(self): users = jccli_helpers.get_groups_from_file(TEST_DATA_PATH+"test_data.yaml") assert (len(users) == 4), "Invalid number of groups"