def test_set(): setknob = Knob('KNOB_NAME', 'KNOB_VAL') assert setknob.get_type() == str assert setknob.get() == 'KNOB_VAL' setknob.set('XX123') assert setknob.get() == 'XX123'
def test_typle_from_env(): os.environ['TUPLE'] = 'DEAD BEEF COFFEE' assert type(os.environ['TUPLE']) == str knob = Knob('LIST', ('LOVE', 'THEY', 'NEIGHBOUR')) assert knob.get_type() == tuple assert knob() == ('DEAD', 'BEEF', 'COFFEE')
def test_cast_to_string(): rope = Knob('ROPE_TO_HANG_BY', 'A stiff rope for yer nek, mate') assert rope.get_type() == str
def test_list_from_env(): os.environ['LIST'] = 'DEAD BEEF COFFEE' assert type(os.environ['LIST']) == str knob = Knob('LIST', ['LOVE', 'THEY', 'NEIGHBOUR']) assert knob.get_type() == list assert knob() == ['DEAD', 'BEEF', 'COFFEE']