示例#1
0
    def test_roger_push_env_from_ROGER_ENV_VAR(self):
        settings = mock(Settings)
        appConfig = mock(AppConfig)
        roger_push = RogerPush()
        marathon = mock(Marathon)
        mockedHooks = mock(Hooks)
        roger_env = self.roger_env
        config = self.config
        frameworkUtils = mock(FrameworkUtils)
        when(settings).getConfigDir().thenReturn(self.configs_dir)
        when(mockedHooks).run_hook(any(), any(), any()).thenReturn(0)
        when(appConfig).getRogerEnv(self.configs_dir).thenReturn(roger_env)
        when(appConfig).getConfig(any(), any()).thenReturn(config)

        args = self.args
        args.env = None
        args.secrets_file = ""
        args.skip_push = True
        args.app_name = 'grafana_test_app'
        args.config_file = 'test.json'

        roger_env = appConfig.getRogerEnv(self.configs_dir)
        roger_env["default_environment"] = None
        # Setting ROGER_ENV to specific value
        os.environ["ROGER_ENV"] = "test_env"

        with self.assertRaises(ValueError):
            roger_push.main(settings, appConfig, frameworkUtils, mockedHooks,
                            args)
 def test_user_can_login_with_password(self):
     cli = mock()
     user = User("username", "password", cli)
     when(cli).compareReceivedAgainst(any(),any(), indexOfSuccessfulResult=any()).thenReturn(0).thenReturn(1)
     user.login()
     verify(cli).send("su username")
     verify(cli).send("password")
 def test_noDeletionsWhenNoItems(self):
     tracker = self.makeValidTracker()
     trackerInstance = self.trackerInstance_
     when(trackerInstance).GetStories(any()).thenReturn([])
     tracker.deleteAllItems()
     verify(trackerInstance, never).DeleteStory(any())
     pass
    def test_multithreadMode(self):
        """
        Tests that when we call get_driver() it returns a unique driver for each thread,
        but for the same thread returns the same driver.
        """
        config_reader = mock(ConfigReader)
        when(config_reader).get(WebDriverManager.SHUTDOWN_HOOK_CONFIG, any()).thenReturn(True)
        when(config_reader).get(WebDriverManager.REUSE_BROWSER, any()).thenReturn(False)
        when(config_reader).get(WebDriverManager.REUSE_BROWSER, any()).thenReturn(False)
        when(config_reader).get(WebDriverManager.ENABLE_THREADING_SUPPORT, any()).thenReturn(True)

        webdriverfactory_mock = mock(WebDriverFactory)
        when(webdriverfactory_mock).create_webdriver(testname=None).thenReturn(mock(WebDriver))\
        .thenReturn(mock(WebDriver)).thenReturn(mock(WebDriver))

        webdriver_provider = WebDriverManager(webdriver_factory=webdriverfactory_mock, 
                                              config = config_reader)

        # Spawn thread to check if driver is unique per thread.
        driver1 = webdriver_provider.get_driver()
        t = threading.Thread(target=lambda: self.__multithreaded_7est_thread2(driver1, webdriver_provider))
        t.start()
        t.join()
        self.assertFalse(self._driver_from_thread_is_same)
        
        # Check that driver is same for the same thread.
        driver3 = webdriver_provider.get_driver()
        self.assertEqual(driver1, driver3, "Same thread should return same driver.")
 def test_mode_exited(self):
     cli = self.makeCli()
     when(cli).compareReceivedAgainst(any(),any()).thenReturn(0)
     testMode = Mode(cli)
     testMode.exit()
     verify(cli).exitMode(testMode)
     verify(cli).send("exit")
 def test_filterIsSentWhenSpecified(self):
     jira = JiraTracker()
     jiraInstance = self.getMockFor(jira)
     forFilter = "blah"
     self.setMocksForGettingItems(jiraInstance)
     self.assertRaises(StopIteration, next, jira._getItems(forFilter)) 
     verify(jiraInstance.service).getIssuesFromJqlSearch(any(),forFilter,any())
