def testContradictoryCreation(self):
     try:
         Period(TimeFormatter.toDatetime('2014-01-01 00:00:00'),
                TimeFormatter.toDatetime('2013-12-01 23:59:59'))
     except:
         return
     self.fail()
 def fromCSVRow(aRow):
     id = int(aRow.pop(0))
     period = Period( TimeFormatter.toDatetime( aRow.pop(0) ), TimeFormatter.toDatetime( aRow.pop(0) ))
     nickName = aRow.pop(0)
     savedDateTime = TimeFormatter.toDatetime(aRow.pop(0))
     result = Group(id,period.start,period.end,nickName,savedDateTime)
     return result
 def testTypeDeterminationOfPayment(self):
     apiCall = APICall(anUrl="/foradmin/before_payment", aCreatedDateTime=TimeFormatter.toDatetime("2014-02-12 23:11:20"), aParm="{'time':'012', 'location':'강남'}")
     self.assertEqual( apiCall.type, APICall.TYPE_PAYMENT )
     apiCall = APICall(anUrl="/foradmin/before_payment/asd", aCreatedDateTime=TimeFormatter.toDatetime("2014-02-12 23:11:20"), aParm="{'time':'012', 'location':'강남'}")
     self.assertEqual( apiCall.type, None )
     apiCall = APICall(anUrl="/foradmin", aCreatedDateTime=TimeFormatter.toDatetime("2014-02-12 23:11:20"), aParm="{'time':'012', 'location':'강남'}")
     self.assertEqual( apiCall.type, None )
    def testAnalyzeNewGroups(self):
        cohort = Cohort(
            aStartDate=TimeFormatter.toDatetime('2014-05-05 00:00:00'),
            aEndDate=TimeFormatter.toDatetime('2014-06-01 23:59:59'),
            aInterval=7)
        groups = cohort.groups

        group = Group(
            anId=1,
            aStartDate=TimeFormatter.toDatetime('2014-05-05 00:00:00'),
            anEndDate=TimeFormatter.toDatetime('2014-05-11 23:59:59'),
            aNickname="5월 1째 주")
        self.assertEqual(groups[0].period, group.period)
        group = Group(
            anId=2,
            aStartDate=TimeFormatter.toDatetime('2014-05-12 00:00:00'),
            anEndDate=TimeFormatter.toDatetime('2014-05-18 23:59:59'),
            aNickname="5월 2째 주")
        self.assertEqual(groups[1].period, group.period)
        group = Group(
            anId=3,
            aStartDate=TimeFormatter.toDatetime('2014-05-19 00:00:00'),
            anEndDate=TimeFormatter.toDatetime('2014-05-25 23:59:59'),
            aNickname="5월 3째 주")
        self.assertEqual(groups[2].period, group.period)
        group = Group(
            anId=3,
            aStartDate=TimeFormatter.toDatetime('2014-05-26 00:00:00'),
            anEndDate=TimeFormatter.toDatetime('2014-06-01 23:59:59'),
            aNickname="5월 4째 주")
        self.assertEqual(groups[3].period, group.period)
        self.assertEqual(groups.__len__(), 4)
示例#5
0
    def delete(anIndex):
        if (RelativeProjectPathManager.isThereFile(Group.FILE_PATH_TO_SAVE)):
            groups = Group.all()
            for groupTuple in enumerate(groups):
                if (groupTuple[1].id == anIndex):
                    groups.pop(groupTuple[0])

            os.remove(
                RelativeProjectPathManager.getRealFilePathToSave(
                    Group.FILE_PATH_TO_SAVE))
            with open(RelativeProjectPathManager.getRealFilePathToSave(
                    Group.FILE_PATH_TO_SAVE),
                      'w',
                      encoding='UTF8') as wCSVFile:
                writer = csv.writer(wCSVFile, delimiter=',')
                for group in groups:
                    row = []
                    row.append(group.id)
                    row.append(
                        TimeFormatter.toDatetimeString(group.period.start))
                    row.append(TimeFormatter.toDatetimeString(
                        group.period.end))
                    row.append(group.nickName)
                    row.append(
                        TimeFormatter.toDatetimeString(group.savedDateTime))
                    writer.writerow(row)
                    wCSVFile.close()
