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)
Beispiel #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)
 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')])
Beispiel #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')
     ])
Beispiel #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)
Beispiel #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.')
Beispiel #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.')
 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)
 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.')
 def testMainWithoutOptionsEmptyExperiments(self, mock_output):
   experiments.GetExperiments = mock.MagicMock(return_value={})
   experiments.main([])
   mock_output.assert_called_with('No experiments are currently running.')