Unit tests for the Gitlab Tools Module

Contains unittests for the gitlab_tools module.

This project is developed by using test driven design. The gitlab_tools module is specified to work with GitLab API v3.

class test_gitlab_tools.TestGitLabPushEventInfo(methodName='runTest')[source]

Test the the class capable of extracting information from gitlab api data.

The GitLabPushEventInfo is specified to work with data from the GitLab v3 API.

The API returns data in json format and can be read into a dict using the json module.

A mock git repository is created via gitpython in the stUp method.

A mock GitLab response is created by ingesting data from the mock git repository into template python dictionaries. Filler and expected push dictionaries are then merged in a list. This creates a List, similar to what the standard library json would parse from a GitLab API response string.

Variables:
  • BRANCH (str) – The branch ingested into the expected_push data. Functionality using branch selection is not jet implemented.
  • NEWEST_PUSH_DATE (str) – Datestring in a format used by the GitLab API. Is supposed to be the newest push date, ingested into the mock API response.
  • PUSH_DATE_OBJECT (datetime) – NEWEST_PUSH_DATE parsed to a date object.
  • GIT_TEST_REPO_PATH (str) – Path to the mock git repository to be created.
  • FROM_COMMIT_INDEX (int) – List index of the first commit, that is part of the newest push from the mock API response.
  • TO_COMMIT_INDEX (int) – List index of the last commit, that is part of the newest push from the mock API response.
  • RESPONSE_FILLER (list) – Mock API Response without the expected_push data.
  • expected_push (dict) – Represents a single push event from a GitLab API response. It is the reference push event, that is expected to be returned as latest push event.
  • all_push_events (list) – List of all push data sections from the mock API response.
  • git_lab_response (list) – Mock api response, as expected when the read via the json.read() method.
  • changed_files (dict) – A dict with all files changed in the most recent push as keys and the type of change as their value.
  • repo (git.Repo) – A gitpython git.Repo object that handles the mock repository.
setUp()[source]

Initiate a test git repository.

tearDown()[source]

Clean up test git repo.

test_extract_push_data()[source]

Test the function to filter out push events from a json file.

test_get_latest_push()[source]

Test the function to get last push date.(not the most recent)

test_get_modified_files()[source]

Test the function, that returns all modified files between two commits.

test_instantiation()[source]

Test the constructor of the class.

test_is_modified_file()[source]

Test the function to check if a file was modified since the last push.

class test_gitlab_tools.TestGitlabAPIRequest(methodName='runTest')[source]

Test the function to call a gitlab API.

The Functions tested here are specified to work with a GitLab API v3.

test_gitlab_events_api_request()[source]

Test the function to call a gitlab API.

The API should return a json list filled with objects.