示例#7
0
    def test_newDriver_ReturnsNewInstance(self):
        config_reader = mock(ConfigReader)
        when(config_reader).get(WebDriverManager.SHUTDOWN_HOOK_CONFIG,
                                any()).thenReturn(True)
        when(config_reader).get(WebDriverManager.REUSE_BROWSER,
                                any()).thenReturn(False)
        when(config_reader).get(WebDriverManager.REUSE_BROWSER,
                                any()).thenReturn(False)

        webdriver_mock1 = mock(WebDriver)
        webdriver_mock2 = mock(WebDriver)
        webdriverfactory_mock = mock(WebDriverFactory)
        when(webdriverfactory_mock).create_webdriver(testname=None).thenReturn(
            webdriver_mock1).thenReturn(webdriver_mock2)

        webdriver_provider = WebDriverManager(
            webdriver_factory=webdriverfactory_mock, config=config_reader)

        driver1 = webdriver_provider.new_driver()
        driver2 = webdriver_provider.new_driver()

        self.assertFalse(
            driver1 is driver2,
            "new_driver() should create fresh instance if reusebrowser if false."
        )
示例#8
0
    def test_get_children_default_watcher(self):
        watcher = mock()
        z = pookeeper.allocate(self.hosts, watcher=watcher)

        z.create('/pookie', CREATOR_ALL_ACL, Persistent(), data=_random_data())
        z.get_children('/pookie', watch=True)

        z.create('/pookie/bear', CREATOR_ALL_ACL, Persistent(), data=_random_data())
        z.get_children('/pookie', watch=True)

        z.set_data('/pookie', _random_data())
        z.set_data('/pookie/bear', _random_data())

        # One is for when we do and the other is for when we don't chroot
        z.get_children('/pookie', watch=True)
        z.get_children('/pookie/bear', watch=True)

        z.delete('/pookie/bear')
        z.delete('/pookie')

        z.close()

        mockito.verify(watcher).session_connected(matchers.any(long), matchers.any(str), False)
        mockito.verify(watcher, times=2).children_changed('/pookie')
        mockito.verify(watcher).node_deleted('/pookie/bear')
        mockito.verify(watcher).connection_closed()
        verifyNoMoreInteractions(watcher)
