Пример #1
0
 def test_token_used(self):
     """
     The provided token is used to connect to GitHub.
     """
     token = "my token"
     gist.postGist("reactor", token=token, files=["something"])
     self.assertEqual(self.getToken_call_count, 0)
     self.assertEqual(self.api_recorder.init_calls, [token])
Пример #2
0
 def test_getToken_by_default(self):
     """
     When no token is provided, the get token implementation is
     called to retrieve one.
     """
     gist.postGist("reactor", token="", files=["something"])
     self.assertEqual(self.getToken_call_count, 1)
     self.assertEqual(self.api_recorder.init_calls, [self.token])
Пример #3
0
 def test_stdin_gist(self):
     """
     When no files are provided, the gist is read from stdin.
     """
     gist.postGist("reactor", token=self.token, files=())
     self.assertEqual(self.gists_recorder.create_calls, [
         {
             "gistfile1": {
                 "content": self.content,
             },
         }
     ])
     self.assertEqual(self.stdin.tell(), len(self.content))
Пример #4
0
    def test_files_used(self):
        """
        The filenames provided are read and comprise the gist's content.
        """
        filename = "some file"

        gist.postGist("reactor", token=self.token, files=[filename])

        self.assertEqual(self.open_calls, [filename])
        self.assertTrue(self.open_returns.closed)

        self.assertEqual(self.gists_recorder.create_calls, [
            {
                "some file": {
                    "content": self.content,
                },
            }
        ])
Пример #5
0
    def test_response_printed(self):
        """
        The URL in the API's response is printed.
        """
        url = "https://something"
        response = gist.postGist("reactor", token=self.token, files=[])

        self.gists_recorder.create_returns.callback(
            {
                "html_url": url,
            }
        )
        self.successResultOf(response)

        self.assertEqual(self.print_calls, [(url,)])