示例#6
0
 def fromCSVRow(aRow):
     id = int(aRow.pop(0))
     period = Period(TimeFormatter.toDatetime(aRow.pop(0)),
                     TimeFormatter.toDatetime(aRow.pop(0)))
     nickName = aRow.pop(0)
     savedDateTime = TimeFormatter.toDatetime(aRow.pop(0))
     result = Group(id, period.start, period.end, nickName, savedDateTime)
     return result
示例#7
0
 def testUpdate(self):
     self.saveAll(self.groups)
     newGroup = Group(
         anId=1,
         aStartDate=TimeFormatter.toDatetime('2013-01-01 00:00:00'),
         anEndDate=TimeFormatter.toDatetime('2015-12-10 23:59:59'),
         aNickname="2013~2015")
     newGroup.save()
 def testTypeDeterminationOfShallowSearch(self):
     apiCall = APICall(anUrl="/classes/dance/etc/1", aCreatedDateTime=TimeFormatter.toDatetime("2014-02-12 23:11:20"), aParm="{}")
     self.assertEqual( apiCall.type, APICall.TYPE_SHALLOW_SEARCH )
     apiCall = APICall(anUrl="/classes/music/etc/2", aCreatedDateTime=TimeFormatter.toDatetime("2014-02-12 23:11:20"), aParm="{}")
     self.assertEqual( apiCall.type, APICall.TYPE_SHALLOW_SEARCH )
     apiCall = APICall(anUrl="/classes/music", aCreatedDateTime=TimeFormatter.toDatetime("2014-02-12 23:11:20"), aParm="{}")
     self.assertEqual( apiCall.type, None )
     apiCall = APICall(anUrl="/classes/kk/ho/123", aCreatedDateTime=TimeFormatter.toDatetime("2014-02-12 23:11:20"), aParm="{}")
     self.assertEqual( apiCall.type, None )
 def testTypeDeterminationOfDetailView(self):
     apiCall = APICall(anUrl="/classes/1/3", aCreatedDateTime=TimeFormatter.toDatetime("2014-02-12 23:11:20"), aParm="{}")
     self.assertEqual( apiCall.type, APICall.TYPE_DETAIL_VIEW )
     apiCall = APICall(anUrl="/classes/123123/7777", aCreatedDateTime=TimeFormatter.toDatetime("2014-02-12 23:11:20"), aParm="{}")
     self.assertEqual( apiCall.type, APICall.TYPE_DETAIL_VIEW )
     apiCall = APICall(anUrl="/classes/123123/7777/123", aCreatedDateTime=TimeFormatter.toDatetime("2014-02-12 23:11:20"), aParm="{}")
     self.assertEqual( apiCall.type, None )
     apiCall = APICall(anUrl="/classes/123123", aCreatedDateTime=TimeFormatter.toDatetime("2014-02-12 23:11:20"), aParm="{r}")
     self.assertEqual( apiCall.type, None )
示例#10
0
 def testTypeDeterminationOfFilter(self):
     apiCall = APICall(
         anUrl="/classes/dance/etc/1",
         aCreatedDateTime=TimeFormatter.toDatetime("2014-02-12 23:11:20"),
         aParm="{'time':'012', 'location':'강남'}")
     self.assertEqual(apiCall.type, APICall.TYPE_FILTER)
     apiCall = APICall(
         anUrl="/classes/music/hoho/1",
         aCreatedDateTime=TimeFormatter.toDatetime("2014-02-12 23:11:20"),
         aParm="{'time':'012'}")
     self.assertEqual(apiCall.type, APICall.TYPE_FILTER)