示例#9
0
    def test_multithreadMode(self):
        """
        Tests that when we call get_driver() it returns a unique driver for each thread,
        but for the same thread returns the same driver.
        """
        config_reader = mock(ConfigReader)
        when(config_reader).get(WebDriverManager.SHUTDOWN_HOOK_CONFIG,
                                any()).thenReturn(True)
        when(config_reader).get(WebDriverManager.REUSE_BROWSER,
                                any()).thenReturn(False)
        when(config_reader).get(WebDriverManager.REUSE_BROWSER,
                                any()).thenReturn(False)
        when(config_reader).get(WebDriverManager.ENABLE_THREADING_SUPPORT,
                                any()).thenReturn(True)

        webdriverfactory_mock = mock(WebDriverFactory)
        when(webdriverfactory_mock).create_webdriver(testname=None).thenReturn(mock(WebDriver))\
        .thenReturn(mock(WebDriver)).thenReturn(mock(WebDriver))

        webdriver_provider = WebDriverManager(
            webdriver_factory=webdriverfactory_mock, config=config_reader)

        # Spawn thread to check if driver is unique per thread.
        driver1 = webdriver_provider.get_driver()
        t = threading.Thread(target=lambda: self.__multithreaded_7est_thread2(
            driver1, webdriver_provider))
        t.start()
        t.join()
        self.assertFalse(self._driver_from_thread_is_same)

        # Check that driver is same for the same thread.
        driver3 = webdriver_provider.get_driver()
        self.assertEqual(driver1, driver3,
                         "Same thread should return same driver.")
 def test_retryWhenTryingToGetStoriesAndException(self):
     tracker = self.makeValidTracker()
     trackerInstance = self.trackerInstance_
     when(trackerInstance).GetStories(any()).thenRaise(Exception("")).thenReturn([Story(),Story()])
     when(trackerInstance).GetComments(any()).thenReturn([])
     next(tracker.items())
     verify(trackerInstance, times=2).GetStories(any())
 def test_noDeletionsWhenNoItems(self):
     tracker = self.makeValidTracker()
     trackerInstance = self.trackerInstance_
     when(trackerInstance).GetStories(any()).thenReturn([])
     tracker.deleteAllItems()
     verify(trackerInstance, never).DeleteStory(any())
     pass
    def test_roger_push_env_from_ROGER_ENV_VAR(self):
        settings = mock(Settings)
        appConfig = mock(AppConfig)
        roger_push = RogerPush()
        marathon = mock(Marathon)
        mockedHooks = mock(Hooks)
        roger_env = self.roger_env
        config = self.config
        frameworkUtils = mock(FrameworkUtils)
        when(settings).getConfigDir().thenReturn(self.configs_dir)
        when(mockedHooks).run_hook(any(), any(), any()).thenReturn(0)
        when(appConfig).getRogerEnv(self.configs_dir).thenReturn(roger_env)
        when(appConfig).getConfig(any(), any()).thenReturn(config)

        args = self.args
        args.env = None
        args.secrets_file = ""
        args.skip_push = True
        args.app_name = 'grafana_test_app'
        args.config_file = 'test.json'

        roger_env = appConfig.getRogerEnv(self.configs_dir)
        roger_env["default_environment"] = None
        # Setting ROGER_ENV to specific value
        os.environ["ROGER_ENV"] = "test_env"

        with self.assertRaises(ValueError):
            roger_push.main(settings, appConfig,
                            frameworkUtils, mockedHooks, args)
示例#13
0
 def test_whenJiraIdIsZeroNameIsNone(self):
     jiraStatus = mock()
     mapObject = mock()
     when(jiraStatus).status().thenReturn("")
     status = TrackerItemStatus(jiraStatus, mapObject)
     verify(mapObject, never).translateStatusTo(any(), any())
     self.assertEqual(status.jira(), None)
 def test_canntGetBugsForProject(self):
     jira = JiraTracker()
     jiraInstance = self.getMockFor(jira)
     jira.selectProject(["",""])
     fault = Holder()
     fault.faultstring = ""
     when(jiraInstance.service).getIssuesFromJqlSearch(any(), any(), any()).thenRaise(WebFault(fault, None))
     self.assertRaises(StopIteration, next, jira._getItems())
 def test_canUpdateStatus(self):
     statusId = "Match"
     action = TestAction(5,statusId)
     jira, jiraInstance, itemId, trackerItem, status = self.setupStatus()
     when(status).jira().thenReturn(statusId)
     when(jiraInstance.service).getAvailableActions(any(), any()).thenReturn([action,])
     jira._ticketWithUpdatedStatusFrom(trackerItem)
     verify(jiraInstance.service).progressWorkflowAction(self.auth_, itemId, action.id, any())
 def test_filterIsSentWhenSpecified(self):
     tracker = self.makeValidTracker()
     trackerInstance = self.trackerInstance_
     forFilter = "blah"
     when(trackerInstance).GetStories(any()).thenReturn([])
     when(trackerInstance).GetComments(any()).thenReturn([])
     self.assertRaises(StopIteration, next, tracker.items(forFilter)) 
     verify(trackerInstance).GetStories(forFilter)
 def test_authSentWhenGettingBugs(self):
     jira = JiraTracker()
     jiraInstance = self.getMockFor(jira)
     self.setMocksForGettingItems(jiraInstance)
     itemIterator = jira._getItems()
     self.assertRaises(StopIteration, next, itemIterator)
     verify(jiraInstance.service).getIssuesFromJqlSearch(self.auth_, any(), any())
     pass
 def test_filterIsSentWhenSpecified(self):
     tracker = self.makeValidTracker()
     trackerInstance = self.trackerInstance_
     forFilter = "blah"
     when(trackerInstance).GetStories(any()).thenReturn([])
     when(trackerInstance).GetComments(any()).thenReturn([])
     self.assertRaises(StopIteration, next, tracker.items(forFilter))
     verify(trackerInstance).GetStories(forFilter)
 def test_doNotAddCommentsGreaterThan20000Characters(self):
     tracker = self.makeValidTracker()
     trackerInstance = self.trackerInstance_
     testing = Testing()
     item = self.itemWithComments(testing)
     item.addComment(Testing.stringOfAsOfSize(20002))
     tracker.updateCommentsFor(item)
     verify(trackerInstance, times=2).AddComment(any(), any())
