Skip to main content

Tresto

Tresto is a Python library that integrates with Trello to provide advanced functionality for unit testing. With Tresto, you can create Trello cards for each test automatically, and these cards will be moved to the appropriate list based on the test results. This makes Tresto an ideal tool for test-driven development, as it provides a convenient and visual way to monitor the progress of your tests.

Installation

You can install Tresto using pip:

pip3 install tresto

Usage

Using Tresto is easy. Simply create a TrestoTestCase and write your tests as you normally would. However, you will need to set up your Trello API key and token as environment variables TRELLO_API_KEY and TRELLO_API_TOKEN.

import unittest
from tresto import TrestoTestCase
# FIX: arithmetic.py is in examples/ folder
from arithmetic import add, subtract, multiply, divide

class TestArithmetic(TrestoTestCase):
    auto_create_board = True
    auto_create_lists = True

    def test_add(self):
        self.assertEqual(add(1, 2), 3)

    def test_subtract(self):
        self.assertEqual(subtract(5, 3), 2)

    def test_multiply(self):
        self.assertEqual(multiply(2, 3), 6)

    def test_divide(self):
        self.assertEqual(divide(6, 3), 2)

    def test_divide_by_zero(self):
        with self.assertRaises(ValueError):
            divide(1, 0)

if __name__ == '__main__':
    unittest.main()

You can then run your tests using the standard Python unittest framework. See the tests/ subdirectory for test_hello_world.py, test_arithmetic.py and test_tresto.py - Yes, that's Tresto testing itself:

import os
import unittest
from tresto import TrestoTestCase
from trello.exceptions import ResourceUnavailable

class TestTresto(TrestoTestCase):

    def setUp(self):
        self.card_failed = None
        self.card_passed = None

    def test_1_board_setup(self):
        self.assertIsNotNone(self.board)
        self.assertEqual(self.board.name, self.board_name)

    def test_2_list_setup(self):
        self.assertIsNotNone(self.passed_list)
        self.assertIsNotNone(self.failed_list)
        self.assertEqual(self.passed_list.name, self.test_passed_list)
        self.assertEqual(self.failed_list.name, self.test_failed_list)

    def test_3_add_and_delete_cards(self):
        # Test add_card and delete_card for FAILED List
        card_name_failed = "Test Card for FAILED List"
        self.card_failed = self.add_card(self.failed_list, card_name_failed)
        self.assertEqual(self.card_failed.name, card_name_failed, self.failed_list)
        self.card_failed.delete()
        try:
            deleted_card_failed = self.board.get_card(self.card_failed.id)
            self.fail("Card was not deleted")
        except ResourceUnavailable:
            pass

        # Test add_card and delete_card for PASSED List
        card_name_passed = "Test Card for PASSED List"
        self.card_passed = self.add_card(self.passed_list, card_name_passed)
        self.assertEqual(self.card_passed.name, card_name_passed, self.passed_list)
        self.card_passed.delete()
        try:
            deleted_card_passed = self.board.get_card(self.card_passed.id)
            self.fail("Card was not deleted")
        except ResourceUnavailable:
            pass

    def test_4_add_and_move_card_between_lists(self):
        card_name = "Test Card for Moving Between Lists"
        card = self.add_card(self.passed_list, card_name)
        self.move_card(card, self.failed_list)

        # Refresh card data
        card.fetch()

        self.assertEqual(card.list_id, self.failed_list.id, self.failed_list)
        card.delete()

if __name__ == '__main__':
    unittest.main()

Acknowledgements

Tresto is built using the py-trello library. Thank you to the py-trello developers for their great work!

Contributing

Contributions are always welcome! If you find a bug or have a suggestion for how to improve Tresto, please open an issue here.

Release files for tresto 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tresto 0.1.2
File Size Uploaded
tresto-0.1.2.tar.gz 3.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tresto 0.1.2
File Interpreter ABI Platform
tresto-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 7.6 kB

Release files / tresto-0.1.2.tar.gz

Download URL tresto-0.1.2.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
9c7f2f4ee8e6466de778d39b9984919fca8ee130b3d1b4a44111e67adb2439a6
BLAKE2b-256 checksum
How to use checksums
d3e30b6cc45b1baeb1187ebfc1aacbd61af1ff25e9f1208d891270ebf736316b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / tresto-0.1.2-py3-none-any.whl

Download URL tresto-0.1.2-py3-none-any.whl
Size 3.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
16c27b2cfbc6dfb493e8c606276f793277946fed54490f7b1183a7b4738fca9b
BLAKE2b-256 checksum
How to use checksums
8e1a3e29d5c5ddd743116e72a07fb56a2361fca492012ff18ff6501954d1a82c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page