def testGet(self):
    self.mox.StubOutWithMock(applesus, 'settings')
    applesus.settings.HOUR_START = 9
    applesus.settings.HOUR_STOP = 17
    now = datetime.datetime(  # Dec 10, 2014 16:20:00
        2014, 12, 10, 16, 20, 00, 000000)
    today = now.date()

    mock_product_promote_testing = self.mox.CreateMockAnything()
    mock_product_promote_testing.tracks = ['unstable']
    mock_product_promote_testing.product_id = 'fooid'
    mock_product_promote_testing.manual_override = False
    mock_product_promote_testing.mtime = 'testingpromotetime'

    mock_product_toonew = self.mox.CreateMockAnything()
    mock_product_toonew.tracks = ['unstable']
    mock_product_toonew.product_id = 'fooid2'
    mock_product_toonew.manual_override = False
    mock_product_toonew.mtime = 'toonewtime'

    mock_product_promote_stable = self.mox.CreateMockAnything()
    mock_product_promote_stable.tracks = ['unstable', applesus.common.TESTING]
    mock_product_promote_stable.product_id = 'fooid3'
    mock_product_promote_stable.manual_override = False
    mock_product_promote_stable.mtime = 'stablepromotetime'

    testing_products = [mock_product_promote_testing, mock_product_toonew]
    stable_products = [mock_product_promote_stable]

    self.mox.StubOutWithMock(applesus.models.AppleSUSProduct, 'all')
    self.mox.StubOutWithMock(applesus.applesus, 'GenerateAppleSUSCatalogs')
    self.mox.StubOutWithMock(applesus.models.AdminAppleSUSProductLog, 'Log')
    self.mox.StubOutWithMock(applesus.applesus, 'GetAutoPromoteDate')

    promotions = {}
    mock_query = self.mox.CreateMockAnything()

    # testing promote
    applesus.models.AppleSUSProduct.all().AndReturn(mock_query)
    mock_query.filter('tracks !=', applesus.common.TESTING).AndReturn(
        testing_products)
    applesus.applesus.GetAutoPromoteDate(
        applesus.common.TESTING, mock_product_promote_testing).AndReturn(today)
    mock_product_promote_testing.put().AndReturn(None)
    promotions[applesus.common.TESTING] = [mock_product_promote_testing]

    # testing product with too new of a datetime does not get promoted.
    applesus.applesus.GetAutoPromoteDate(
        applesus.common.TESTING, mock_product_toonew).AndReturn(
            today + datetime.timedelta(days=2))

    # stable promote
    applesus.models.AppleSUSProduct.all().AndReturn(mock_query)
    mock_query.filter('tracks !=', applesus.common.STABLE).AndReturn(
        stable_products)
    applesus.applesus.GetAutoPromoteDate(
        applesus.common.STABLE, mock_product_promote_stable).AndReturn(
            today - datetime.timedelta(days=3))
    mock_product_promote_stable.put().AndReturn(None)
    promotions[applesus.common.STABLE] = [mock_product_promote_stable]

    for track in [applesus.common.TESTING, applesus.common.STABLE]:
      applesus.applesus.GenerateAppleSUSCatalogs(track)
      applesus.models.AdminAppleSUSProductLog.Log(
          promotions[track], 'auto-promote to %s' % track).AndReturn(None)

    self.mox.StubOutWithMock(self.c, '_NotifyAdminsOfAutoPromotions')
    self.c._NotifyAdminsOfAutoPromotions(promotions).AndReturn(None)

    self.mox.ReplayAll()
    self.c.get(now=now)

    self.assertTrue(
        applesus.common.TESTING in mock_product_promote_testing.tracks)
    self.assertTrue(
        applesus.common.STABLE not in mock_product_promote_testing.tracks)

    self.assertTrue(
        applesus.common.TESTING not in mock_product_toonew.tracks)
    self.assertTrue(
        applesus.common.STABLE not in mock_product_toonew.tracks)

    self.assertTrue(
        applesus.common.STABLE in mock_product_promote_stable.tracks)

    self.mox.VerifyAll()
Tests get() within working hours.
dataset/ETHPy150Open google/simian/src/tests/simian/mac/cron/applesus_test.py/AppleSUSAutoPromoteTest.testGet