Пример #1
0
    def test_clean_keep_last(self):
        first = self._empty_ingest()

        assert_equal(self.clean("bundle", keep_last=1, environ=self.environ), set())
        assert_equal(self._list_bundle(), {first}, msg="directory should not have changed")

        second = self._empty_ingest()
        assert_equal(self._list_bundle(), {first, second}, msg="two ingestions are not present")
        assert_equal(self.clean("bundle", keep_last=1, environ=self.environ), {first})
        assert_equal(self._list_bundle(), {second}, msg="first ingestion was not removed with keep_last=2")

        third = self._empty_ingest()
        fourth = self._empty_ingest()
        fifth = self._empty_ingest()

        assert_equal(
            self._list_bundle(), {second, third, fourth, fifth}, msg="larger set of ingestions did not happen correctly"
        )

        assert_equal(self.clean("bundle", keep_last=2, environ=self.environ), {second, third})

        assert_equal(
            self._list_bundle(), {fourth, fifth}, msg="keep_last=2 did not remove the correct number of ingestions"
        )

        with assert_raises(BadClean):
            self.clean("bundle", keep_last=-1, environ=self.environ)

        assert_equal(self._list_bundle(), {fourth, fifth}, msg="keep_last=-1 removed some ingestions")

        assert_equal(self.clean("bundle", keep_last=0, environ=self.environ), {fourth, fifth})

        assert_equal(self._list_bundle(), set(), msg="keep_last=0 did not remove the correct number of ingestions")
Пример #2
0
    def test_load_no_data(self):
        # register but do not ingest data
        self.register("bundle", lambda *args: None)

        ts = pd.Timestamp("2014", tz="UTC")

        with assert_raises(ValueError) as e:
            self.load("bundle", timestamp=ts, environ=self.environ)

        assert_in("no data for bundle 'bundle' on or before %s" % ts, str(e.exception))
Пример #3
0
    def test_load_no_data(self):
        # register but do not ingest data
        self.register('bundle', lambda *args: None)

        ts = pd.Timestamp('2014', tz='UTC')

        with assert_raises(ValueError) as e:
            self.load('bundle', timestamp=ts, environ=self.environ)

        assert_in(
            "no data for bundle 'bundle' on or before %s" % ts,
            str(e.exception),
        )
Пример #4
0
    def test_parameterized_term_non_hashable_arg(self):
        with assert_raises(TypeError) as e:
            self.SomeFactorParameterized(a=[], b=1)
        assert_equal(
            str(e.exception),
            "SomeFactorParameterized expected a hashable value for parameter"
            " 'a', but got [] instead.",
        )

        with assert_raises(TypeError) as e:
            self.SomeFactorParameterized(a=1, b=[])
        assert_equal(
            str(e.exception),
            "SomeFactorParameterized expected a hashable value for parameter"
            " 'b', but got [] instead.",
        )

        with assert_raises(TypeError) as e:
            self.SomeFactorParameterized(a=[], b=[])
        assert_equal(
            str(e.exception),
            "SomeFactorParameterized expected a hashable value for parameter"
            " 'a', but got [] instead.",
        )
Пример #5
0
    def test_parameterized_term_non_hashable_arg(self):
        with assert_raises(TypeError) as e:
            self.SomeFactorParameterized(a=[], b=1)
        assert_equal(
            str(e.exception),
            "SomeFactorParameterized expected a hashable value for parameter"
            " 'a', but got [] instead.",
        )

        with assert_raises(TypeError) as e:
            self.SomeFactorParameterized(a=1, b=[])
        assert_equal(
            str(e.exception),
            "SomeFactorParameterized expected a hashable value for parameter"
            " 'b', but got [] instead.",
        )

        with assert_raises(TypeError) as e:
            self.SomeFactorParameterized(a=[], b=[])
        assert_regex(
            str(e.exception),
            r"SomeFactorParameterized expected a hashable value for parameter"
            r" '(a|b)', but got \[\] instead\.",
        )
Пример #6
0
    def test_bundle_doesnt_exist(self, fnname):
        with assert_raises(UnknownBundle) as e:
            getattr(self, fnname)('ayy', environ=self.environ)

        assert_equal(e.exception.name, 'ayy')
Пример #7
0
    def test_bundle_doesnt_exist(self, fnname):
        with assert_raises(UnknownBundle) as e:
            getattr(self, fnname)('ayy', environ=self.environ)

        assert_equal(e.exception.name, 'ayy')
Пример #8
0
    def test_clean_keep_last(self):
        first = self._empty_ingest()

        assert_equal(
            self.clean('bundle', keep_last=1, environ=self.environ),
            set(),
        )
        assert_equal(
            self._list_bundle(),
            {first},
            msg='directory should not have changed',
        )

        second = self._empty_ingest()
        assert_equal(
            self._list_bundle(),
            {first, second},
            msg='two ingestions are not present',
        )
        assert_equal(
            self.clean('bundle', keep_last=1, environ=self.environ),
            {first},
        )
        assert_equal(
            self._list_bundle(),
            {second},
            msg='first ingestion was not removed with keep_last=2',
        )

        third = self._empty_ingest()
        fourth = self._empty_ingest()
        fifth = self._empty_ingest()

        assert_equal(
            self._list_bundle(),
            {second, third, fourth, fifth},
            msg='larger set of ingestions did not happen correctly',
        )

        assert_equal(
            self.clean('bundle', keep_last=2, environ=self.environ),
            {second, third},
        )

        assert_equal(
            self._list_bundle(),
            {fourth, fifth},
            msg='keep_last=2 did not remove the correct number of ingestions',
        )

        with assert_raises(BadClean):
            self.clean('bundle', keep_last=-1, environ=self.environ)

        assert_equal(
            self._list_bundle(),
            {fourth, fifth},
            msg='keep_last=-1 removed some ingestions',
        )

        assert_equal(
            self.clean('bundle', keep_last=0, environ=self.environ),
            {fourth, fifth},
        )

        assert_equal(
            self._list_bundle(),
            set(),
            msg='keep_last=0 did not remove the correct number of ingestions',
        )