Contribute

Fantastico framework is open source so every contribution is welcome. For the moment we are looking for more developers willing to contribute.

Code contribution

If you want to contribute with code to fantastico framework there are a simple set of rules that you must follow:

  • Write unit tests (for the code / feature you are contributing).
  • Write integration tests (for the code / feature you are contributing).
  • Make sure your code is rated above 9.5 by pylint tool.
  • In addition integration tests and unit tests must cover 95% of your code.

In order for each build to remain stable the following hard limits are imposed:

  1. Unit tests must cover >= 95% of the code.
  2. Integration tests must cover >= 95% of the code.
  3. Code must be rated above 9.5 by pylint.
  4. Everything must pass.

When you push on master a set of jobs are cascaded executed:

  1. Run all unit tests job.
  2. Run all integration tests job (only if unit tests succeeds).
  3. Generate documentation and publish it (only if integration tests job succeeds).

You can follow the above build process by visiting Jenkins build [http://jenkins.scrum-expert.ro:8080/job/fantastico-framework/]. Login with your github account and everything should work smoothly.

In the end do not forget that in Fantastico framework we love to develop against a stable base. We really think code will have high quality and zero bugs.

Writing unit tests

For better understanding how to write unit tests see the documentation below:

class fantastico.tests.base_case.FantasticoUnitTestsCase(methodName='runTest')[source]

This is the base class that must be inherited by each unit test written for fantastico.

class SimpleUnitTest(FantasticoUnitTestsCase):
    def init(self):
        self._msg = "Hello world"

    def test_simple_flow_ok(self):
        self.assertEqual("Hello world", self._msg)
_get_class_root_folder()[source]

This methods determines the root folder under which the test is executed.

_get_root_folder()[source]

This method determines the root folder under which core is executed.

check_original_methods(cls_obj)[source]

This method ensures that for a given class only original non decorated methods will be invoked. Extremely useful when you want to make sure @Controller decorator does not break your tests. It is strongly recommended to invoke this method on all classes which might contain @Controller decorator. It ease your when committing on CI environment.

classmethod setup_once()[source]

This method is overriden in order to correctly mock some dependencies:

Writing integration tests

For better understanding how to write integration tests see the documentation below:

class fantastico.tests.base_case.FantasticoIntegrationTestCase(methodName='runTest')[source]

This is the base class that must be inherited by each integration test written for fantastico. If you used this class you don’t have to mind about restoring call methods from each middleware once they are wrapped by fantastico app. This is a must because otherwise you will crash other tests.

_envs[source]

Private property that holds the environments against which we run the integration tests.

_get_db_conn()[source]

This method opens a db connection and returns it to for usage.

_get_oauth2_logintoken(client_id, user_id)[source]

This methods generates an oauth2 login token which can be used in integration tests.

_get_oauth2_token(client_id, user_id, scopes)[source]

This method generates an oauth2 access token which can be used in integration tests.

_get_token(token_type, token_desc)[source]

This method provides a generic token generation method which can be used in integration tests.

_invalidate_encrypted_token(encrypted_token)[source]

This method invalidates a given encrypted token using tokens service implementation.

_invalidate_oauth2_token(token)[source]

This method invalidates the given token automatically.

_restore_call_methods()[source]

This method restore original call methods to all affected middlewares.

_save_call_methods(middlewares)[source]

This method save all call methods for each listed middleware so that later on they can be restored.

fantastico_cfg_os_key[source]

This property holds the name of os environment variable used for setting up active fantastico configuration.

class fantastico.server.tests.itest_dev_server.DevServerIntegration(methodName='runTest')[source]

This class provides the foundation for writing integration tests that do http requests against a fantastico server.

class DummyLoaderIntegration(DevServerIntegration):
    def init(self):
        self._exception = None

    def test_server_runs_ok(self):
        def request_logic(server):
            request = Request(self._get_server_base_url(server, DummyRouteLoader.DUMMY_ROUTE))
            with self.assertRaises(HTTPError) as cm:
                urllib.request.urlopen(request)

            self._exception = cm.exception

        def assert_logic(server):
            self.assertEqual(400, self._exception.code)
            self.assertEqual("Hello world.", self._exception.read().decode())

        self._run_test_against_dev_server(request_logic, assert_logic)

As you can see from above listed code, when you write a new integration test against Fantastico server you only need to provide the request logic and assert logic functions. Request logic is executed while the server is up and running. Assert logic is executed after the server has stopped.

_check_server_started(server)[source]

This method holds the sanity checks to ensure a server is started correctly.

_get_server_base_url(server, route)[source]

This method returns the absolute url for a given relative url (route).

_run_test_against_dev_server(request_logic, assert_logic=None)[source]

This method provides a template for writing integration tests that requires a development server being active. It accepts a request logic (code that actually do the http request) and an assert logic for making sure code is correct.