def test_importer_reportStatus(excel): log = Log('test.log') importer = Importer(excel, log) # Still working out how best to test this method - all it does is write # content out to log files, no calculation assert importer.reportStatus() is True importer.missing = ['Missing Record'] assert importer.reportStatus() is True
def test_importer_checkFields(excel): log = Log('test.log') importer = Importer(excel, log) requiredFields = (['foo', 'bar']) assert importer.checkFields(requiredFields) is True with pytest.raises(RuntimeError) as excinfo: requiredFields = (['foo', 'none']) importer.checkFields(requiredFields) assert 'missing the following columns' in str(excinfo.value)
def test_importer_processMissingRecords(excel): log = Log('test.log') importer = Importer(excel, log) assert len(importer.missing) == 0 assert importer.skipped == 0 importer.processMissingRecord('Missing Record', 0) assert len(importer.missing) == 1 assert importer.skipped == 1 importer.processMissingRecord('Another Missing Record', 0) assert len(importer.missing) == 2 assert importer.skipped == 2 importer.processMissingRecord('Missing Record', 0) assert len(importer.missing) == 2 assert importer.skipped == 3
def test_importer_lookupTeamID(excel): log = Log('test.log') importer = Importer(excel, log) needle = 'Columbus Crew' assert importer.lookupTeamID(needle) == 1 with pytest.raises(RuntimeError) as excinfo: needle = 'Columbus Magic' importer.lookupTeamID(needle) assert 'Team not found: ' in str(excinfo.value) with pytest.raises(RuntimeError) as excinfo: needle = 'Duplicate Sample Team' importer.lookupTeamID(needle) assert 'Ambiguous team name: ' in str(excinfo.value)
def test_importer_generic_importRecord(excel): log = Log('test.log') importer = Importer(excel, log) dummyRecord = 'Dummy Record' assert importer.importRecord(dummyRecord) is True
def test_importer_setLog(excel): log = Log('test.log') log2 = Log('test2.log') importer = Importer(excel, log) importer.setLog(log2) assert importer.log.name == 'test2.log'
def test_importer_correctValues(excel): log = Log('test.log') importer = Importer(excel, log) assert importer.correctValues() is True