示例#11
0
    def testEnableToCapture(self):
        group = Group(anId=1, aStartDate=TimeFormatter.toDatetime('2014-06-01 00:00:00'), anEndDate=TimeFormatter.toDatetime('2014-06-01 23:59:59'), aNickname="6월 1일")
        snapshot = Snapshot(group)

        snapshot.capture(TimeFormatter.toDatetime('2014-06-07 23:59:59'))
        self.assertTrue( snapshot.funnel is not None)

        try:
            snapshot.capture(TimeFormatter.toDatetime('2014-06-01 23:59:59'))
        except:
            return
        self.fail("this is not correct time relation, should be failed")
    def testAnalyzeNewGroups(self):
        cohort = Cohort(aStartDate=TimeFormatter.toDatetime('2014-05-05 00:00:00'), aEndDate=TimeFormatter.toDatetime('2014-06-01 23:59:59'), aInterval = 7)
        groups = cohort.groups

        group = Group(anId=1, aStartDate=TimeFormatter.toDatetime('2014-05-05 00:00:00'), anEndDate=TimeFormatter.toDatetime('2014-05-11 23:59:59'), aNickname="5월 1째 주")
        self.assertEqual(groups[0].period, group.period)
        group = Group(anId=2, aStartDate=TimeFormatter.toDatetime('2014-05-12 00:00:00'), anEndDate=TimeFormatter.toDatetime('2014-05-18 23:59:59'), aNickname="5월 2째 주")
        self.assertEqual(groups[1].period, group.period)
        group = Group(anId=3, aStartDate=TimeFormatter.toDatetime('2014-05-19 00:00:00'), anEndDate=TimeFormatter.toDatetime('2014-05-25 23:59:59'), aNickname="5월 3째 주")
        self.assertEqual(groups[2].period, group.period)
        group = Group(anId=3, aStartDate=TimeFormatter.toDatetime('2014-05-26 00:00:00'), anEndDate=TimeFormatter.toDatetime('2014-06-01 23:59:59'), aNickname="5월 4째 주")
        self.assertEqual(groups[3].period, group.period)
        self.assertEqual(groups.__len__(),4)
    def save(self):
        if(Group.findById(self.id) is not None):
            Group.delete(self.id)

        with open(RelativeProjectPathManager.getRealFilePathToSave(Group.FILE_PATH_TO_SAVE), 'a', encoding='UTF8') as wCSVFile:
            writer = csv.writer(wCSVFile, delimiter=',')
            row = []
            row.append(self.id)
            row.append(TimeFormatter.toDatetimeString(self.period.start))
            row.append(TimeFormatter.toDatetimeString(self.period.end))
            row.append(self.nickName)
            self.savedDateTime = datetime.now()
            row.append(TimeFormatter.toDatetimeString(self.savedDateTime))
            writer.writerow(row)
            wCSVFile.close()
示例#14
0
 def testTypeDeterminationOfPayment(self):
     apiCall = APICall(
         anUrl="/foradmin/before_payment",
         aCreatedDateTime=TimeFormatter.toDatetime("2014-02-12 23:11:20"),
         aParm="{'time':'012', 'location':'강남'}")
     self.assertEqual(apiCall.type, APICall.TYPE_PAYMENT)
     apiCall = APICall(
         anUrl="/foradmin/before_payment/asd",
         aCreatedDateTime=TimeFormatter.toDatetime("2014-02-12 23:11:20"),
         aParm="{'time':'012', 'location':'강남'}")
     self.assertEqual(apiCall.type, None)
     apiCall = APICall(
         anUrl="/foradmin",
         aCreatedDateTime=TimeFormatter.toDatetime("2014-02-12 23:11:20"),
         aParm="{'time':'012', 'location':'강남'}")
     self.assertEqual(apiCall.type, None)
