def setup_function(function):
    pass


def teardown_function(function):
    pass


def test_upload_image():
    image_path = Path(__file__).parent / "images/icon.png"
    api = wordpress_oauth.Wordpress("~/.config/pywordpress_oauth/config.yml")
    result = api.upload_image(image_path)
    assert result.status_code == 200


def test_post_article():
    api = wordpress_oauth.Wordpress("~/.config/pywordpress_oauth/config.yml")
    result = api.post_article({"title": "test title", "status": "draft"})
    assert result.status_code == 201


if __name__ == "__main__":
    os.chdir(os.path.dirname(os.path.abspath(__file__)))
    kanilog.setup_logger(
        logfile="/tmp/%s.log" % (os.path.basename(__file__)), level=logging.INFO
    )
    stdlogging.enable()

    pytest.main([__file__, "-k test_post_article", "-s"])
Exemplo n.º 2
0
    The request handler class for our server.

    It is instantiated once per connection to the server, and must
    override the handle() method to implement communication to the
    client.
    """
    def handle(self):
        # self.request is the TCP socket connected to the client
        self.data = self.request.recv(1024).strip()
        print("{} wrote:".format(self.client_address[0]))
        print(self.data)
        # just send back the same data, but upper-cased
        self.request.sendall(self.data.upper())


def main():
    HOST, PORT = "localhost", 9999

    # Create the server, binding to localhost on port 9999
    with socketserver.TCPServer((HOST, PORT), MyTCPHandler) as server:
        # Activate the server; this will keep running until you
        # interrupt the program with Ctrl-C
        server.serve_forever()


if __name__ == "__main__":
    kanilog.setup_logger(logfile="/tmp/%s.log" % (Path(__file__).name),
                         level=logging.INFO)
    stdlogging.enable()
    main()