Exemplo n.º 1
0
    def test_writes_stat_to_writer(self, fake_init, fake_run):
        fake_run.return_value = {"stat": 1}
        fake_init.return_value = None
        temp_fs = fsopendir("temp://")

        hdf_partition = HDFPartition(temp_fs, path="temp.h5")

        fake_reader = MagicMock()
        fake_writer = MagicMock(spec=HDFWriter)
        fake_set_stats = MagicMock()
        fake_writer.__enter__ = lambda x: fake_set_stats
        # FIXME: So complicated. Refactor.

        with patch.object(hdf_partition, "_reader", fake_reader):
            with patch.object(hdf_partition, "_writer", fake_writer):
                hdf_partition.run_stats()
                self.assertEqual(fake_set_stats.mock_calls, [call.set_stats({"stat": 1})])
Exemplo n.º 2
0
    def test_writes_stat_to_writer(self, fake_init, fake_run):
        fake_run.return_value = {'stat': 1}
        fake_init.return_value = None
        temp_fs = fsopendir('temp://')

        hdf_partition = HDFPartition(temp_fs, path='temp.h5')

        fake_reader = MagicMock()
        fake_writer = MagicMock(spec=HDFWriter)
        fake_set_stats = MagicMock()
        fake_writer.__enter__ = lambda x: fake_set_stats
        # FIXME: So complicated. Refactor.

        with patch.object(hdf_partition, '_reader', fake_reader):
            with patch.object(hdf_partition, '_writer', fake_writer):
                hdf_partition.run_stats()
                self.assertEqual(fake_set_stats.mock_calls,
                                 [call.set_stats({'stat': 1})])
Exemplo n.º 3
0
    def test_creates_stat_from_reader(self, fake_init, fake_run):
        fake_init.return_value = None
        fake_run.return_value = {"a": 1}
        temp_fs = fsopendir("temp://")

        hdf_partition = HDFPartition(temp_fs, path="temp.h5")

        with patch.object(hdf_partition, "_reader", MagicMock()):
            with patch.object(hdf_partition, "_writer", MagicMock()):
                ret = hdf_partition.run_stats()
                self.assertEqual(ret, {"a": 1})
Exemplo n.º 4
0
    def test_creates_stat_from_reader(self, fake_init, fake_run):
        fake_init.return_value = None
        fake_run.return_value = {'a': 1}
        temp_fs = fsopendir('temp://')

        hdf_partition = HDFPartition(temp_fs, path='temp.h5')

        with patch.object(hdf_partition, '_reader', MagicMock()):
            with patch.object(hdf_partition, '_writer', MagicMock()):
                ret = hdf_partition.run_stats()
                self.assertEqual(ret, {'a': 1})