示例#20
0
    def test_run_hook_returns_zero_when_hook_succeeds(self):

        when(self.hooks.whobj).invoke_webhook(any(), any(), any()).thenReturn()
        sc = mock(StatsClient)
        when(sc).timing(any(), any()).thenReturn(any())
        when(self.hooks.utils).getStatsClient().thenReturn(sc)
        when(self.hooks.utils).get_identifier(any(), any(), any()).thenReturn(any())
        assert self.hooks.run_hook("pre-build", self.appdata, os.getcwd(), "roger-tools.pre-build-test") == 0
 def test_retryWhenTryingToGetStoriesAndException(self):
     tracker = self.makeValidTracker()
     trackerInstance = self.trackerInstance_
     when(trackerInstance).GetStories(any()).thenRaise(
         Exception("")).thenReturn([Story(), Story()])
     when(trackerInstance).GetComments(any()).thenReturn([])
     next(tracker.items())
     verify(trackerInstance, times=2).GetStories(any())
 def test_noDeletionsWhenNoItems(self):
     jira = JiraTracker()
     jiraInstance = self.getMockFor(jira)
     jira.selectProject(["",""])
     self.setMocksForGettingItems(jiraInstance)
     jira.deleteAllItems()
     verify(jiraInstance.service, never).deleteIssue(any(), any())
     pass
 def test_whenDoingPivotalOperationAuthenticationIsIncluded(self):
     tracker = self.makeTestTracker()
     pivotalApiObject = self.apiObject_
     password = "******"
     authentication = mock()
     when(pivotalApiObject).HostedTrackerAuth(any(),any()).thenReturn(authentication)
     tracker.withCredential(password)
     verify(pivotalApiObject).Tracker(any(), authentication)
 def test_doNotAddCommentsGreaterThan20000Characters(self):
     tracker = self.makeValidTracker()
     trackerInstance = self.trackerInstance_
     testing = Testing()
     item = self.itemWithComments(testing)
     item.addComment(Testing.stringOfAsOfSize(20002))
     tracker.updateCommentsFor(item)
     verify(trackerInstance, times=2).AddComment(any(), any())
 def test_updateAddsNewComments(self):
     jira = JiraTracker()
     jiraInstance = self.getMockFor(jira)
     testing = Testing()
     item = self.itemWithComments(testing)
     jira.update(item)
     verify(jiraInstance.service, times=2).addComment(any(), any(), any())
     pass
 def test_whenDoingPivotalOperationAuthenticationIsIncluded(self):
     tracker = self.makeTestTracker()
     pivotalApiObject = self.apiObject_
     password = "******"
     authentication = mock()
     when(pivotalApiObject).HostedTrackerAuth(
         any(), any()).thenReturn(authentication)
     tracker.withCredential(password)
     verify(pivotalApiObject).Tracker(any(), authentication)
 def test_canGetStoriesFromProject(self):
     tracker = self.makeValidTracker()
     trackerInstance = self.trackerInstance_
     when(trackerInstance).GetStories(any()).thenReturn([Story(), Story()])
     when(trackerInstance).GetComments(any()).thenReturn([])
     itemIterator = tracker.items()
     next(itemIterator)
     next(itemIterator)
     self.assertRaises(StopIteration, next, itemIterator)
 def test_handleWhenNoCommentsAreReturned(self):
     jira = JiraTracker()
     jiraInstance = self.getMockFor(jira)
     ticket = mock()
     key = "12345"
     when(ticket).Id().thenReturn(key)
     when(jiraInstance.service).getComments(any(),any()).thenReturn(None)
     jira.addCommentsTo(ticket)
     verify(jiraInstance.service,times=0).addComment(any(), any(), any())
 def test_trackerValidAfterLogin(self):
     tracker = self.makeTestTracker()
     pivotalApiObject = self.apiObject_
     trackerInstance = mock()
     when(pivotalApiObject).Tracker(any(),any()).thenReturn(trackerInstance)
     user = "******"
     password = "******"
     tracker.loginAs(user).withCredential(password)
     self.assertTrue(tracker.valid())
 def test_canGetStoriesFromProject(self):
     tracker = self.makeValidTracker()
     trackerInstance = self.trackerInstance_
     when(trackerInstance).GetStories(any()).thenReturn([Story(),Story()])
     when(trackerInstance).GetComments(any()).thenReturn([])
     itemIterator = tracker.items()
     next(itemIterator)
     next(itemIterator)
     self.assertRaises(StopIteration, next, itemIterator)
 def makeValidTracker(self):
     tracker = self.makeTestTracker()
     pivotalApiObject = self.apiObject_
     trackerInstance = mock()
     when(pivotalApiObject).Tracker(any(),any()).thenReturn(trackerInstance)
     pivotalProjectNumber = 0
     tracker.selectProject(pivotalProjectNumber)
     self.trackerInstance_ = trackerInstance
     return tracker
