Esempio n. 1
0
 def testMainWithoutOptions(self, mock_getexp, mock_output):
   experiments.InExperiment = mock.MagicMock(
       side_effect=[(True, ''), (False, '')])
   mock_getexp.return_value = TWO_SAMPLE_EXPERIMENTS
   experiments.main([])
   self.assertTrue(mock_getexp.called)
   self.assertEqual(2, mock_output.call_count)
Esempio n. 2
0
 def testMainWithoutOptions(self, mock_getexp, mock_output):
     experiments.InExperiment = mock.MagicMock(side_effect=[(True,
                                                             ''), (False,
                                                                   '')])
     mock_getexp.return_value = TWO_SAMPLE_EXPERIMENTS
     experiments.main([])
     self.assertTrue(mock_getexp.called)
     self.assertEqual(2, mock_output.call_count)
Esempio n. 3
0
 def testMainRecommended(self, mock_mml):
   experiments.os.geteuid = mock.MagicMock(return_value=0)
   experiments.main(['', '-r', 'foo'])
   mock_mml.assert_has_calls([
       mock.call('add', mock.ANY, None),
       mock.call('remove', mock.ANY, None),
       mock.call('add', mock.ANY, None),
       mock.call('remove', mock.ANY, None),
       mock.call('remove', mock.ANY, 'foo')])
Esempio n. 4
0
 def testMainRecommended(self, mock_mml):
     experiments.os.geteuid = mock.MagicMock(return_value=0)
     experiments.main(['', '-r', 'foo'])
     mock_mml.assert_has_calls([
         mock.call('add', mock.ANY, None),
         mock.call('remove', mock.ANY, None),
         mock.call('add', mock.ANY, None),
         mock.call('remove', mock.ANY, None),
         mock.call('remove', mock.ANY, 'foo')
     ])
Esempio n. 5
0
 def testMainWithFormatting(self, mock_getexp, mock_output, mock_inexp):
     mock_getexp.return_value = SAMPLE_50_EXPERIMENT
     experiments.main(['', '-F'])
     self.assertTrue(mock_getexp.called)
     self.assertTrue(mock_inexp.called)
     mock_output.assert_called_with('%s,false' % EXP_NAME)
Esempio n. 6
0
 def testMainWithDebugEmptyExperiments(self, mock_confl, mock_output):
     experiments.GetExperiments = mock.MagicMock(return_value={})
     experiments.main(['', '--debug'])
     mock_confl.assert_called_with(debug_level=experiments.logging.DEBUG,
                                   stderr=True)
     mock_output.assert_called_with('No experiments are currently running.')
Esempio n. 7
0
 def testMainWithoutOptionsEmptyExperiments(self, mock_output):
     experiments.GetExperiments = mock.MagicMock(return_value={})
     experiments.main([])
     mock_output.assert_called_with('No experiments are currently running.')
Esempio n. 8
0
 def testMainWithFormatting(self, mock_getexp, mock_output, mock_inexp):
   mock_getexp.return_value = SAMPLE_50_EXPERIMENT
   experiments.main(['', '-F'])
   self.assertTrue(mock_getexp.called)
   self.assertTrue(mock_inexp.called)
   mock_output.assert_called_with('%s,false' % EXP_NAME)
Esempio n. 9
0
 def testMainWithDebugEmptyExperiments(self, mock_confl, mock_output):
   experiments.GetExperiments = mock.MagicMock(return_value={})
   experiments.main(['', '--debug'])
   mock_confl.assert_called_with(debug_level=experiments.logging.DEBUG,
                                 stderr=True)
   mock_output.assert_called_with('No experiments are currently running.')
Esempio n. 10
0
 def testMainWithoutOptionsEmptyExperiments(self, mock_output):
   experiments.GetExperiments = mock.MagicMock(return_value={})
   experiments.main([])
   mock_output.assert_called_with('No experiments are currently running.')