starting GoogleAnalytics.GoogleAnalyticsReaderTest
This commit is contained in:
14
src/GoogleAnalytics/GoogleAnalyticsReader.py
Normal file
14
src/GoogleAnalytics/GoogleAnalyticsReader.py
Normal 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 + '/*')
|
||||
30
src/GoogleAnalytics/GoogleAnalyticsReaderTest.py
Normal file
30
src/GoogleAnalytics/GoogleAnalyticsReaderTest.py
Normal 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'
|
||||
])
|
||||
@@ -3,3 +3,5 @@
|
||||
# Batchcode By Country-Country By Clicked Batchcode
|
||||
# 20230501-20230531
|
||||
# ----------------------------------------
|
||||
|
||||
Clicked Batchcode,Country,Event count
|
||||
|
||||
|
Reference in New Issue
Block a user