示例#32
0
    def test_run_hook_returns_non_zero_when_hook_fails(self):

        when(self.hooks.whobj).invoke_webhook(any(), any(), any()).thenReturn()
        sc = mock(StatsClient)
        when(sc).timing(any(), any()).thenReturn(any())
        when(self.hooks.utils).getStatsClient().thenReturn(sc)
        when(self.hooks.utils).get_identifier(any(), any(), any()).thenReturn(any())
        assert self.hooks.run_hook(
            "bad-hook-cmd", self.appdata, os.getcwd(), "roger-tools.bad-hook-cmd-test") != 0
 def makeValidTracker(self):
     tracker = self.makeTestTracker()
     pivotalApiObject = self.apiObject_
     trackerInstance = mock()
     when(pivotalApiObject).Tracker(any(),
                                    any()).thenReturn(trackerInstance)
     pivotalProjectNumber = 0
     tracker.selectProject(pivotalProjectNumber)
     self.trackerInstance_ = trackerInstance
     return tracker
 def test_jiraItemsAreReturnedWithUrlPopulated(self):
     jira = JiraTracker()
     jiraInstance = self.getMockFor(jira)
     url = "http://www.jira.com/garbage/not/to/be/included/"
     jira.setLocationTo(url)
     item = RemoteIssue()
     item.key = "TEST-jt12345"
     when(jiraInstance.service).getIssuesFromJqlSearch(any(), any(), any()).thenReturn([item])
     when(jiraInstance.service).getComments(any(),any()).thenReturn([])
     self.assertEqual(next(jira.items()).jiraUrl(), "https://www.jira.com/browse/TEST-jt12345") 
