starting GoogleAnalytics.GoogleAnalyticsReaderTest

This commit is contained in:
frankknoll
2023-10-03 20:35:31 +02:00
parent 6c50e43bbc
commit 165b3ab190
3 changed files with 46 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
import glob
from GoogleAnalytics.ResolutionProvider import ResolutionProvider
class GoogleAnalyticsReader:
def __init__(self, dataDir):
self.dataDir = dataDir
def getFilesHavingResolution(self, resolution):
return [file for file in self._getFiles() if ResolutionProvider.getResolution(file) == resolution]
def _getFiles(self):
return glob.glob(self.dataDir + '/*')

View File

@@ -0,0 +1,30 @@
import unittest
from GoogleAnalytics.ResolutionProvider import Resolution
from GoogleAnalytics.GoogleAnalyticsReader import GoogleAnalyticsReader
class GoogleAnalyticsReaderTest(unittest.TestCase):
def test_getFilesHavingCityResolution(self):
# Given
googleAnalyticsReader = GoogleAnalyticsReader(dataDir = 'src/testdata/GoogleAnalytics')
# When
files = googleAnalyticsReader.getFilesHavingResolution(Resolution.CITY)
# Then
self.assertEqual(files, ['src/testdata/GoogleAnalytics/CountryByBatchcode 20230730-20230929.csv'])
def test_getFilesHavingCountryResolution(self):
# Given
googleAnalyticsReader = GoogleAnalyticsReader(dataDir = 'src/testdata/GoogleAnalytics')
# When
files = googleAnalyticsReader.getFilesHavingResolution(Resolution.COUNTRY)
# Then
self.assertEqual(
files,
[
'src/testdata/GoogleAnalytics/CountryByBatchcode 20230501-20230531.csv',
'src/testdata/GoogleAnalytics/CountryByBatchcode 20230302-20230430.csv'
])

View File

@@ -3,3 +3,5 @@
# Batchcode By Country-Country By Clicked Batchcode
# 20230501-20230531
# ----------------------------------------
Clicked Batchcode,Country,Event count
1 # ----------------------------------------
3 # Batchcode By Country-Country By Clicked Batchcode
4 # 20230501-20230531
5 # ----------------------------------------
6 Clicked Batchcode,Country,Event count
7