def test_5(self): """ 'None' -> PASS """ with mock.patch('__builtin__.input', side_effect=['']): result = get_date(self.today, self.message) expected = self.today print("Result: {}\nExpected: {}".format(result, expected)) assert result == expected
def test_10(self): """ VAP -> Facility -> No Input -> PASS """ with mock.patch('__builtin__.input', side_effect=['']): result = ask_sif(f=None, vap=True)[2] expected = '' print("Result: {}\nExpected: {}".format(result, expected)) assert result == expected
def test_3(self): """ No input -> PASS """ with mock.patch('__builtin__.input', side_effect=['', '', '']): result = ask_for_dir(self.message) expected = None print("Result: {}\nExpected: {}".format(result, expected)) assert result == expected
def test_3(self): """ 'None' -> 'non-numberic' -> 'valid date' -> PASS """ with mock.patch('__builtin__.input', side_effect=['', 'asdf', self.today]): result = get_date(0, self.message) expected = self.today print("Result: {}\nExpected: {}".format(result, expected)) assert result == expected
def test_9(self): """ Supply begin date, test end date -> FAIL """ self.config['interactive'] = True self.config['begin'] = 0 self.config['end'] = 0 with mock.patch('__builtin__.input', side_effect=[self.today, '', '', '']): with self.assertRaises(SystemExit): check_dates(self.config)
def test_8(self): """ No supplied dates, No passed dates -> FAIL """ self.config['interactive'] = True self.config['begin'] = 0 self.config['end'] = 0 with mock.patch('__builtin__.input', side_effect=['', '', '']): with self.assertRaises(SystemExit): check_dates(self.config)
def test_5(self): """ Instrument -> Good Input -> PASS """ with mock.patch('__builtin__.input', side_effect=[self.config['instrument']]): result = ask_sif(i=None) expected = (False, self.config['instrument'], False) print("Result: {}\nExpected: {}".format(result, expected)) assert result == expected
def test_3(self): """ Site -> Good Input -> PASS """ with mock.patch('__builtin__.input', side_effect=[self.config['site']]): result = ask_sif(s=None) expected = (self.config['site'], False, False) print("Result: {}\nExpected: {}".format(result, expected)) assert result == expected
def test_7(self): """ Facility -> Good Input -> PASS """ with mock.patch('__builtin__.input', side_effect=[self.config['facility']]): result = ask_sif(f=None) expected = (False, False, self.config['facility']) print("Result: {}\nExpected: {}".format(result, expected)) assert result == expected
def test_8(self): """ All -> Good Input -> PASS """ with mock.patch('__builtin__.input', side_effect=[self.config['site'], self.config['instrument'], self.config['facility']]): result = ask_sif(s=None, i=None, f=None) expected = (self.config['site'], self.config['instrument'], self.config['facility']) print("Result: {}\nExpected: {}".format(result, expected)) assert result == expected
def test_1(self): """ Default -> No input -> PASS """ self.stage = self.default['stage'] with mock.patch('__builtin__.input', side_effect=['']): result = ask_for_dir(self.message, default=self.default['stage']) expected = self.default['stage'] print("Result: {}\nExpected: {}".format(result, expected)) assert result == expected
def test_16(self): """ None -> Interactive -> No input -> PASS """ self.config['interactive'] = True with mock.patch('__builtin__.input', side_effect=['']): result = check_stage(self.config) expected = '/data/home/{0}/apm'.format(self.config['username']) print("Result: {}\nExpected: {}".format(result, expected)) assert result == expected
def test_8(self): """ None -> Interactive -> No input -> PASS """ self.config['interactive'] = True with mock.patch('__builtin__.input', side_effect=['']): result = check_source(self.config) expected = self.default['source'] print("Result: {}\nExpected: {}".format(result, expected)) assert result == expected
def test_5(self): """ Dir -> Not exists -> Not empty -> PASS """ self.config['source'] = self.alt['source']['not_exists'] with mock.patch('__builtin__.input', side_effect=[self.default['source']]): result = check_source(self.config) expected = self.default['source'] print("Result: {}\nExpected: {}".format(result, expected)) assert result == expected
def test_7(self): """ Supply new dates even though dates already provided """ self.config['interactive'] = True with mock.patch('__builtin__.input', side_effect=[self.earlier, self.today]): result = check_dates(self.config) expected = (self.earlier, self.today) print("Result: {}\nExpected: {}".format(result, expected)) assert result == expected
def test_6(self): """ Ask for dates even with dates given """ self.config['interactive'] = True with mock.patch('__builtin__.input', side_effect=['', '']): result = check_dates(self.config) expected = (self.begin, self.end) print("Result: {}\nExpected: {}".format(result, expected)) assert result == expected
def test_14(self): """ SIF -> Interactive -> Ask for all 3 -> PASS """ self.config['interactive'] = True with mock.patch('__builtin__.input', side_effect=[self.config['site'], self.config['instrument'], self.config['facility']]): result = check_sif_datastream(self.config) expected = (self.config['site'], self.config['instrument'], self.config['facility'], None) print("Result: {}\nExpected: {}".format(result, expected)) assert result == expected
def test_14(self): """ No end date -> PASS """ self.config['end'] = 0 with mock.patch('__builtin__.input', side_effect=[self.end]): result = check_dates(self.config) expected = (self.begin, self.end) print("Result: {}\nExpected: {}".format(result, expected)) assert result == expected
def test_17(self): """ None -> Interactive -> Dir -> PASS """ self.stage = self.alt['stage']['new'] self.config['interactive'] = True with mock.patch('__builtin__.input', side_effect=[self.stage]): result = check_stage(self.config) expected = self.stage print("Result: {}\nExpected: {}".format(result, expected)) assert result == expected
def test_2(self): """ No Job -> Interactive -> Job Name -> PASS """ self.config['job'] = None self.config['interactive'] = True with mock.patch('__builtin__.input', side_effect=['test']): result = check_job(self.config) expected = 'test' print("Result: {}\nExpected: {}".format(result, expected)) assert result == expected
def test_3(self): """ No Job -> Interactive -> No Job -> PASS """ files = set(os.listdir(self.stage)) self.config['job'] = None self.config['interactive'] = True with mock.patch('__builtin__.input', side_effect=['']): result = check_job(self.config) expected = self.get_job(files) if self.get_job(files) != None else os.listdir(self.stage)[0] print("Result: {}\nExpected: {}".format(result, expected)) assert result == expected
def test_2(self): """ Required -> No input -> FAIL """ with mock.patch('__builtin__.input', side_effect=['', '', '']): with self.assertRaises(SystemExit): ask_for_dir(self.message, required=True, error=self.error)
def test_7(self): """ Dir -> Exists -> Empty -> FAIL """ self.config['source'] = self.alt['source']['empty'] with mock.patch('__builtin__.input', side_effect=['', '', '']): with self.assertRaises(SystemExit): check_source(self.config)
def test_15(self): """ Dir -> Exists -> Not Writable -> FAIL """ self.config['stage'] = self.alt['stage']['not_writable'] with mock.patch('__builtin__.input', side_effect=['', '', '']): with self.assertRaises(SystemExit): check_stage(self.config)
def test_6(self): """ Facility -> No Input -> FAIL """ with mock.patch('__builtin__.input', side_effect=['', '', '']): with self.assertRaises(SystemExit): ask_sif(f=True)
def test_4(self): """ Instrument -> No Input -> FAIL """ with mock.patch('__builtin__.input', side_effect=['', '', '']): with self.assertRaises(SystemExit): ask_sif(i=True)
def test_2(self): """ Site -> Too Short Input -> Too Long Input -> No Input -> FAIL """ with mock.patch('__builtin__.input', side_effect=['as', 'asdf', '']): with self.assertRaises(SystemExit): ask_sif(s=True)
def test_2(self): """ Non-numeric input -> FAIL """ with mock.patch('__builtin__.input', side_effect=['asdf', 'asdf', 'asdf']): with self.assertRaises(SystemExit): get_date(0, self.message)