示例#35
0
    def test_run_hook_returns_zero_when_hook_is_absent(self):

        when(self.hooks.whobj).invoke_webhook(any(), any(), any()).thenReturn()
        sc = mock(StatsClient)
        when(sc).timing(any(), any()).thenReturn(any())
        when(self.hooks.utils).getStatsClient().thenReturn(sc)
        when(self.hooks.utils).get_identifier(any(), any(),
                                              any()).thenReturn(any())
        assert self.hooks.run_hook("absent-hook", self.appdata, os.getcwd(),
                                   "roger-tools.absent-hook-test") == 0
 def test_doNotAddItemWhenItemInTracker(self):
     toTracker = mock()
     fromTracker = mock()
     detectedItem = mock()
     when(fromTracker).items(any()).thenReturn([detectedItem])
     when(toTracker).items(any()).thenReturn(Testing.MockIterator([detectedItem]))
     when(detectedItem).canBeSyncedWith(detectedItem).thenReturn(True)
     syncByAddingItems = TrackerSyncBy.addingItemsOfType(None)
     syncByAddingItems(fromTracker, toTracker)
     verify(toTracker, never).update()
 def test_whenMultipleItemsMatchFilterAndItemsCanNotBeSyncedWithThenAddNewItem(self):
     toTracker = mock()
     fromTracker = mock()
     detectedItem = mock()
     when(fromTracker).items(any()).thenReturn([detectedItem])
     when(toTracker).items(any()).thenReturn(Testing.MockIterator([detectedItem,detectedItem]))
     when(detectedItem).canBeSyncedWith(detectedItem).thenReturn(False).thenReturn(True)
     syncByAddingItems = TrackerSyncBy.addingItemsOfType(None)
     syncByAddingItems(fromTracker, toTracker)
     verify(toTracker, never).update()
 def test_canAddCommentsToTicket(self):
     jira = JiraTracker()
     jiraInstance = self.getMockFor(jira)
     testing = Testing()
     item = self.itemWithComments(testing)
     jira.updateCommentsFor(item)
     inorder.verify(jiraInstance.service).login(any(),any())
     inorder.verify(jiraInstance.service).addComment(self.auth_, testing.issue.key, {"body":testing.comment1.text()})
     inorder.verify(jiraInstance.service).addComment(self.auth_, testing.issue.key, {"body":testing.comment2.text()})
     pass
 def test_trackerValidAfterLogin(self):
     tracker = self.makeTestTracker()
     pivotalApiObject = self.apiObject_
     trackerInstance = mock()
     when(pivotalApiObject).Tracker(any(),
                                    any()).thenReturn(trackerInstance)
     user = "******"
     password = "******"
     tracker.loginAs(user).withCredential(password)
     self.assertTrue(tracker.valid())
示例#40
0
    def test_run_hook_returns_non_zero_when_hook_fails(self):

        when(self.hooks.whobj).invoke_webhook(any(), any(), any()).thenReturn()
        sc = mock(StatsClient)
        when(sc).timing(any(), any()).thenReturn(any())
        when(self.hooks.utils).getStatsClient().thenReturn(sc)
        when(self.hooks.utils).get_identifier(any(), any(),
                                              any()).thenReturn(any())
        assert self.hooks.run_hook("bad-hook-cmd", self.appdata, os.getcwd(),
                                   "roger-tools.bad-hook-cmd-test") != 0
 def test_no_assertion_when_good_result_detected(self):
     resultContainGoodResult = 0
     goodResult = "who cares"
     cli = self.makeCli()
     when(cli).compareReceivedAgainst(any(),any(),indexOfSuccessfulResult=any()).thenReturn(resultContainGoodResult)
      
     assertion = assertResultEquals(goodResult)
     assertion.executeOn(cli)
      
     verify(cli).compareReceivedAgainst([goodResult, EOF, TIMEOUT], any(),indexOfSuccessfulResult=0)
 def getMockFor(self, jira):
     jiraApiObject = mock()
     jiraInstance = Holder()
     jiraInstance.service = mock()
     jira.apiObject(jiraApiObject)
     when(jiraApiObject).Client(any(), timeout=any()).thenReturn(jiraInstance)
     self.auth_ = mock()
     when(jiraInstance.service).login(any(),any()).thenReturn(self.auth_)
     jira.withCredential("None")
     return jiraInstance
