Ejemplo n.º 1
0
    def test_not_existing_matrix(self):
        """Testing get_stage for a matrix that does not exist."""
        store = Store()
        item = CollectorUpdate(
            stage='Build', status='started',
            timestamp=int(time.time()), information={'language': 'java'})
        store.update(item)

        stage = store.get_stage('test', 'Build')
        assert_that(stage, equal_to(None))
Ejemplo n.º 2
0
    def test_matrix_duration(self):
        """Testing matrix duration."""
        now = datetime.now()
        timestamp_started = int(time.mktime(now.timetuple()))
        timestamp_succeeded = int(time.mktime((now + timedelta(seconds=60)).timetuple()))

        store = Store()
        assert_that(store.get_duration('default'), equal_to(0))

        item = CollectorUpdate(
            stage='Build', status='started', timestamp=timestamp_started, information={'language': 'java'})
        store.update(item)
        assert_that(store.get_duration('default'), equal_to(0))

        item = CollectorUpdate(stage='Build', status='succeeded', timestamp=timestamp_succeeded)
        store.update(item)

        duration = store.get_duration('default')
        assert_that(duration >= 59 and duration <= 61, equal_to(True))
Ejemplo n.º 3
0
    def test_update_existing(self):
        """Testing updating an existing stage."""
        store = Store()
        item = CollectorUpdate(
            stage='Build', status='started',
            timestamp=int(time.time()), information={'language': 'java'})
        store.update(item)

        item = CollectorUpdate(
            stage='Build', status='succeeded',
            timestamp=int(time.time()))
        store.update(item)

        assert_that(store.count_matrixes(), equal_to(1))
        assert_that(store.count_stages('default'), equal_to(1))

        stage = store.get_stage('default', 'Build')
        assert_that(stage.stage, equal_to('Build'))
        assert_that(stage.status, equal_to('succeeded'))
        assert_that(len(stage.events), equal_to(2))
Ejemplo n.º 4
0
    def test_update_first(self):
        """Testing creating a stage."""
        store = Store()
        item = CollectorUpdate(
            stage='Build', status='started',
            timestamp=int(time.time()), information={'language': 'java'})
        store.update(item)

        stage = store.get_stage('default', 'Build')
        assert_that(stage.stage, equal_to('Build'))

        assert_that(store.count_matrixes(), equal_to(1))
        assert_that(store.count_stages('default'), equal_to(1))
Ejemplo n.º 5
0
 def test_write(self):
     """Testing normal write without really writing to a file."""
     with patch("os.makedirs") as mocked_make_dirs:
         with patch("spline.tools.report.generator.generate_html"
                    ) as mocked_generate_html:
             mocked_generate_html.return_value = '<html></html>'
             stream = MagicMock()
             with patch(
                     "spline.tools.report.generator.open") as mocked_open:
                 mocked_open.return_value = stream
                 assert_that(generate(Store(), 'html', '/tmp/html'),
                             equal_to(True))
                 mocked_make_dirs.assert_called_once_with('/tmp/html')
             assert_that(stream.mock_calls[1],
                         equal_to(call.__enter__().write('<html></html>')))
Ejemplo n.º 6
0
 def test_configure(self):
     """Testing assigning the document."""
     store = Store()
     store.configure({'test': 'test'})
     # no magic ... document is used by the templates (that's all)
     assert_that(store.document, equal_to({'test': 'test'}))
Ejemplo n.º 7
0
 def test_clear(self):
     """Testing deletion of data."""
     store = Store()
     store.data = {'test': 'test'}
     store.clear()
     assert_that(len(store.data), equal_to(0))
Ejemplo n.º 8
0
 def test_failed_rendering(self):
     """Testing failed rendering."""
     with patch("spline.tools.report.generator.render") as mocked_render:
         mocked_render.return_value = None
         assert_that(generate(Store(), 'html', '/tmp'), equal_to(False))
Ejemplo n.º 9
0
 def test_generate_html(self):
     """Testing html generation."""
     html = generate_html(Store())
     assert_that(html.find('Spline - Pipeline Visualization'),
                 greater_than(0))