def test_CartesianData(): meta = CoreMetaData({ "identifier": "test", "structure": "test", "title": "test" }) test = CartesianData() raw = (0, 1) a = test.get_data(raw, meta) b = test.get_value(a) assert b[0] == 0 assert b[1] == 1 raw = (0, 1, -1) a = test.get_data(raw, meta) b = test.get_value(a) assert b[0] == 0 assert b[1] == 1 assert b[2] == -1 raw = (0, 1, -1, 1) with pytest.raises(ValueError): test.get_data(raw, meta)
def test_CartesianData_auto_file(tmpdir, fext): test_path = tmpdir.mkdir("sub").join("test{}".format(fext)) test_path_str = str(test_path) raws = [(0, 1), (0, 1, -1)] for raw in raws: meta = CoreMetaData({ "identifier": "test", "structure": "test", "title": "test" }) test = CartesianData() fout_factory = InterfaceFactory(AutoFileOutput) FOutCls = fout_factory(meta, test) fout = FOutCls() fout._path = test_path_str fout.data.result = test.get_data(raw, meta) fout.connect() assert len(tmpdir.listdir()) == 1 fin_factory = InterfaceFactory(AutoFileInput) FInCls = fin_factory(meta, test) fin = FInCls() fin._path = test_path_str fin.connect() result = test.get_data(fin.data.result, meta) assert result[0] == 0 assert result[1] == 1
def test_get_None(): test = CartesianData() result = test.get_value(None) assert result is None
def auto_output(self): CartesianData.auto_output(self) return