Exemplo n.º 1
0
    def setUp(self):
        self.channel = channels.get_channel('polls')
        self.storage = self.channel.storage

        try:
            shutil.rmtree(self.storage.location)
        except OSError:
            pass
Exemplo n.º 2
0
    def setUp(self):
        self.channel = channels.get_channel('polls')
        self.storage = self.channel.storage

        try:
            shutil.rmtree(self.storage.location)
        except OSError:
            pass
Exemplo n.º 3
0
def inline(name, mimetype, offset, limit):
    datas = []

    channel = get_channel(name)

    for obj in channel.get_query(offset, limit):
        datas.append([channel.format(column, obj)
                      for column in channel.columns])

    channel.write(datas, mimetype, offset, limit)

    return offset, limit
Exemplo n.º 4
0
    def test_inline_task(self):
        tasks.inline('polls', 'csv', 0, 100)  # NOQA

        file_root = self.channel.get_file_root('csv', 0, 100)

        file = self.storage.open(file_root)

        lines = file.readlines()

        self.assertEqual(len(lines), 101)

        self.assertEqual(len(lines[0].split(',')), len(channels.get_channel('polls').columns))
Exemplo n.º 5
0
    def test_inline_task(self):
        with patch('__builtin__.open', create=True) as mock_open:
            mock_open.return_value = MagicMock(spec=file)

            tasks.inline('polls', 'csv', 0, 100) # NOQA

            file_handle = mock_open.return_value.__enter__.return_value

            datas = file_handle.write._mock_call_args[0][0].split('\n')

            self.assertEqual(len(datas), 102)

            self.assertEqual(len(datas[0].split(',')), len(channels.get_channel('polls').columns))
Exemplo n.º 6
0
    def test_inline_task(self):
        tasks.inline('polls', 'csv', 0, 100)  # NOQA

        file_root = self.channel.get_file_root('csv', 0, 100)

        file = self.storage.open(file_root)

        lines = file.readlines()

        self.assertEqual(len(lines), 101)

        self.assertEqual(len(lines[0].split(',')),
                         len(channels.get_channel('polls').columns))
Exemplo n.º 7
0
 def setUp(self):
     self.channel = channels.get_channel('polls')
Exemplo n.º 8
0
    def test_get_channel(self):
        channel = channels.get_channel('polls')

        self.assertTrue(isinstance(channel, PollExport))
Exemplo n.º 9
0
def generate_subtasks_builder(name, mimetype, chunks):
    return [inline.subtask((name, mimetype, i, chunks))
            for i in xrange(0, get_channel(name).get_count(), chunks)]
Exemplo n.º 10
0
def compute(offsets, **kwargs):
    channel = get_channel(kwargs.get('name'))
    channel.combine(offsets, kwargs.get('mimetype'))