Пример #1
0
    def test_unhandled_exception_occurs(self, requests, argparse, exit_):
        requests.Session.return_value = self.session
        parser = argparse.ArgumentParser.return_value
        parser.parse_args.return_value = mock.Mock(
            config='fixtures/good_config.json')

        with self.vcr.use_cassette('good_post_request'):
            idonethis.main()

        self.assertTrue(exit_.called)
Пример #2
0
    def test_done_text_provided_in_cli(self, get_done_text, argparse, requests):
        requests.Session.return_value = self.session
        parser = argparse.ArgumentParser.return_value
        parser.parse_args.return_value = mock.Mock(
            message='I did it!',
            team='aweber-be-bof',
            token=os.environ.get('IDONETHIS_TOKEN', 'x' * 20),
            config='fixtures/good_config.json')

        with self.vcr.use_cassette('good_post_request'):
            idonethis.main()

        self.assertFalse(get_done_text.called)
Пример #3
0
    def test_no_done_text_provided_in_cli(self, requests, argparse, stdin, exit_):
        requests.Session.return_value = self.session
        parser = argparse.ArgumentParser.return_value
        parser.parse_args.return_value = mock.Mock(
            message=None,
            team='aweber-be-bof',
            token=os.environ.get('IDONETHIS_TOKEN', 'x' * 20),
            config='fixtures/good_config.json')

        stdin.isatty.return_value = False
        stdin.read.return_value = 'testing'

        with self.vcr.use_cassette('good_post_request'):
            idonethis.main()

        self.assertFalse(exit_.called)