Ejemplo n.º 1
0
    def test_uses_given_id(self):
        """Ensure an id passed in is used."""
        from furious.async import Async

        job = Async("somehting", id="superrandom")

        self.assertEqual(job.id, "superrandom")
        self.assertEqual(job.get_options()["id"], "superrandom")
Ejemplo n.º 2
0
    def test_uses_given_id(self):
        """Ensure an id passed in is used."""
        from furious. async import Async

        job = Async('somehting', id='superrandom')

        self.assertEqual(job.id, 'superrandom')
        self.assertEqual(job.get_options()['id'], 'superrandom')
Ejemplo n.º 3
0
    def test_uses_given_id(self):
        """Ensure an id passed in is used."""
        from furious.async import Async

        job = Async('somehting', id='superrandom')

        self.assertEqual(job.id, 'superrandom')
        self.assertEqual(job.get_options()['id'], 'superrandom')
Ejemplo n.º 4
0
    def test_update_id(self):
        """Ensure using update options to update an id works."""
        from furious.async import Async

        job = Async("somehting")
        job.update_options(id="newid")

        self.assertEqual(job.id, "newid")
        self.assertEqual(job.get_options()["id"], "newid")
Ejemplo n.º 5
0
    def test_update_id(self):
        """Ensure using update options to update an id works."""
        from furious.async import Async

        job = Async('somehting')
        job.update_options(id='newid')

        self.assertEqual(job.id, 'newid')
        self.assertEqual(job.get_options()['id'], 'newid')
Ejemplo n.º 6
0
    def test_update_id(self):
        """Ensure using update options to update an id works."""
        from furious. async import Async

        job = Async('somehting')
        job.update_options(id='newid')

        self.assertEqual(job.id, 'newid')
        self.assertEqual(job.get_options()['id'], 'newid')
Ejemplo n.º 7
0
    def test_get_options(self):
        """Ensure get_options returns the job options."""
        from furious.async import Async

        options = {"value": 1, "other": "zzz", "nested": {1: 1}}

        job = Async("nonexistant")
        job._options = options

        self.assertEqual(options, job.get_options())
Ejemplo n.º 8
0
    def test_get_options(self):
        """Ensure get_options returns the job options."""
        from furious.async import Async

        options = {'value': 1, 'other': 'zzz', 'nested': {1: 1}}

        job = Async("nonexistant")
        job._options = options

        self.assertEqual(options, job.get_options())
Ejemplo n.º 9
0
    def test_get_options(self):
        """Ensure get_options returns the job options."""
        from furious. async import Async

        options = {'value': 1, 'other': 'zzz', 'nested': {1: 1}}

        job = Async("nonexistant")
        job._options = options

        self.assertEqual(options, job.get_options())
Ejemplo n.º 10
0
    def test_generates_id(self, uuid_patch):
        """Ensure an id is auto-generated if not specified."""
        from furious.async import Async

        id = "random-id"
        uuid_patch.return_value.hex = id

        job = Async("somehting")

        self.assertEqual(job.id, id)
        self.assertEqual(job.get_options()["id"], id)
Ejemplo n.º 11
0
    def test_generates_id(self, uuid_patch):
        """Ensure an id is auto-generated if not specified."""
        from furious. async import Async

        id = 'random-id'
        uuid_patch.return_value.hex = id

        job = Async('somehting')

        self.assertEqual(job.id, id)
        self.assertEqual(job.get_options()['id'], id)
Ejemplo n.º 12
0
    def test_update_recursion_level_defaults(self):
        """Ensure that defaults (1, MAX_DEPTH) are set correctly."""
        from furious. async import Async
        from furious. async import MAX_DEPTH

        async_job = Async("something")

        async_job._increment_recursion_level()

        options = async_job.get_options()['_recursion']
        self.assertEqual(1, options['current'])
        self.assertEqual(MAX_DEPTH, options['max'])
Ejemplo n.º 13
0
    def test_update_recursion_level_defaults(self):
        """Ensure that defaults (1, MAX_DEPTH) are set correctly."""
        from furious.async import Async
        from furious.async import MAX_DEPTH

        async_job = Async("something")

        async_job._increment_recursion_level()

        options = async_job.get_options()["_recursion"]
        self.assertEqual(1, options["current"])
        self.assertEqual(MAX_DEPTH, options["max"])
Ejemplo n.º 14
0
    def test_check_recursion_level_execution_context(self):
        """Ensure that when there is an existing Async that the correct values
        are pulled and incremented from there, not the defaults.
        """
        from furious.async import Async
        from furious.context import execution_context_from_async

        context_async = Async("something", _recursion={"current": 42, "max": 77})
        new_async = Async("something_else")

        with execution_context_from_async(context_async):
            new_async._increment_recursion_level()

        self.assertEqual(43, new_async.recursion_depth)

        options = new_async.get_options()["_recursion"]
        self.assertEqual(77, options["max"])
Ejemplo n.º 15
0
    def test_check_recursion_level_overridden_interior_max(self):
        """Ensure that when there is an existing Async that the correct values
        are pulled and incremented from there, unless the interior Async sets
        it's own custom max.
        """
        from furious.async import Async
        from furious.context import execution_context_from_async

        context_async = Async("something", _recursion={"current": 42, "max": 77})

        new_async = Async("something_else", _recursion={"max": 89})

        with execution_context_from_async(context_async):
            new_async._increment_recursion_level()

        options = new_async.get_options()["_recursion"]
        self.assertEqual(43, options["current"])
        self.assertEqual(89, options["max"])
Ejemplo n.º 16
0
    def test_check_recursion_level_execution_context(self):
        """Ensure that when there is an existing Async that the correct values
        are pulled and incremented from there, not the defaults.
        """
        from furious. async import Async
        from furious.context import execution_context_from_async

        context_async = Async("something",
                              _recursion={
                                  'current': 42,
                                  'max': 77
                              })
        new_async = Async("something_else")

        with execution_context_from_async(context_async):
            new_async._increment_recursion_level()

        self.assertEqual(43, new_async.recursion_depth)

        options = new_async.get_options()['_recursion']
        self.assertEqual(77, options['max'])
Ejemplo n.º 17
0
    def test_check_recursion_level_overridden_interior_max(self):
        """Ensure that when there is an existing Async that the correct values
        are pulled and incremented from there, unless the interior Async sets
        it's own custom max.
        """
        from furious. async import Async
        from furious.context import execution_context_from_async

        context_async = Async("something",
                              _recursion={
                                  'current': 42,
                                  'max': 77
                              })

        new_async = Async("something_else", _recursion={'max': 89})

        with execution_context_from_async(context_async):
            new_async._increment_recursion_level()

        options = new_async.get_options()['_recursion']
        self.assertEqual(43, options['current'])
        self.assertEqual(89, options['max'])