def test_next(self): datafile = 'examples/data/colors.txt' seed_value = 123 r = RanCat(seed=seed_value) r.load(datafile) value = r.next() assert isinstance(value, str)
def test_read_size_option(self): datafile = 'examples/data/colors.txt' seed_value = 123 r = RanCat(seed=seed_value) r.set_read_size(2) r.load(datafile) r._refresh_all(r._read_size) assert len(r.files[datafile].current_lines) == 2
def test_duplicate_file_allowed(self): datafile = 'examples/data/colors.txt' seed_value = 123 r = RanCat(seed=seed_value) r.load(datafile).load(datafile).load(datafile) result = r.next() result = result.split('_') assert len(result) == 3
def test_iterable(self): datafile = 'examples/data/colors.txt' seed_value = 123 r = RanCat(seed=seed_value) r.load(datafile) i = [] for x in r: i.append(x) break assert i != []
def test_unique_option(self): datafile = 'examples/data/colors.txt' seed_value = 123 r = RanCat(seed=seed_value) r.set_unique(True) r.load(datafile) i = [] for x in r: i.append(x) assert i != [] assert len(i) == r._total_combinations
def test_hard_reset(self): datafile = 'examples/data/colors.txt' seed_value = 123 r = RanCat(seed=seed_value, unique=True) r.load(datafile).load(datafile) i = [] for x in r: i.append(x) assert i != [] assert len(i) == r._total_combinations r = r.hard_reset() i = [] for x in r: i.append(x) assert i == [] assert len(r.files) == 0 assert len(i) == r._total_combinations
# Example 1 - Generate names from files from rancat import RanCat r = RanCat(seed=12335).load('examples/data/jedi.txt') r.load('examples/data/got.txt') for i in range(0, 10): print(r.next())
def test_load(self): datafile = 'examples/data/colors.txt' seed_value = 123 r = RanCat(seed=seed_value) r.load(datafile) assert len(r.files) == 1
def test_load_url(self): data_url = 'http://www.sample-videos.com/text/Sample-text-file-10kb.txt' seed_value = 123 r = RanCat(seed=seed_value) r.load(data_url) assert len(r.files) == 1