Exemple #1
0
    def test_parameter_parse_and_default(self):
        month = luigi.date_interval.Month(2012, 11)
        other = luigi.date_interval.Month(2012, 10)

        class MyTask(luigi.Task):
            di = DI(default=month)

        class MyTaskNoDefault(luigi.Task):
            di = DI()

        self.assertEqual(MyTask().di, month)
        in_parse(["MyTask", "--di", "2012-10"],
                 lambda task: self.assertEqual(task.di, other))
        task = MyTask(month)
        self.assertEqual(task.di, month)
        task = MyTask(di=month)
        self.assertEqual(task.di, month)
        task = MyTask(other)
        self.assertNotEqual(task.di, month)

        def fail1():
            return MyTaskNoDefault()

        self.assertRaises(luigi.parameter.MissingParameterException, fail1)

        in_parse(["MyTaskNoDefault", "--di", "2012-10"],
                 lambda task: self.assertEqual(task.di, other))
Exemple #2
0
    def test_parameter_parse_and_default(self):
        month = luigi.date_interval.Month(2012, 11)
        other = luigi.date_interval.Month(2012, 10)

        class MyTask(luigi.Task):
            di = DI(default=month)

        class MyTaskNoDefault(luigi.Task):
            di = DI()

        self.assertEqual(MyTask().di, month)
        in_parse(["MyTask", "--di", "2012-10"],
                 lambda task: self.assertEqual(task.di, other))
        task = MyTask(month)
        self.assertEqual(task.di, month)
        task = MyTask(di=month)
        self.assertEqual(task.di, month)
        task = MyTask(other)
        self.assertNotEqual(task.di, month)

        def fail1():
            return MyTaskNoDefault()
        self.assertRaises(luigi.parameter.MissingParameterException, fail1)

        in_parse(["MyTaskNoDefault", "--di", "2012-10"],
                 lambda task: self.assertEqual(task.di, other))
    def test_subclasses(self):
        class BarBaseClass(luigi.Task):
            x = luigi.Parameter(default="bar_base_default")

        class BarSubClass(BarBaseClass):
            pass

        in_parse(["BarSubClass", "--x", "xyz", "--BarBaseClass-x", "xyz"], lambda task: self.assertEqual(task.x, "xyz"))

        # https://github.com/spotify/luigi/issues/822#issuecomment-77782714
        in_parse(["BarBaseClass", "--BarBaseClass-x", "xyz"], lambda task: self.assertEqual(task.x, "xyz"))
Exemple #4
0
    def test_subclasses(self):
        class BarBaseClass(luigi.Task):
            x = luigi.Parameter(default='bar_base_default')

        class BarSubClass(BarBaseClass):
            pass

        in_parse(['BarSubClass', '--x', 'xyz', '--BarBaseClass-x', 'xyz'],
                 lambda task: self.assertEqual(task.x, 'xyz'))

        # https://github.com/spotify/luigi/issues/822#issuecomment-77782714
        in_parse(['BarBaseClass', '--BarBaseClass-x', 'xyz'],
                 lambda task: self.assertEqual(task.x, 'xyz'))
Exemple #5
0
 def test_parse_interface(self):
     in_parse([
         "DictParameterTask", "--param",
         '{"username": "******", "password": "******"}'
     ], lambda task: self.assertEqual(task.param, DictParameterTest._dict))
 def test_parse_interface(self):
     in_parse(["DateHourTask", "--dh", "2013-02-01T18"],
              lambda task: self.assertEqual(
                  task.dh, datetime.datetime(2013, 2, 1, 18, 0, 0)))
 def test_parse_interface(self):
     in_parse(
         ["DateTask", "--day", "2015-04-03"],
         lambda task: self.assertEqual(task.day, datetime.date(2015, 4, 3)))
 def test_parse_interface(self):
     in_parse([
         "YearTask", "--year", "2015"
     ], lambda task: self.assertEqual(task.year, datetime.date(2015, 1, 1)))
 def test_parse_interface(self):
     in_parse(["MonthTask", "--month", "2015-04"],
              lambda task: self.assertEqual(task.month,
                                            datetime.date(2015, 4, 1)))
 def test_parse_interface(self):
     in_parse(["DateSecondTask", "--ds", "2013-02-01T184227"],
              lambda task: self.assertEqual(
                  task.ds, datetime.datetime(2013, 2, 1, 18, 42, 27)))
Exemple #11
0
 def test_parse_interface(self):
     in_parse(["DateHourTask", "--dh", "2013-02-01T18"],
              lambda task: self.assertEqual(task.dh, datetime.datetime(2013, 2, 1, 18, 0, 0)))
Exemple #12
0
 def test_parse_interface(self):
     in_parse(["DateTask", "--day", "2015-04-03"],
              lambda task: self.assertEqual(task.day, datetime.date(2015, 4, 3)))
Exemple #13
0
 def test_parse_interface(self):
     in_parse(["YearTask", "--year", "2015"],
              lambda task: self.assertEqual(task.year, datetime.date(2015, 1, 1)))
Exemple #14
0
 def test_parse_interface(self):
     in_parse(["MonthTask", "--month", "2015-04"],
              lambda task: self.assertEqual(task.month, datetime.date(2015, 4, 1)))
Exemple #15
0
 def test_parse_interface(self):
     in_parse(["DateMinuteTask", "--dm", "2013-02-01T1842"],
              lambda task: self.assertEqual(task.dm, datetime.datetime(2013, 2, 1, 18, 42, 0)))
Exemple #16
0
 def test_parse_interface(self):
     in_parse(["DateSecondTask", "--ds", "2013-02-01T184227"],
              lambda task: self.assertEqual(task.ds, datetime.datetime(2013, 2, 1, 18, 42, 27)))
 def test_parse_interface(self):
     in_parse(["DateMinuteTask", "--dm", "2013-02-01T1842"],
              lambda task: self.assertEqual(
                  task.dm, datetime.datetime(2013, 2, 1, 18, 42, 0)))
Exemple #18
0
 def test_parse_interface(self):
     in_parse(["DictParameterTask", "--param", '{"username": "******", "password": "******"}'],
              lambda task: self.assertEqual(task.param, DictParameterTest._dict))