示例#15
0
    def save(self):
        if (Group.findById(self.id) is not None):
            Group.delete(self.id)

        with open(RelativeProjectPathManager.getRealFilePathToSave(
                Group.FILE_PATH_TO_SAVE),
                  'a',
                  encoding='UTF8') as wCSVFile:
            writer = csv.writer(wCSVFile, delimiter=',')
            row = []
            row.append(self.id)
            row.append(TimeFormatter.toDatetimeString(self.period.start))
            row.append(TimeFormatter.toDatetimeString(self.period.end))
            row.append(self.nickName)
            self.savedDateTime = datetime.now()
            row.append(TimeFormatter.toDatetimeString(self.savedDateTime))
            writer.writerow(row)
            wCSVFile.close()
    def delete(anIndex):
        if(RelativeProjectPathManager.isThereFile(Group.FILE_PATH_TO_SAVE)):
            groups = Group.all()
            for groupTuple in enumerate(groups):
                if(groupTuple[1].id == anIndex):
                    groups.pop(groupTuple[0])

            os.remove(RelativeProjectPathManager.getRealFilePathToSave(Group.FILE_PATH_TO_SAVE))
            with open(RelativeProjectPathManager.getRealFilePathToSave(Group.FILE_PATH_TO_SAVE), 'w', encoding='UTF8') as wCSVFile:
                writer = csv.writer(wCSVFile, delimiter=',')
                for group in groups:
                    row = []
                    row.append(group.id)
                    row.append(TimeFormatter.toDatetimeString(group.period.start))
                    row.append(TimeFormatter.toDatetimeString(group.period.end))
                    row.append(group.nickName)
                    row.append(TimeFormatter.toDatetimeString(group.savedDateTime))
                    writer.writerow(row)
                    wCSVFile.close()
示例#17
0
 def setUp(self):
     try:
         os.remove(
             RelativeProjectPathManager.getRealFilePathToSave(
                 Group.FILE_PATH_TO_SAVE))
     except:
         pass
     Group.FILE_PATH_TO_SAVE = GroupTest.directoryPathToSave
     self.groups = []
     self.groups.append(
         Group(anId=1,
               aStartDate=TimeFormatter.toDatetime('2014-06-01 00:00:00'),
               anEndDate=TimeFormatter.toDatetime('2014-06-01 23:59:59'),
               aNickname="5월 4째주"))
     self.groups.append(
         Group(anId=2,
               aStartDate=TimeFormatter.toDatetime('2011-09-09 00:00:00'),
               anEndDate=TimeFormatter.toDatetime('2013-12-12 23:59:59'),
               aNickname="ㅋㅋㅋ"))
示例#18
0
 def testTypeDeterminationOfShallowSearch(self):
     apiCall = APICall(
         anUrl="/classes/dance/etc/1",
         aCreatedDateTime=TimeFormatter.toDatetime("2014-02-12 23:11:20"),
         aParm="{}")
     self.assertEqual(apiCall.type, APICall.TYPE_SHALLOW_SEARCH)
     apiCall = APICall(
         anUrl="/classes/music/etc/2",
         aCreatedDateTime=TimeFormatter.toDatetime("2014-02-12 23:11:20"),
         aParm="{}")
     self.assertEqual(apiCall.type, APICall.TYPE_SHALLOW_SEARCH)
     apiCall = APICall(
         anUrl="/classes/music",
         aCreatedDateTime=TimeFormatter.toDatetime("2014-02-12 23:11:20"),
         aParm="{}")
     self.assertEqual(apiCall.type, None)
     apiCall = APICall(
         anUrl="/classes/kk/ho/123",
         aCreatedDateTime=TimeFormatter.toDatetime("2014-02-12 23:11:20"),
         aParm="{}")
     self.assertEqual(apiCall.type, None)
