def test_sorted(): for n in range(1, 3): for conditions in (CONDITIONS_3, CONDITIONS_6): for sort in ('both', 'ascending', 'descending'): o = Sorted(n, order=sort) o.first_pass(conditions) yield check_sorted, o, len(conditions) for conditions in (CONDITIONS_2_2, CONDITIONS_2_3, CONDITIONS_2_3_2): with pytest.raises(ValueError): o = Sorted() o.first_pass(conditions)
def test_design_from_spec(): spec = { 'name': 'test1', 'order': 'Shuffle', 'n': 2, 'ivs': { 'a': [True, False], 'b': [1, 2, 3] }, } assert Design.from_dict(spec) == ('test1', Design( { 'a': [True, False], 'b': [1, 2, 3] }, ordering=Shuffle(2))) spec = { 'name': 'test2', 'some_extra_field': ['blah'], 'number': 3, } assert Design.from_dict(spec) == ('test2', Design(extra_data={ 'some_extra_field': ['blah'] }, ordering=Shuffle(3))) spec = { 'name': 'test3', 'ordering': { 'class': 'Sorted', 'order': 'ascending', }, 'ivs': { 'a': [1, 2, 3] }, } assert Design.from_dict(spec) == ('test3', Design( ivs={'a': [1, 2, 3]}, ordering=Sorted(order='ascending'))) spec = { 'name': 'test4', 'order': ['CompleteCounterbalance', 3], } assert Design.from_dict(spec) == ('test4', Design( ordering=CompleteCounterbalance(3))) spec.pop('name') assert Design.from_dict(spec) == Design(ordering=CompleteCounterbalance(3))
def test_schema_dict(): spec = { 'name': 'sorted', 'order': 'both', } assert OrderSchema.from_any(spec) == Sorted(order='both')
def test_reprs(): for ord in (CompleteCounterbalance(), Shuffle(), LatinSquare(), Ordering(), Sorted()): yield check_repr, ord
def test_sorted_generator_condition(): n = 2 for sort in ('both', 'ascending', 'descending'): o = Sorted(n, order=sort) o.first_pass(c for c in CONDITIONS_3) yield check_sorted, o, len(CONDITIONS_3)