def test_api_error(self):
        self.server.add(
            url='/user',
            params='action=getApiKey&method=PUT&username=u&password=p',
            response='{"error": "your foo went bar"}')
        with ShouldRaise(WorkfrontAPIError(u'your foo went bar', 200)):
            with OutputCapture() as output:
                main()

        output.compare("")
    def test_api_error(self):
        self.server.add(
            url='/user',
            params='action=getApiKey&method=PUT&username=u&password=p',
            response='{"error": "your foo went bar"}'
        )
        with ShouldRaise(WorkfrontAPIError(u'your foo went bar', 200)):
            with OutputCapture() as output:
                main()

        output.compare("")
    def test_functional(self):
        self.server.add(
            url='/user',
            params='action=getApiKey&method=PUT&username=u&password=p',
            response='{"data": {"result": "xyz"}}')
        with OutputCapture() as output:
            main()

        if PY2:
            expected = "Your API key is: u'xyz'"
        else:
            expected = "Your API key is: 'xyz'"
        output.compare(expected)
    def test_functional(self):
        self.server.add(
            url='/user',
            params='action=getApiKey&method=PUT&username=u&password=p',
            response='{"data": {"result": "xyz"}}'
        )
        with OutputCapture() as output:
            main()

        if PY2:
            expected="Your API key is: u'xyz'"
        else:
            expected="Your API key is: 'xyz'"
        output.compare(expected)