示例#19
0
 def testTypeDeterminationOfDetailView(self):
     apiCall = APICall(
         anUrl="/classes/1/3",
         aCreatedDateTime=TimeFormatter.toDatetime("2014-02-12 23:11:20"),
         aParm="{}")
     self.assertEqual(apiCall.type, APICall.TYPE_DETAIL_VIEW)
     apiCall = APICall(
         anUrl="/classes/123123/7777",
         aCreatedDateTime=TimeFormatter.toDatetime("2014-02-12 23:11:20"),
         aParm="{}")
     self.assertEqual(apiCall.type, APICall.TYPE_DETAIL_VIEW)
     apiCall = APICall(
         anUrl="/classes/123123/7777/123",
         aCreatedDateTime=TimeFormatter.toDatetime("2014-02-12 23:11:20"),
         aParm="{}")
     self.assertEqual(apiCall.type, None)
     apiCall = APICall(
         anUrl="/classes/123123",
         aCreatedDateTime=TimeFormatter.toDatetime("2014-02-12 23:11:20"),
         aParm="{r}")
     self.assertEqual(apiCall.type, None)
 def fromDict(aJsonDict):
     return APICall(anUrl=aJsonDict[APICall.JSON_PARM_URL], aCreatedDateTime=TimeFormatter.toDatetime(aJsonDict[APICall.JSON_PARM_CREATED_DATE_TIME]), aParm=aJsonDict[APICall.JSON_PARM_PARM].__str__())
 def __str__(self):
     return self.url + '\n' + self.parm + '\n' + TimeFormatter.toDatetimeString(self.createdDateTime) + '\n' + self.typeToString()
    # funnel = snapshot.capture(TimeFormatter.toDatetime( '2014-05-20 00:00:00') )
    # print(str(funnel.countNumberOfIndifference()) + ', ' + str(funnel.countNumberOfCurios()) + ', ' + str(funnel.countNumberOfInterested()) + ', ' + str(funnel.countNumberOfFilter()) + ', ' + str(funnel.countNumberOfPayment()) )
    #
    #
    # group = Group(anId=3, aStartDate=TimeFormatter.toDatetime('2014-05-19 00:00:00'), anEndDate=TimeFormatter.toDatetime('2014-05-25 23:59:59'), aNickname="5월 3째 주")
    # snapshot = Snapshot(group)
    # funnel = snapshot.capture(TimeFormatter.toDatetime( '2014-05-27 00:00:00') )
    # print(str(funnel.countNumberOfIndifference()) + ', ' + str(funnel.countNumberOfCurios()) + ', ' + str(funnel.countNumberOfInterested()) + ', ' + str(funnel.countNumberOfFilter()) + ', ' + str(funnel.countNumberOfPayment()) )
    #
    # group = Group(anId=3, aStartDate=TimeFormatter.toDatetime('2014-05-26 00:00:00'), anEndDate=TimeFormatter.toDatetime('2014-06-01 23:59:59'), aNickname="5월 4째 주")
    # snapshot = Snapshot(group)
    # funnel = snapshot.capture(TimeFormatter.toDatetime( '2014-06-03 00:00:00') )
    # print(str(funnel.countNumberOfIndifference()) + ', ' + str(funnel.countNumberOfCurios()) + ', ' + str(funnel.countNumberOfInterested()) + ', ' + str(funnel.countNumberOfFilter()) + ', ' + str(funnel.countNumberOfPayment()) )
    #
    # group = Group(anId=3, aStartDate=TimeFormatter.toDatetime('2014-06-02 00:00:00'), anEndDate=TimeFormatter.toDatetime('2014-06-08 23:59:59'), aNickname="6월 1째 주")
    # snapshot = Snapshot(group)
    # funnel = snapshot.capture(TimeFormatter.toDatetime( '2014-06-10 00:00:00') )
    # print(str(funnel.countNumberOfIndifference()) + ', ' + str(funnel.countNumberOfCurios()) + ', ' + str(funnel.countNumberOfInterested()) + ', ' + str(funnel.countNumberOfFilter()) + ', ' + str(funnel.countNumberOfPayment()) )

    group = Group(anId=3,
                  aStartDate=TimeFormatter.toDatetime('2014-06-09 00:00:00'),
                  anEndDate=TimeFormatter.toDatetime('2014-06-14 23:59:59'),
                  aNickname="5월 4째 주")
    snapshot = Snapshot(group)
    funnel = snapshot.capture(TimeFormatter.toDatetime('2014-06-16 00:00:00'))
    print(
        str(funnel.countNumberOfIndifference()) + ', ' +
        str(funnel.countNumberOfCurios()) + ', ' +
        str(funnel.countNumberOfInterested()) + ', ' +
        str(funnel.countNumberOfFilter()) + ', ' +
        str(funnel.countNumberOfPayment()))
