예제 #1
0
    def test_upload_when_status_201_returned(self):
        http_adapter = FakeHttpAdapter(201)
        uploader = Uploader(http_adapter)

        response_body = uploader.upload('http://api/url', 'a1b2c3', self.asciicast)

        assert_equal(b'success!', response_body)
        assert_equal('http://api/url/api/asciicasts', http_adapter.url)
        assert_equal(self._expected_files(), http_adapter.files)
        assert_equal(self._expected_headers(), http_adapter.headers)
예제 #2
0
    def test_upload_when_status_201_returned(self):
        http_adapter = FakeHttpAdapter(201)
        uploader = Uploader(http_adapter)

        response_body = uploader.upload('http://api/url', 'a1b2c3',
                                        self.asciicast)

        assert_equal(b'success!', response_body)
        assert_equal('http://api/url/api/asciicasts', http_adapter.url)
        assert_equal(self._expected_files(), http_adapter.files)
        assert_equal(self._expected_headers(), http_adapter.headers)
예제 #3
0
 def __init__(self,
              api_url,
              api_token,
              cmd,
              title,
              skip_confirmation,
              recorder=None,
              uploader=None,
              confirmator=None):
     self.api_url = api_url
     self.api_token = api_token
     self.cmd = cmd
     self.title = title
     self.skip_confirmation = skip_confirmation
     self.recorder = recorder if recorder is not None else Recorder()
     self.uploader = uploader if uploader is not None else Uploader()
     self.confirmator = confirmator if confirmator is not None else Confirmator(
     )
예제 #4
0
    def test_upload_when_status_404_returned(self):
        http_adapter = FakeHttpAdapter(404)
        uploader = Uploader(http_adapter)

        assert_raises(ResourceNotFoundError, uploader.upload, 'http://api/url',
                      'a1b2c3', self.asciicast)
예제 #5
0
    def test_upload_when_status_503_returned(self):
        http_adapter = FakeHttpAdapter(503)
        uploader = Uploader(http_adapter)

        assert_raises(ServerMaintenanceError, uploader.upload,
                      'http://api/url', 'a1b2c3', self.asciicast)