Ejemplo n.º 1
0
    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
Ejemplo n.º 2
0
    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
Ejemplo n.º 3
0
    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
Ejemplo n.º 4
0
    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
Ejemplo n.º 5
0
 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)
Ejemplo n.º 6
0
 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)
Ejemplo n.º 7
0
    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
Ejemplo n.º 8
0
    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
Ejemplo n.º 9
0
    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
Ejemplo n.º 10
0
    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
Ejemplo n.º 11
0
    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
Ejemplo n.º 12
0
    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
Ejemplo n.º 13
0
    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
Ejemplo n.º 14
0
    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
Ejemplo n.º 15
0
    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
Ejemplo n.º 16
0
    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
Ejemplo n.º 17
0
    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
Ejemplo n.º 18
0
    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
Ejemplo n.º 19
0
    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
Ejemplo n.º 20
0
    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
Ejemplo n.º 21
0
    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
Ejemplo n.º 22
0
 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)
Ejemplo n.º 23
0
 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)
Ejemplo n.º 24
0
 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)
Ejemplo n.º 25
0
 def test_6(self):
     """ Facility -> No Input -> FAIL """
     with mock.patch('__builtin__.input', side_effect=['', '', '']):
         with self.assertRaises(SystemExit):
             ask_sif(f=True)
Ejemplo n.º 26
0
 def test_4(self):
     """ Instrument -> No Input -> FAIL """
     with mock.patch('__builtin__.input', side_effect=['', '', '']):
         with self.assertRaises(SystemExit):
             ask_sif(i=True)
Ejemplo n.º 27
0
 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)
Ejemplo n.º 28
0
 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)