示例#23
0
 def testInstantiateUserBehaviorBySessionId(self):
     try:
         userBehavior = UserBehavior.instantiateBasedOnSessionIdWithCaptureDatetime(aSessionId = 'W1A/aq3DnaO6NpBrD8gbzw==', aCaptureDatetime=TimeFormatter.toDatetime('2014-06-01 11:23:30'))
     except:
         self.fail("fail to instantiate userBehavior, this function is related with http request and json parsing tasks.")
    print("indifference, curious, interested, filter, payment")
    # group = Group(anId=1, aStartDate=TimeFormatter.toDatetime('2014-05-05 00:00:00'), anEndDate=TimeFormatter.toDatetime('2014-05-11 23:59:59'), aNickname="5월 1째 주")
    # snapshot = Snapshot(group)
    # funnel = snapshot.capture(TimeFormatter.toDatetime( '2014-05-13 00:00:00') )
    # print(str(funnel.countNumberOfIndifference()) + ', ' + str(funnel.printCuriosUserSessions()) + ', ' + str(funnel.printInterestedUserSessions()) + ', ' + str(funnel.countNumberOfFilter()) + ', ' + str(funnel.countNumberOfPayment()) )

    # group = Group(anId=2, aStartDate=TimeFormatter.toDatetime('2014-05-12 00:00:00'), anEndDate=TimeFormatter.toDatetime('2014-05-18 23:59:59'), aNickname="5월 2째 주")
    # snapshot = Snapshot(group)
    # funnel = snapshot.capture(TimeFormatter.toDatetime( '2014-05-20 00:00:00') )
    # print(str(funnel.countNumberOfIndifference()) + ', ' + str(funnel.countNumberOfCurios()) + ', ' + str(funnel.countNumberOfInterested()) + ', ' + str(funnel.countNumberOfFilter()) + ', ' + str(funnel.countNumberOfPayment()) )
    #
    #
    # group = Group(anId=3, aStartDate=TimeFormatter.toDatetime('2014-05-19 00:00:00'), anEndDate=TimeFormatter.toDatetime('2014-05-25 23:59:59'), aNickname="5월 3째 주")
    # snapshot = Snapshot(group)
    # funnel = snapshot.capture(TimeFormatter.toDatetime( '2014-05-27 00:00:00') )
    # print(str(funnel.countNumberOfIndifference()) + ', ' + str(funnel.countNumberOfCurios()) + ', ' + str(funnel.countNumberOfInterested()) + ', ' + str(funnel.countNumberOfFilter()) + ', ' + str(funnel.countNumberOfPayment()) )
    #
    # group = Group(anId=3, aStartDate=TimeFormatter.toDatetime('2014-05-26 00:00:00'), anEndDate=TimeFormatter.toDatetime('2014-06-01 23:59:59'), aNickname="5월 4째 주")
    # snapshot = Snapshot(group)
    # funnel = snapshot.capture(TimeFormatter.toDatetime( '2014-06-03 00:00:00') )
    # print(str(funnel.countNumberOfIndifference()) + ', ' + str(funnel.countNumberOfCurios()) + ', ' + str(funnel.countNumberOfInterested()) + ', ' + str(funnel.countNumberOfFilter()) + ', ' + str(funnel.countNumberOfPayment()) )
    #
    # group = Group(anId=3, aStartDate=TimeFormatter.toDatetime('2014-06-02 00:00:00'), anEndDate=TimeFormatter.toDatetime('2014-06-08 23:59:59'), aNickname="6월 1째 주")
    # snapshot = Snapshot(group)
    # funnel = snapshot.capture(TimeFormatter.toDatetime( '2014-06-10 00:00:00') )
    # print(str(funnel.countNumberOfIndifference()) + ', ' + str(funnel.countNumberOfCurios()) + ', ' + str(funnel.countNumberOfInterested()) + ', ' + str(funnel.countNumberOfFilter()) + ', ' + str(funnel.countNumberOfPayment()) )

    group = Group(anId=3, aStartDate=TimeFormatter.toDatetime('2014-06-09 00:00:00'), anEndDate=TimeFormatter.toDatetime('2014-06-14 23:59:59'), aNickname="5월 4째 주")
    snapshot = Snapshot(group)
    funnel = snapshot.capture(TimeFormatter.toDatetime( '2014-06-16 00:00:00') )
    print(str(funnel.countNumberOfIndifference()) + ', ' + str(funnel.countNumberOfCurios()) + ', ' + str(funnel.countNumberOfInterested()) + ', ' + str(funnel.countNumberOfFilter()) + ', ' + str(funnel.countNumberOfPayment()) )