示例#43
0
    def test_run_hook_preserves_current_directory(self):

        when(self.hooks.whobj).invoke_webhook(any(), any(), any()).thenReturn()
        sc = mock(StatsClient)
        when(sc).timing(any(), any()).thenReturn(any())
        when(self.hooks.utils).getStatsClient().thenReturn(sc)
        when(self.hooks.utils).get_identifier(any(), any(), any()).thenReturn(any())
        cwd = os.getcwd()
        self.hooks.run_hook("pre-build", self.appdata, "/tmp", "roger-tools.pre-build-tmp-test")
        assert cwd == os.getcwd()
 def test_doNotAddItemWhenItemInTracker(self):
     toTracker = mock()
     fromTracker = mock()
     detectedItem = mock()
     when(fromTracker).items(any()).thenReturn([detectedItem])
     when(toTracker).items(any()).thenReturn(
         Testing.MockIterator([detectedItem]))
     when(detectedItem).canBeSyncedWith(detectedItem).thenReturn(True)
     syncByAddingItems = TrackerSyncBy.addingItemsOfType(None)
     syncByAddingItems(fromTracker, toTracker)
     verify(toTracker, never).update()
 def test_canGetAvailableStatusNextStepsForATicket(self):
     jira = JiraTracker()
     jiraInstance = self.getMockFor(jira)
     actions = ["next step1", "next step2"]
     item = mock()
     itemId = 1234 
     when(item).Id().thenReturn(itemId)
     when(jiraInstance.service).getAvailableActions(any(), any()).thenReturn(actions)
     actionsReturned = jira.getNextStatusActionsFor(item)
     verify(jiraInstance.service).getAvailableActions(self.auth_, itemId)
     self.assertEqual(actions, actionsReturned)
 def test_updateAddsNewComments(self):
     tracker = self.makeValidTracker()
     trackerInstance = self.trackerInstance_
     updatedStory = mock()
     testing = Testing()
     item = self.itemWithComments(testing)
     when(trackerInstance).UpdateStory(any()).thenReturn(updatedStory)
     when(updatedStory).GetName().thenReturn("")
     tracker.update(item)
     verify(trackerInstance, times=2).AddComment(any(), any())
     pass
 def test_canGetBugsForProject(self):
     jira = JiraTracker()
     jiraInstance = self.getMockFor(jira)
     project = ["test","JQL here"]
     jira.selectProject(project)
     when(jiraInstance.service).getIssuesFromJqlSearch(any(), project[1], any()).thenReturn([RemoteIssue(),RemoteIssue(),RemoteIssue()])
     itemIterator = jira._getItems() 
     next(itemIterator)
     next(itemIterator)
     next(itemIterator)
     self.assertRaises(StopIteration, next, itemIterator)
示例#48
0
 def test_invoke_webhook_when_appdata_is_invalid(self):
     settings = mock(Settings)
     appConfig = mock(AppConfig)
     appdata = 'invalid-app-data'
     hook_input_metrics = 'hook-input-metrics'
     conf_file = 'roger-mesos-tools.config'
     when(settings).getConfigDir().thenReturn(self.configs_dir)
     when(appConfig).getRogerEnv(any()).thenReturn(self.roger_env)
     when(appConfig).getConfig(any(), any()).thenReturn(conf_file)
     with self.assertRaises(ValueError):
         self.webhook.invoke_webhook(appdata, hook_input_metrics, conf_file)
示例#49
0
    def test_run_hook_preserves_current_directory(self):

        when(self.hooks.whobj).invoke_webhook(any(), any(), any()).thenReturn()
        sc = mock(StatsClient)
        when(sc).timing(any(), any()).thenReturn(any())
        when(self.hooks.utils).getStatsClient().thenReturn(sc)
        when(self.hooks.utils).get_identifier(any(), any(),
                                              any()).thenReturn(any())
        cwd = os.getcwd()
        self.hooks.run_hook("pre-build", self.appdata, "/tmp",
                            "roger-tools.pre-build-tmp-test")
        assert cwd == os.getcwd()