adding RegionCountsByBatchcodeTablesMergerTest
This commit is contained in:
@@ -13,7 +13,12 @@ class FilesProviderTest(unittest.TestCase):
|
|||||||
files = filesProvider.getFilesHavingResolution(Resolution.CITY)
|
files = filesProvider.getFilesHavingResolution(Resolution.CITY)
|
||||||
|
|
||||||
# Then
|
# Then
|
||||||
self.assertEqual(files, [dataDir + '/CountryByBatchcode 20230730-20230929.csv'])
|
self.assertEqual(
|
||||||
|
files,
|
||||||
|
[
|
||||||
|
dataDir + '/CountryByBatchcode 20230730-20230929.csv',
|
||||||
|
dataDir + '/CountryByBatchcode 20230929-20230930.csv'
|
||||||
|
])
|
||||||
|
|
||||||
def test_getFilesHavingCountryResolution(self):
|
def test_getFilesHavingCountryResolution(self):
|
||||||
# Given
|
# Given
|
||||||
|
|||||||
13
src/GoogleAnalytics/RegionCountsByBatchcodeTablesMerger.py
Normal file
13
src/GoogleAnalytics/RegionCountsByBatchcodeTablesMerger.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
from GoogleAnalytics.RegionCountsByClickedBatchcodeProvider import RegionCountsByClickedBatchcodeProvider
|
||||||
|
from GoogleAnalytics.FilesProvider import FilesProvider
|
||||||
|
from GoogleAnalytics.Resolution import Resolution
|
||||||
|
from TablesHelper import TablesHelper
|
||||||
|
|
||||||
|
class RegionCountsByBatchcodeTablesMerger:
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def getRegionCountsByClickedBatchcode(dataDir):
|
||||||
|
files = FilesProvider(dataDir).getFilesHavingResolution(Resolution.CITY)
|
||||||
|
tables = [RegionCountsByClickedBatchcodeProvider.getRegionCountsByClickedBatchcode(file) for file in files]
|
||||||
|
table = TablesHelper.concatTables_groupByIndex_sum(tables)
|
||||||
|
return table
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import unittest
|
||||||
|
from pandas.testing import assert_frame_equal
|
||||||
|
from TestHelper import TestHelper
|
||||||
|
import pandas as pd
|
||||||
|
from src.GoogleAnalytics.RegionCountsByBatchcodeTablesMerger import RegionCountsByBatchcodeTablesMerger
|
||||||
|
|
||||||
|
class RegionCountsByBatchcodeTablesMergerTest(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_getRegionCountsByClickedBatchcode(self):
|
||||||
|
# Given
|
||||||
|
|
||||||
|
# When
|
||||||
|
regionCountsByClickedBatchcodeTable = RegionCountsByBatchcodeTablesMerger.getRegionCountsByClickedBatchcode('src/testdata/GoogleAnalytics')
|
||||||
|
|
||||||
|
# Then
|
||||||
|
assert_frame_equal(
|
||||||
|
regionCountsByClickedBatchcodeTable,
|
||||||
|
TestHelper.createDataFrame(
|
||||||
|
columns = ['REGION_COUNT_BY_VAX_LOT'],
|
||||||
|
data = [ [100 + 200],
|
||||||
|
[(10 + 20) + (20 + 40)]],
|
||||||
|
index = pd.MultiIndex.from_tuples(
|
||||||
|
names = ['VAX_LOT', 'COUNTRY', 'REGION'],
|
||||||
|
tuples = [['#003B21A', 'United States', 'California'],
|
||||||
|
['000086A', 'Germany', 'Bavaria']])))
|
||||||
6
src/GoogleAnalytics/Resolution.py
Normal file
6
src/GoogleAnalytics/Resolution.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
from enum import Enum
|
||||||
|
|
||||||
|
|
||||||
|
class Resolution(Enum):
|
||||||
|
CITY = 1
|
||||||
|
COUNTRY = 2
|
||||||
@@ -1,11 +1,5 @@
|
|||||||
from enum import Enum
|
|
||||||
import linecache
|
import linecache
|
||||||
|
from GoogleAnalytics.Resolution import Resolution
|
||||||
|
|
||||||
class Resolution(Enum):
|
|
||||||
CITY = 1
|
|
||||||
COUNTRY = 2
|
|
||||||
|
|
||||||
|
|
||||||
class ResolutionProvider:
|
class ResolutionProvider:
|
||||||
|
|
||||||
|
|||||||
11
src/testdata/GoogleAnalytics/CountryByBatchcode 20230929-20230930.csv
vendored
Normal file
11
src/testdata/GoogleAnalytics/CountryByBatchcode 20230929-20230930.csv
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# ----------------------------------------
|
||||||
|
# HowBadIsMyBatch
|
||||||
|
# Batchcode By Country-Country By Clicked Batchcode
|
||||||
|
# 20230730-20230929
|
||||||
|
# ----------------------------------------
|
||||||
|
|
||||||
|
Clicked Batchcode,Country,Region,City,Event count
|
||||||
|
,,,,441337,Grand total
|
||||||
|
#003B21A,United States,California,Roseville,200
|
||||||
|
000086A,Germany,Bavaria,Nordlingen,20
|
||||||
|
000086A,Germany,Bavaria,Nuremberg,40
|
||||||
|
Reference in New Issue
Block a user