示例#25
0
 def __str__(self):
     return self.url + '\n' + self.parm + '\n' + TimeFormatter.toDatetimeString(
         self.createdDateTime) + '\n' + self.typeToString()
示例#26
0
 def fromDict(aJsonDict):
     return APICall(anUrl=aJsonDict[APICall.JSON_PARM_URL],
                    aCreatedDateTime=TimeFormatter.toDatetime(
                        aJsonDict[APICall.JSON_PARM_CREATED_DATE_TIME]),
                    aParm=aJsonDict[APICall.JSON_PARM_PARM].__str__())
示例#27
0
 def fromJson(aJsonString):
     jsonDict = json.loads(aJsonString)
     return APICall(anUrl=jsonDict[APICall.JSON_PARM_URL],
                    aCreatedDateTime=TimeFormatter.toDatetime(
                        jsonDict[APICall.JSON_PARM_CREATED_DATE_TIME]),
                    aParm=jsonDict[APICall.JSON_PARM_PARM].__str__())
 def getAPICallLogListGivenSessionId(aSessionId, aCaptureDatetime):
     response = ClassweekHttpRequester.postForDictResponse(ClassweekHttpRequester.URL_API_CALL_LOG_LIST_GIVEN_SESSION_ID, { ClassweekHttpRequester.POST_PARM_SESSION_ID : aSessionId, ClassweekHttpRequester.POST_PARM_CAPTURE_DATETIME : TimeFormatter.toDatetimeString(aCaptureDatetime)})
     return response[ClassweekHttpRequester.SUCCESSFUL_RESULT_DATA_PARSING_KEY]
from src.main.domain.Group import Group
from src.main.domain.Snapshot import Snapshot
from src.main.domain.UserBehavior import UserBehavior
from src.main.util.TimeFormatter import TimeFormatter

__author__ = 'continueing'




if __name__ == "__main__":
    group = Group(anId=1, aStartDate=TimeFormatter.toDatetime('2014-06-15 00:00:00'), anEndDate=TimeFormatter.toDatetime('2014-06-19 23:59:59'), aNickname="6월 12일 하루")
    group.save()
    snapshot = Snapshot(group)
    snapshot.capture(TimeFormatter.toDatetime( '2014-06-20 00:00:00') )
    funnel = snapshot.funnel

    print('Indifference:\t\t' + str(funnel.countNumberOfIndifference()))
    print('curios:\t\t' + str(funnel.countNumberOfCurios()))
    print('interested:\t\t' + str(funnel.countNumberOfInterested()))
    print('filter:\t\t' + str(funnel.countNumberOfFilter()))
    print('payment:\t\t' + str(funnel.countNumberOfPayment()))


    userbehavior = UserBehavior.instantiateBasedOnSessionIdWithCaptureDatetime("09FN8+0qQscHPgeR5RrTmg==",TimeFormatter.toDatetime( '2014-06-20 00:00:00'))
    userbehavior.printLog()




