mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
2a76e589a5
(cherry picked from commit 92f4273fb6d3d3079b07dc3c76acf1afd17f4225)
43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
"""Unit tests for buildscripts.patch_builds.change_data.py."""
|
|
|
|
from __future__ import absolute_import
|
|
|
|
import os
|
|
import unittest
|
|
|
|
from mock import patch, MagicMock
|
|
|
|
import buildscripts.patch_builds.change_data as under_test
|
|
|
|
# pylint: disable=missing-docstring
|
|
|
|
NS = "buildscripts.patch_builds.change_data"
|
|
|
|
|
|
def ns(relative_name): # pylint: disable=invalid-name
|
|
"""Return a full name from a name relative to the test module"s name space."""
|
|
return NS + "." + relative_name
|
|
|
|
|
|
class TestFindChangedFilesInRepos(unittest.TestCase):
|
|
@patch(ns("find_changed_files"))
|
|
def test_nothing_found(self, changed_files_mock):
|
|
repos_mock = [MagicMock()]
|
|
changed_files_mock.return_value = set()
|
|
|
|
self.assertEqual(0, len(under_test.find_changed_files_in_repos(repos_mock)))
|
|
|
|
@patch(ns("find_changed_files"))
|
|
def test_changed_files_in_multiple_repos(self, changed_files_mock):
|
|
repos_mock = [MagicMock(), MagicMock()]
|
|
first_repo_file_changes = [
|
|
os.path.join("jstests", "test1.js"),
|
|
os.path.join("jstests", "test1.cpp"),
|
|
]
|
|
second_repo_file_changes = [
|
|
os.path.join("jstests", "test2.js"),
|
|
]
|
|
changed_files_mock.side_effect = [first_repo_file_changes, second_repo_file_changes]
|
|
|
|
self.assertEqual(3, len(under_test.find_changed_files_in_repos(repos_mock)))
|