Пример #1
0
 def test_generate_fills_in_a_stage_without_tasks(self):
     worksheet_mock = MagicMock()
     factory = WorksheetFactoryFake()
     factory.create = MagicMock(return_value=worksheet_mock)
     Caches._publish(name='irrelevant',
                     stages=[Stage(name='name',
                                   coordinates='coordinates',
                                   description='stage description',
                                   tasks=[])],
                     factory=factory)
     self.assertIn(call.update_cell(row=1, col=1, val='name'), worksheet_mock.mock_calls)
     self.assertIn(call.update_cell(row=1, col=2, val='coordinates'), worksheet_mock.mock_calls)
     self.assertIn(call.update_cell(row=2, col=1, val='stage description'), worksheet_mock.mock_calls)
Пример #2
0
 def test_merge_duplicate_variables_per_stage(self):
     worksheet_mock = MagicMock()
     factory = WorksheetFactoryFake()
     factory.create = MagicMock(return_value=worksheet_mock)
     Caches._publish(name='irrelevant',
                     stages=[Stage(name='irrelevant',
                                   coordinates='irrelevant',
                                   description='irrelevant',
                                   tasks=[Task(description='d1',
                                               variables='abc'), Task(description='d2',
                                                                      variables='abc')])],
                     factory=factory)
     self.assertIn(call.update_cell(row=3, col=1, val='d1\nd2'), worksheet_mock.mock_calls)
     self.assertIn(call.update_cell(row=3, col=2, val='a'), worksheet_mock.mock_calls)
     self.assertIn(call.update_cell(row=4, col=2, val='b'), worksheet_mock.mock_calls)
     self.assertIn(call.update_cell(row=5, col=2, val='c'), worksheet_mock.mock_calls)
     self.assertNotIn(call.update_cell(row=6, col=1, val='d2'), worksheet_mock.mock_calls)
     self.assertNotIn(call.update_cell(row=6, col=2, val='a'), worksheet_mock.mock_calls)
Пример #3
0
    def test_generate_fills_in_complex_stages(self):
        worksheet_mock = MagicMock()
        factory = WorksheetFactoryFake()
        factory.create = MagicMock(return_value=worksheet_mock)
        Caches._publish(name='irrelevant',
                        stages=[Stage(name='n1',
                                      coordinates='c1',
                                      description='sd1',
                                      tasks=[Task(description='d1',
                                                  variables='abc'), Task(description='d2',
                                                                         variables='d')]),
                                Stage(name='n2',
                                      coordinates='c2',
                                      description='sd2',
                                      tasks=[Task(description='d3',
                                                  variables='e'), Task(description='d4',
                                                                       variables='fghi')])],
                        factory=factory)
        self.assertIn(call.update_cell(row=1, col=1, val='n1'), worksheet_mock.mock_calls)
        self.assertIn(call.update_cell(row=1, col=2, val='c1'), worksheet_mock.mock_calls)
        self.assertIn(call.update_cell(row=2, col=1, val='sd1'), worksheet_mock.mock_calls)
        self.assertIn(call.update_cell(row=3, col=1, val='d1'), worksheet_mock.mock_calls)
        self.assertIn(call.update_cell(row=3, col=2, val='a'), worksheet_mock.mock_calls)
        self.assertIn(call.update_cell(row=4, col=2, val='b'), worksheet_mock.mock_calls)
        self.assertIn(call.update_cell(row=5, col=2, val='c'), worksheet_mock.mock_calls)
        self.assertIn(call.update_cell(row=6, col=1, val='d2'), worksheet_mock.mock_calls)
        self.assertIn(call.update_cell(row=6, col=2, val='d'), worksheet_mock.mock_calls)

        self.assertIn(call.update_cell(row=8, col=1, val='n2'), worksheet_mock.mock_calls)
        self.assertIn(call.update_cell(row=8, col=2, val='c2'), worksheet_mock.mock_calls)
        self.assertIn(call.update_cell(row=9, col=1, val='sd2'), worksheet_mock.mock_calls)
        self.assertIn(call.update_cell(row=10, col=1, val='d3'), worksheet_mock.mock_calls)
        self.assertIn(call.update_cell(row=10, col=2, val='e'), worksheet_mock.mock_calls)
        self.assertIn(call.update_cell(row=11, col=1, val='d4'), worksheet_mock.mock_calls)
        self.assertIn(call.update_cell(row=11, col=2, val='f'), worksheet_mock.mock_calls)
        self.assertIn(call.update_cell(row=12, col=2, val='g'), worksheet_mock.mock_calls)
        self.assertIn(call.update_cell(row=13, col=2, val='h'), worksheet_mock.mock_calls)
        self.assertIn(call.update_cell(row=14, col=2, val='i'), worksheet_mock.mock_calls)
Пример #4
0
 def test_generate_fills_in_two_stages_with_two_tasks(self):
     worksheet_mock = MagicMock()
     factory = WorksheetFactoryFake()
     factory.create = MagicMock(return_value=worksheet_mock)
     # from nose.tools import set_trace; set_trace()
     Caches._publish(name='irrelevant',
                     stages=[Stage(name='n1',
                                   coordinates='c1',
                                   description='sd1',
                                   tasks=[Task(description='d1',
                                               variables='v'), Task(description='d2',
                                                                    variables='w')]),
                             Stage(name='n2',
                                   coordinates='c2',
                                   description='sd2',
                                   tasks=[Task(description='d3',
                                               variables='y'), Task(description='d4',
                                                                    variables='z')])],
                     factory=factory)
     self.assertIn(call.update_cell(row=1, col=1, val='n1'), worksheet_mock.mock_calls)
     self.assertIn(call.update_cell(row=1, col=2, val='c1'), worksheet_mock.mock_calls)
     self.assertIn(call.update_cell(row=2, col=1, val='sd1'), worksheet_mock.mock_calls)
     self.assertIn(call.update_cell(row=3, col=1, val='d1'), worksheet_mock.mock_calls)
     self.assertIn(call.update_cell(row=3, col=2, val='v'), worksheet_mock.mock_calls)
     self.assertIn(call.update_cell(row=4, col=1, val='d2'), worksheet_mock.mock_calls)
     self.assertIn(call.update_cell(row=4, col=2, val='w'), worksheet_mock.mock_calls)
     self.assertIn(call.update_cell(row=6, col=1, val='n2'), worksheet_mock.mock_calls)
     self.assertIn(call.update_cell(row=6, col=2, val='c2'), worksheet_mock.mock_calls)
     self.assertIn(call.update_cell(row=7, col=1, val='sd2'), worksheet_mock.mock_calls)
     self.assertIn(call.update_cell(row=8, col=1, val='d3'), worksheet_mock.mock_calls)
     self.assertIn(call.update_cell(row=8, col=2, val='y'), worksheet_mock.mock_calls)
     self.assertIn(call.update_cell(row=9, col=1, val='d4'), worksheet_mock.mock_calls)
     self.assertIn(call.update_cell(row=9, col=2, val='z'), worksheet_mock.mock_calls)