starting ResolutionProviderTest
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -15,3 +15,4 @@ src/__pycache__/
|
||||
src/intensivstationen/__pycache__/
|
||||
google-chrome-stable_current_amd64*
|
||||
src/captcha/__pycache__
|
||||
src/GoogleAnalytics/__pycache__
|
||||
|
||||
15
src/GoogleAnalytics/ResolutionProvider.py
Normal file
15
src/GoogleAnalytics/ResolutionProvider.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from enum import Enum
|
||||
import linecache
|
||||
|
||||
|
||||
class Resolution(Enum):
|
||||
CITY = 1
|
||||
COUNTRY = 2
|
||||
|
||||
|
||||
class ResolutionProvider:
|
||||
|
||||
@staticmethod
|
||||
def getResolution(file):
|
||||
columns = linecache.getline(file, 7)
|
||||
return Resolution.CITY if 'City' in columns else Resolution.COUNTRY
|
||||
23
src/GoogleAnalytics/ResolutionProviderTest.py
Normal file
23
src/GoogleAnalytics/ResolutionProviderTest.py
Normal file
@@ -0,0 +1,23 @@
|
||||
import unittest
|
||||
from GoogleAnalytics.ResolutionProvider import Resolution, ResolutionProvider
|
||||
|
||||
|
||||
class ResolutionProviderTest(unittest.TestCase):
|
||||
|
||||
def test_getResolution_COUNTRY(self):
|
||||
# Given
|
||||
|
||||
# When
|
||||
resolution = ResolutionProvider.getResolution('src/testdata/GoogleAnalytics/CountryByBatchcode 20230302-20230430.csv')
|
||||
|
||||
# Then
|
||||
self.assertEqual(resolution, Resolution.COUNTRY)
|
||||
|
||||
def test_getResolution_CITY(self):
|
||||
# Given
|
||||
|
||||
# When
|
||||
resolution = ResolutionProvider.getResolution('src/testdata/GoogleAnalytics/CountryByBatchcode 20230730-20230929.csv')
|
||||
|
||||
# Then
|
||||
self.assertEqual(resolution, Resolution.CITY)
|
||||
0
src/GoogleAnalytics/__init__.py
Normal file
0
src/GoogleAnalytics/__init__.py
Normal file
@@ -12,4 +12,4 @@ class GoogleAnalyticsReaderTest(unittest.TestCase):
|
||||
dateRange = googleAnalyticsReader.getDateRange()
|
||||
|
||||
# Then
|
||||
self.assertEqual(dateRange, (date(2023, 3, 2), date(2023, 5, 31)))
|
||||
self.assertEqual(dateRange, (date(2023, 3, 2), date(2023, 9, 29)))
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user