funki 0.0.162
Functional programming test driven development framework.
Requires Python: >=3.7

# funki

Functional programming test driven development framework.

Please see source code to understand how this currently works.

As the code matures, this readme will be repopulated with higher quality documentation.

Some imperfect notes follow.

## Initiate a new funki project
`python3 -m funki.create_new_funki_project`

## Create a new Funk
`python3 -m funki.make_new_funk`

File will be created in the src/funks directory by default.

## Run Tests Continuously and Auto-commit on Pass
Execute testing and autocommit functionality with this command:
```bash
nodemon --exec python3 start.py --auto-commit
```

-------------------------------------------------------------

# funki

Functional programming test driven development framework.

See https://gitlab.com/zereiji/x for a minimum working application using this module.

See https://youtu.be/mtK18Ef15Uc for demo.

### Execute Application using auto-commit mode
The system works by writing functions as Funk instances.

Each Funk instance has the following properties:
```python
name:str, # The reference for the funk when it is listed in the testing phase
io_value_pairs:list, # A set of expected input output pairs
description='', # This is effectively the docstring of a function
setup=nop, # A function to do any setup activities, e.g. open a connection to a database.
run=nop_state_x, # The function that satisfies the io_value_pairs and other constraints.
tear_down=nop_x, # A function that is called to release any resources setup in the setup function.
output_properties=[] # Properties that the output may have, e.g. output must be a list.
```

#### Notes
`x` represents the arguments to a Funk and is expected to be a singular value or a dictionary of values if multiple parameters are to be passed.

`state` represents state that was configured in the setup method.  It should take the form of a dictionary of values.
``

```py
list_functions = Funk(
  name='list_python_functions.list_functions',
  io_value_pairs=[
    (
      {'stdin': [], 'x': './temp'},
      {'stdout': [], 'y': [
          '.temp.coo_doo.coo',
          '.temp.coo_doo.doo',
          '.temp.foo_goo.foo',
          '.temp.foo_goo.goo',
        ]
      }
    )
  ],
  description='List all python functions',
  setup=_setup,
  run=_run,
  tear_down=_tear_down
)
```

These methods (setup, run, tear_down) can either be written inline as a lambda function or passed a reference to a traditional dirty function as shown in the example.

Each Funk has a test method that is called that applies the input output pairs, and the output conditions to determine if the Funk.run is ok.

These Funk.test methods are called sequentially in the tests.test.py script when the application is set to run in auto-commit mode.

Execute testing and autocommit functionality with this command:
```bash
nodemon --exec python3 start.py --auto-commit
```

This should produce something like the following:

```
[nodemon] starting `python3 start.py --auto-commit`
PASS list_python_functions.list_functions()
Already up to date.
[main 9dfab7c] Updated README.md.
 1 file changed, 1 insertion(+), 1 deletion(-)
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 32 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 308 bytes | 308.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
To gitlab.com:civilise-ai/funky.git
   56787b9..9dfab7c  main -> main
fin
[nodemon] clean exit - waiting for changes before restart
```

Which is a list of tests that passed or failed followed by the stdout output form the git commit activity.

## Notes
Running the auto-commit option generates a list of refactor recommendations sorted by frequency of occurence.

For example,

```
"    self," [('./src/funk.py', 11), ('./src/auto_commit/git_manager.py', 7)]
```

states that the code `"    self,"` occurred twice in two files: `'./src/funk.py'` and `'./src/auto_commit/git_manager.py'` on lines `11` and `7`.

Particular lines can be ignored by editing the list: `src.auto_commit.refactor_recommender.RefactorRecommender.ignoreable`.

These refactor recommendations can be used to assist in the refactor phase of the TDD cycle.

## Notes for Author
Republish by issuing these commands:
* python3 setup.py sdist
* twine upload dist/*