コード例 #1
0
    def test_getPubDateObject_full_date(self, mocker, TestYear):
        mockParser = mocker.patch('managers.kMeans.YearObject')
        mockParser.side_effect = [TestYear(20, 0, 0), TestYear(19, 0, 0)]

        mockDates = ['2000-12-01|other_date', '1900-01-01|publication_date']
        outYear = KMeansManager.getPubDateObject(mockDates)

        assert outYear == {'century': 19, 'decade': 0, 'year': 0}
コード例 #2
0
 def testModel(self, testInstances, testClusters):
     testModel = KMeansManager([])
     testModel.instances = testInstances
     testModel.clusters = testClusters
     testModel.currentK = 1
     return testModel
コード例 #3
0
    def test_getEditionStatement_empty_array(self, mocker):
        edStmt = KMeansManager.getEditionStatement([])

        assert edStmt == ''
コード例 #4
0
    def test_getEditionStatement_no_value(self, mocker):
        edStmt = KMeansManager.getEditionStatement(None)

        assert edStmt == ''
コード例 #5
0
    def test_getEditionStatement_value_present(self, mocker):
        edStmt = KMeansManager.getEditionStatement(['edition|1'])

        assert edStmt == 'edition'
コード例 #6
0
    def test_getPublishers_none(self, mocker):
        outPublisher = KMeansManager.getPublishers(None)

        assert outPublisher == ''
コード例 #7
0
    def test_getPublishers_stripped(self, mocker):
        outPublisher = KMeansManager.getPublishers(['Test Second [].||viaf|'])

        assert outPublisher == 'test second'
コード例 #8
0
    def test_getPublishers_clean(self, mocker):
        outPublisher = KMeansManager.getPublishers(['Test|||', 'Other|||'])

        assert outPublisher == 'test, other'
コード例 #9
0
 def test_getPubDateFloat_bad_string_value(self, mocker):
     outYear = KMeansManager.getPubDateObject(['test|date'])
     assert outYear == {}
コード例 #10
0
 def test_getPubDateFloat_bad_value(self, mocker):
     outYear = KMeansManager.getPubDateObject(['2000'])
     assert outYear == {}
コード例 #11
0
 def test_getPubDateFloat_no_dates(self, mocker):
     outYear = KMeansManager.getPubDateObject([])
     assert outYear == {}
コード例 #12
0
 def test_getPubDateFloat_neither(self, mocker):
     mocker.patch('managers.kMeans.YearObject')
     mockDates = ['2000|other_date', '1900-1901|pub_date']
     outYear = KMeansManager.getPubDateObject(mockDates)
     assert outYear == {}
コード例 #13
0
 def test_pubProcessor_none(self):
     cleanStr = KMeansManager.pubProcessor(None)
     assert cleanStr == ''
コード例 #14
0
 def test_pubProcessor_list(self):
     cleanStr = KMeansManager.pubProcessor(['hello', 'sn', 'goodbye'])
     assert cleanStr == 'hello goodbye'
コード例 #15
0
    def test_pubProcessor_str(self):
        cleanStr = KMeansManager.pubProcessor('Testing & Testing,')
        assert cleanStr == 'testing and testing'

        cleanStr2 = KMeansManager.pubProcessor('[publisher not identified]')
        assert cleanStr2 == ''