Exemplo n.º 1
0
    def test_module_wraps_config_set(self):
        cfg = Mock(Config)

        m = Module(cfg, Messages())
        m.set('an.entry', 42)
        m.set('path', 'str-value')

        self.assert_equal(
            [call.set('an.entry', 42),
             call.set('path', 'str-value')], cfg.mock_calls)
Exemplo n.º 2
0
    def test_view(self):
        # Run test
        view()

        # Evaluate test
        calls = [
            call.set(contactlist[1][0])
        ]
        addbook.__main__.name.assert_has_calls(calls)
        calls = [
            call.set(contactlist[1][1])
        ]
        addbook.__main__.number.assert_has_calls(calls)
Exemplo n.º 3
0
 def test_gauge(self):
     """Tests setting a gauge with ``R.gauge``. Verifies that the gauge slug
     is added to the set of gauge slugs and that the value gets set."""
     self.r.gauge('test-gauge', 9000)
     self.redis.assert_has_calls([
         call.sadd(self.r._gauge_slugs_key, 'test-gauge'),
         call.set('g:test-gauge', 9000),
     ])
 def test_gauge(self):
     """Tests setting a gauge with ``R.gauge``. Verifies that the gauge slug
     is added to the set of gauge slugs and that the value gets set."""
     self.r.gauge('test-gauge', 9000)
     self.redis.assert_has_calls([
         call.sadd(self.r._gauge_slugs_key, 'test-gauge'),
         call.set('g:test-gauge', 9000),
     ])
    def test_update_sampling_rate(self):
        sample_rates = [2400000000.0, 1200000000.0, 600000000.0, 300000000.0, 150000000.0, 75000000.0, 37500000.0,
                        18750000.0, 9375000.0, 4687500.0, 2343750.0, 1171875.0, 585937.5, 292968.75]

        for sample_rate in sample_rates:
            self.zi_hdawg8.update_sampling_rate(sample_rate)
        calls = [call.set('awgs_0_time', i) for i in range(0, 14)]
        self.awg.assert_has_calls(calls)

        with self.assertRaises(ValueError):
            self.zi_hdawg8.update_sampling_rate(99)
Exemplo n.º 6
0
    def test_reset(self):
        """Test is the field reset to empty string"""
        # Run test
        reset()

        # Evaluate test
        calls = [
            call.set("")
        ]
        addbook.__main__.name.assert_has_calls(calls)
        addbook.__main__.number.assert_has_calls(calls)
Exemplo n.º 7
0
    def test_method_uncached(self):
        """When the method has not been cached, it should set the cache."""
        with patch("utils.decorators.cache") as mock_cache:
            mock_cache.get.return_value = None  # Ensure first call returns None

            k = self.Klass()
            k.meth(self.obj)  # 1st call, cache should get set

            # check for cache calls.
            mock_cache.assert_has_calls([
                call.get("5-test"),
                call.set("5-test", "result", timeout=99),
            ])
Exemplo n.º 8
0
    def testCreateFullConfigIfItDoesNotExists(self, makedirs_patch,
                                              patch_exists):
        patch_exists.return_value = False
        makedirs_patch.return_value = None

        config_mock = MagicMock()

        test_object = Tomaatti()
        test_object.toggle_timer = MagicMock()
        test_object._persist_current_state = MagicMock()
        test_object.initialize(config_mock)

        config_mock.add_section.assert_has_calls(
            [call('timer'),
             call('ui'),
             call('periods'),
             call('experimental')],
            any_order=True)
        config_mock.assert_has_calls([
            call.set('timer', 'mode', str(TimerType.WORKING.value[0])),
            call.set('periods', 'working', '25'),
            call.set('periods', 'break', '5')
        ],
                                     any_order=True)
Exemplo n.º 9
0
 def test_update_gain(self):
     self.zi_hdawg8.update_gain(0.5)
     calls = [
         call.set('sigouts_{}_range'.format(ch), 0.5) for ch in range(8)
     ]
     self.awg.assert_has_calls(calls)
 def test_update_gain(self):
     self.zi_hdawg8.update_gain(0.5)
     calls = [call.set(f'sigouts_{ch}_range', 1.0) for ch in range(8)]
     self.awg.assert_has_calls(calls)