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}
def testModel(self, testInstances, testClusters): testModel = KMeansManager([]) testModel.instances = testInstances testModel.clusters = testClusters testModel.currentK = 1 return testModel
def test_getEditionStatement_empty_array(self, mocker): edStmt = KMeansManager.getEditionStatement([]) assert edStmt == ''
def test_getEditionStatement_no_value(self, mocker): edStmt = KMeansManager.getEditionStatement(None) assert edStmt == ''
def test_getEditionStatement_value_present(self, mocker): edStmt = KMeansManager.getEditionStatement(['edition|1']) assert edStmt == 'edition'
def test_getPublishers_none(self, mocker): outPublisher = KMeansManager.getPublishers(None) assert outPublisher == ''
def test_getPublishers_stripped(self, mocker): outPublisher = KMeansManager.getPublishers(['Test Second [].||viaf|']) assert outPublisher == 'test second'
def test_getPublishers_clean(self, mocker): outPublisher = KMeansManager.getPublishers(['Test|||', 'Other|||']) assert outPublisher == 'test, other'
def test_getPubDateFloat_bad_string_value(self, mocker): outYear = KMeansManager.getPubDateObject(['test|date']) assert outYear == {}
def test_getPubDateFloat_bad_value(self, mocker): outYear = KMeansManager.getPubDateObject(['2000']) assert outYear == {}
def test_getPubDateFloat_no_dates(self, mocker): outYear = KMeansManager.getPubDateObject([]) assert outYear == {}
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 == {}
def test_pubProcessor_none(self): cleanStr = KMeansManager.pubProcessor(None) assert cleanStr == ''
def test_pubProcessor_list(self): cleanStr = KMeansManager.pubProcessor(['hello', 'sn', 'goodbye']) assert cleanStr == 'hello goodbye'
def test_pubProcessor_str(self): cleanStr = KMeansManager.pubProcessor('Testing & Testing,') assert cleanStr == 'testing and testing' cleanStr2 = KMeansManager.pubProcessor('[publisher not identified]') assert cleanStr2 == ''