from src.main.domain.Group import Group
from src.main.domain.Snapshot import Snapshot
from src.main.domain.UserBehavior import UserBehavior
from src.main.util.TimeFormatter import TimeFormatter

__author__ = 'continueing'

if __name__ == "__main__":
    group = Group(anId=1,
                  aStartDate=TimeFormatter.toDatetime('2014-06-15 00:00:00'),
                  anEndDate=TimeFormatter.toDatetime('2014-06-19 23:59:59'),
                  aNickname="6월 12일 하루")
    group.save()
    snapshot = Snapshot(group)
    snapshot.capture(TimeFormatter.toDatetime('2014-06-20 00:00:00'))
    funnel = snapshot.funnel

    print('Indifference:\t\t' + str(funnel.countNumberOfIndifference()))
    print('curios:\t\t' + str(funnel.countNumberOfCurios()))
    print('interested:\t\t' + str(funnel.countNumberOfInterested()))
    print('filter:\t\t' + str(funnel.countNumberOfFilter()))
    print('payment:\t\t' + str(funnel.countNumberOfPayment()))

    userbehavior = UserBehavior.instantiateBasedOnSessionIdWithCaptureDatetime(
        "09FN8+0qQscHPgeR5RrTmg==",
        TimeFormatter.toDatetime('2014-06-20 00:00:00'))
    userbehavior.printLog()
 def fromJson(aJsonString):
     jsonDict= json.loads(aJsonString)
     return APICall(anUrl=jsonDict[APICall.JSON_PARM_URL], aCreatedDateTime=TimeFormatter.toDatetime(jsonDict[APICall.JSON_PARM_CREATED_DATE_TIME]), aParm=jsonDict[APICall.JSON_PARM_PARM].__str__())
 def testTypeDeterminationOfFilter(self):
     apiCall = APICall(anUrl="/classes/dance/etc/1", aCreatedDateTime=TimeFormatter.toDatetime("2014-02-12 23:11:20"), aParm="{'time':'012', 'location':'강남'}")
     self.assertEqual( apiCall.type, APICall.TYPE_FILTER )
     apiCall = APICall(anUrl="/classes/music/hoho/1", aCreatedDateTime=TimeFormatter.toDatetime("2014-02-12 23:11:20"), aParm="{'time':'012'}")
     self.assertEqual( apiCall.type, APICall.TYPE_FILTER )
 def getSessionIdsGivenPeriod(aPeriod):
     post_params = { ClassweekHttpRequester.POST_PARM_START_DATE : TimeFormatter.toDateString(aPeriod.start)  , ClassweekHttpRequester.POST_PARM_END_DATE : TimeFormatter.toDateString(aPeriod.end)}
     response = ClassweekHttpRequester.postForDictResponse(ClassweekHttpRequester.URL_SESSION_IDS_GIVEN_PERIOD, post_params)
     return response[ClassweekHttpRequester.SUCCESSFUL_RESULT_DATA_PARSING_KEY]
示例#34
0
 def testIsAndroidUser(self):
     userBehavior = UserBehavior.instantiateBasedOnSessionIdWithCaptureDatetime(aSessionId = 'W1A/aq3DnaO6NpBrD8gbzw==', aCaptureDatetime=TimeFormatter.toDatetime('2014-06-11 11:23:30'))
     self.assertTrue(userBehavior.isAndroidUser())