GithubHelp home page GithubHelp logo

domenicoblanco / healthcheck-bot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from unict-dmi/healthcheck-bot

0.0 1.0 0.0 114 KB

A simple Python script to verify if a service is up

License: GNU General Public License v3.0

Python 100.00%

healthcheck-bot's Introduction

Healthcheck-bot

CI Badge

logo

A simple Python script to verify if a service is up. Whenever the service falls, a message will be sent to a user/group/channel with Telegram

How to use?

Just set two env variables:

  • QDBotToken, your bot token
  • QDBotIDs, the ID(s) the bot will use to communicate any downtime. It's possible to set multiple IDs, semicolon separated without any space

Example in bash

export QDBotToken="123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11" # Your bot token
export QDBotIDs="10000000"                                      # Single ID
export QDBotIDs="10000000;10000001;10000002"                    # Multiple IDs

Write Unit Tests

In order to write Unit Tests, you have to put it inside tests. There are many possibilities,

Unit Tests without mocking

To add a new unit test without mocking, there are some examples at the beginning of tests, but let's inspect how they're implemented:

  • func: simply the function to mock
  • expected_res: the expected returned value of the function to test
  • arg: a tuple that contains the argument(s) of the function to test (the one previously defined in func). In case there are no passing arguments, just add an empty tuple object (tuple())
  • is_async: this is not a compulsory key, should be added and set to True only if the function is asynchronous

Unit Tests with mocking

If is necessary one or more mock(s), it's possible to append three more keys to the unit test. In case an async function needs to be mocked, its result can be wrapped in an AsyncMock and its return value set as a constructor element in the constructor. The test should have the same keys with three more keys:

  • mock_obj: it's a list of the objects in which there are the functions to mock. In our examples they often refer to the main object (the one imported from src.main)
  • mock_func: an array of strings, it indicates the functions to mock
  • mock_ret: a list of the returned values

healthcheck-bot's People

Contributors

domenicoblanco avatar valeri0p avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.