This repository has been archived by the owner on Dec 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve stats and charts module to add formats pie chart #15
- Loading branch information
Showing
2 changed files
with
207 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# -*- coding: UTF-8 -*- | ||
#! python3 | ||
|
||
""" | ||
Usage from the repo root folder: | ||
```python | ||
# for whole test | ||
python -m unittest tests.test_stats | ||
# for specific | ||
python -m unittest tests.test_stats.TestStats.test_translations_length | ||
``` | ||
""" | ||
|
||
# ############################################################################# | ||
# ########## Libraries ############# | ||
# ################################## | ||
|
||
# Standard library | ||
import unittest | ||
|
||
# 3rd party | ||
from openpyxl import Workbook | ||
|
||
# target | ||
from isogeotoxlsx.utils import Stats | ||
|
||
|
||
# ############################################################################# | ||
# ########## Classes ############### | ||
# ################################## | ||
|
||
|
||
class TestStats(unittest.TestCase): | ||
"""Test stats and charts module.""" | ||
|
||
def setUp(self): | ||
"""Executed before each test.""" | ||
pass | ||
|
||
def tearDown(self): | ||
"""Executed after each test.""" | ||
pass | ||
|
||
# -- TESTS --------------------------------------------------- | ||
def test_translations_length(self): | ||
"""Ensure that different translations have the same length""" | ||
# this module | ||
app = Stats() | ||
# workbook | ||
wb = Workbook() | ||
|
||
# types of metadatas | ||
ws_types = wb.create_sheet(title="Types") | ||
app.md_types_repartition = { | ||
"raster": 50, | ||
"resource": 10, | ||
"service": 40, | ||
"vector": 100, | ||
} | ||
|
||
app.metadata_types(ws_types) | ||
|
||
# formats of source datasets | ||
ws_formats = wb.create_sheet(title="Formats") | ||
app.data_formats = [ | ||
"PostGIS", | ||
"WFS", | ||
"PostGIS", | ||
"WMS", | ||
"Esri Shapefiles", | ||
"Esri Shapefiles", | ||
"Esri Shapefiles", | ||
"Esri Shapefiles", | ||
"Esri Shapefiles", | ||
] | ||
|
||
app.source_formats( | ||
ws_formats, | ||
# cell_start_table="A" # you can specify where to write table | ||
) | ||
|
||
# write xlsx | ||
wb.save("test_stats_charts.xlsx") | ||
|
||
|
||
# ############################################################################# | ||
# ##### Stand alone program ######## | ||
# ################################## | ||
if __name__ == "__main__": | ||
unittest.main() |