def it_prints_help_when_there_is_no_data(self, stdout, Data): Data.return_value.is_empty.return_value = True cli = CLI() cli.start([]) assert "Usage:" in stdout.getvalue()
def it_lists_all_keys_when_there_is_data(self, stdout, Data): Data.return_value.is_empty.return_value = False Data.return_value.list.return_value = {"foo": "bar", "asdf": "fdsa"} cli = CLI() cli.start([]) assert " foo: bar\nasdf: fdsa\n" == stdout.getvalue()
def it_gets_keys(self, Data): cli = CLI() cli.start(["foo"]) Data.return_value.get.assert_called_with("foo")
def it_deletes_keys(self, Data): cli = CLI() cli.start(["-d", "foo"]) Data.return_value.delete.assert_called_with("foo")
def it_lists_all_keys_when_there_is_data(self, stdout, Data): Data.return_value.is_empty.return_value = False Data.return_value.list.return_value = {'foo': 'bar', 'asdf': 'fdsa'} cli = CLI() cli.start([]) assert ' foo: bar\nasdf: fdsa\n' == stdout.getvalue()
def it_deletes_keys(self, Data): cli = CLI() cli.start(['-d', 'foo']) Data.return_value.delete.assert_called_with('foo')
def it_gets_keys(self, Data): cli = CLI() cli.start(['foo']) Data.return_value.get.assert_called_with('foo')
def it_has_a_data_attribute(self, Data): assert CLI().data is not None