Exemple #1
0
    def test__tabulate_rst(self):
        # Arrange
        data = copy.deepcopy(SAMPLE_DATA)
        expected_output = """
.. table:: 

    ==========  ============  ===========
     category       date       downloads 
    ==========  ============  ===========
          2.6    2018-08-15           51 
          2.7    2018-08-15       63,749 
          3.2    2018-08-15            2 
          3.3    2018-08-15           40 
          3.4    2018-08-15        6,095 
          3.5    2018-08-15       20,358 
          3.6    2018-08-15       35,274 
          3.7    2018-08-15        6,595 
          3.8    2018-08-15            3 
     null        2018-08-15        1,019 
    ==========  ============  ===========
"""  # noqa: W291

        # Act
        output = pypistats._tabulate(data, format="rst")

        # Assert
        self.assertEqual(output.strip(), expected_output.strip())
Exemple #2
0
    def test__tabulate(self, test_input: str, expected: str) -> None:
        # Arrange
        data = copy.deepcopy(SAMPLE_DATA)

        # Act
        output = pypistats._tabulate(data, format=test_input)

        # Assert
        assert output.strip() == expected.strip()
Exemple #3
0
    def test__tabulate_noarg(self) -> None:
        # Arrange
        data = copy.deepcopy(SAMPLE_DATA)
        expected_output = EXPECTED_TABULATED_MD

        # Act
        output = pypistats._tabulate(data)

        # Assert
        assert output.strip() == expected_output.strip()
Exemple #4
0
    def test_versions_are_strings(self) -> None:
        # Arrange
        data = copy.deepcopy(SAMPLE_DATA_VERSION_STRINGS)
        expected_output = """
| category |    date    | downloads |
|:---------|:----------:|----------:|
| 3.1      | 2018-08-15 |        10 |
| 3.10     | 2018-08-15 |         1 |
"""

        # Act
        output = pypistats._tabulate(data, format="markdown")

        # Assert
        assert output.strip() == expected_output.strip()
Exemple #5
0
    def test__tabulate_markdown(self):
        # Arrange
        data = copy.deepcopy(SAMPLE_DATA)
        expected_output = """
| category |    date    | downloads |
|----------|------------|----------:|
|      2.6 | 2018-08-15 |        51 |
|      2.7 | 2018-08-15 |    63,749 |
|      3.2 | 2018-08-15 |         2 |
|      3.3 | 2018-08-15 |        40 |
|      3.4 | 2018-08-15 |     6,095 |
|      3.5 | 2018-08-15 |    20,358 |
|      3.6 | 2018-08-15 |    35,274 |
|      3.7 | 2018-08-15 |     6,595 |
|      3.8 | 2018-08-15 |         3 |
| null     | 2018-08-15 |     1,019 |
"""

        # Act
        output = pypistats._tabulate(data, format="markdown")

        # Assert
        self.assertEqual(output.strip(), expected_output.strip())
Exemple #6
0
    def test__tabulate_html(self):
        # Arrange
        data = copy.deepcopy(SAMPLE_DATA)
        expected_output = """
<table>
    <thead>
        <tr>
            <th>category</th>
            <th>date</th>
            <th>downloads</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td align="right">2.6</td>
            <td align="left">2018-08-15</td>
            <td align="right">51</td>
        </tr>
        <tr>
            <td align="right">2.7</td>
            <td align="left">2018-08-15</td>
            <td align="right">63,749</td>
        </tr>
        <tr>
            <td align="right">3.2</td>
            <td align="left">2018-08-15</td>
            <td align="right">2</td>
        </tr>
        <tr>
            <td align="right">3.3</td>
            <td align="left">2018-08-15</td>
            <td align="right">40</td>
        </tr>
        <tr>
            <td align="right">3.4</td>
            <td align="left">2018-08-15</td>
            <td align="right">6,095</td>
        </tr>
        <tr>
            <td align="right">3.5</td>
            <td align="left">2018-08-15</td>
            <td align="right">20,358</td>
        </tr>
        <tr>
            <td align="right">3.6</td>
            <td align="left">2018-08-15</td>
            <td align="right">35,274</td>
        </tr>
        <tr>
            <td align="right">3.7</td>
            <td align="left">2018-08-15</td>
            <td align="right">6,595</td>
        </tr>
        <tr>
            <td align="right">3.8</td>
            <td align="left">2018-08-15</td>
            <td align="right">3</td>
        </tr>
        <tr>
            <td align="left">null</td>
            <td align="left">2018-08-15</td>
            <td align="right">1,019</td>
        </tr>
    </tbody>
</table>
        """

        # Act
        output = pypistats._tabulate(data, format="html")

        # Assert
        self.assertEqual(output.strip(), expected_output.strip())