def test_get_build_weights_listBuilds_failed(self, ClientSession): session = ClientSession.return_value session.getLoggedInUser.return_value = {"id": 123} session.multiCall.side_effect = [[[1], [2]], []] session.getAverageBuildDuration.return_value = None weights = KojiModuleBuilder.get_build_weights(["httpd", "apr"]) assert weights == {"httpd": 1.5, "apr": 1.5} expected_calls = [ mock.call(packageID=1, userID=123, state=1, queryOpts={ "limit": 1, "order": "-build_id" }), mock.call(packageID=2, userID=123, state=1, queryOpts={ "limit": 1, "order": "-build_id" }), ] assert session.listBuilds.mock_calls == expected_calls session.krb_login.assert_called_once()
def test_get_build_weights_no_build(self, ClientSession): session = ClientSession.return_value session.getLoggedInUser.return_value = {"id": 123} session.multiCall.side_effect = [ # getPackageID response [[1], [2]], # listBuilds response [[[{ "task_id": 456 }]], [[]]], # getTaskDescendents response [[{ "1": [], "2": [], "3": [{ "weight": 1.0 }, { "weight": 1.0 }] }]], ] session.getAverageBuildDuration.return_value = None weights = KojiModuleBuilder.get_build_weights(["httpd", "apr"]) assert weights == {"httpd": 2, "apr": 1.5} expected_calls = [mock.call(456)] assert session.getTaskDescendents.mock_calls == expected_calls session.krb_login.assert_called_once()
def test_get_build_weights_getPackageID_failed(self, ClientSession): session = ClientSession.return_value session.getLoggedInUser.return_value = {"id": 123} session.multiCall.side_effect = [[], []] session.getAverageBuildDuration.return_value = None weights = KojiModuleBuilder.get_build_weights(["httpd", "apr"]) assert weights == {"httpd": 1.5, "apr": 1.5} expected_calls = [mock.call("httpd"), mock.call("apr")] assert session.getPackageID.mock_calls == expected_calls session.krb_login.assert_called_once()
def test_get_build_weights_getLoggedInUser_failed(self, ClientSession): session = ClientSession.return_value session.getAverageBuildDuration.return_value = None weights = KojiModuleBuilder.get_build_weights(["httpd", "apr"]) assert weights == {"httpd": 1.5, "apr": 1.5} session.krb_login.assert_called_once()