Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_essential_parameters_ng(self):
"""
EssentialParameters invalid case
"""
with pytest.raises(CliboaException) as excinfo:
valid = EssentialParameters("DummyClass", [""])
valid()
assert "is not specified" in str(excinfo.value)
def _csv_quote(self):
if "QUOTE_ALL" == self._quote:
return csv.QUOTE_ALL
elif "QUOTE_MINIMAL" == self._quote:
return csv.QUOTE_MINIMAL
elif "QUOTE_NONNUMERIC" == self._quote:
return csv.QUOTE_NONNUMERIC
elif "QUOTE_NONE" == self._quote:
return csv.QUOTE_NONE
else:
raise CliboaException(
"Unknown quote. One of the followings are allowd [QUOTE_ALL, QUOTE_MINIMAL, QUOTE_NONNUMERIC, QUOTE_NONE]"
)
def _csv_delimiter(self, ext):
if ext.upper() == "CSV":
return ","
elif ext.upper() == "TSV":
return "\t"
else:
raise CliboaException(
"Unknown ext. One of the followings are allowd [CSV, TSV]"
)
class FileNotFound(CliboaException):
# Exception when specified file not found
pass
class InvalidFileCount(CliboaException):
# Exception when many files exist more than expacted
pass
class InvalidParameter(CliboaException):
# Exception when parameters are invalid
pass
class InvalidCount(CliboaException):
# Exception when invalid count was specified
pass
class InvalidFormat(CliboaException):
# Exception when invalid format was specified
pass
class ScenarioFileInvalid(CliboaException):
# Exception when scenario.yml(json) is invalid
pass
class StepExecutionFailed(CliboaException):
# Exception when step execution was failed
def execute(self, *args):
input_valid = IOInput(self._io)
input_valid()
files = glob(self._src_path)
if len(files) > 1:
raise CliboaException("Input file must be only one.")
if len(files) == 0:
raise FileNotFound("The specified csv file not found.")
with open(files[0], "r", encoding=self._encoding) as f:
# save per one column
if self._columns:
reader = csv.DictReader(f, delimiter=",")
for row in reader:
# extract only the specified columns
row_dict = {}
for c in self._columns:
if not row.get(c):
continue
row_dict[c] = row.get(c)
class InvalidCount(CliboaException):
# Exception when invalid count was specified
pass
class InvalidFormat(CliboaException):
# Exception when invalid format was specified
pass
class ScenarioFileInvalid(CliboaException):
# Exception when scenario.yml(json) is invalid
pass
class StepExecutionFailed(CliboaException):
# Exception when step execution was failed
pass
class SqliteInvalid(CliboaException):
# Exception when specified file not found
pass
class InvalidFileCount(CliboaException):
# Exception when many files exist more than expacted
pass
class InvalidParameter(CliboaException):
# Exception when parameters are invalid
pass
class InvalidCount(CliboaException):
# Exception when invalid count was specified
pass
class InvalidFormat(CliboaException):
# Exception when invalid format was specified
pass
class ScenarioFileInvalid(CliboaException):
# Exception when scenario.yml(json) is invalid
pass
class StepExecutionFailed(CliboaException):
# Exception when step execution was failed
pass
class SqliteInvalid(CliboaException):
# Exception when specified file not found
class CliboaException(Exception):
# cliboa unique exception
pass
class DirStructureInvalid(CliboaException):
# Exception when directory structure invalid
pass
class FileNotFound(CliboaException):
# Exception when specified file not found
pass
class InvalidFileCount(CliboaException):
# Exception when many files exist more than expacted
pass
class InvalidParameter(CliboaException):
# Exception when parameters are invalid
pass
class InvalidCount(CliboaException):
# Exception when invalid count was specified
pass
class InvalidFormat(CliboaException):
# Exception when invalid format was specified
class DirStructureInvalid(CliboaException):
# Exception when directory structure invalid
pass
class FileNotFound(CliboaException):
# Exception when specified file not found
pass
class InvalidFileCount(CliboaException):
# Exception when many files exist more than expacted
pass
class InvalidParameter(CliboaException):
# Exception when parameters are invalid
pass
class InvalidCount(CliboaException):
# Exception when invalid count was specified
pass
class InvalidFormat(CliboaException):
# Exception when invalid format was specified
pass
class ScenarioFileInvalid(CliboaException):
# Exception when scenario.yml(json) is invalid