1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
import unittest
from crossref import validators
class ValidatorsTest(unittest.TestCase):
def test_directory_1(self):
result = validators.directory("DOAJ")
assert result
def test_directory_2(self):
with self.assertRaises(ValueError):
validators.directory("any invalid archive")
def test_archive_1(self):
result = validators.archive("CLOCKSS")
assert result
def test_archive_2(self):
with self.assertRaises(ValueError):
validators.archive("any invalid archive")
def test_document_type_1(self):
result = validators.document_type("book-chapter")
assert result
def test_document_type_2(self):
with self.assertRaises(ValueError):
validators.document_type("any invalid type")
def test_is_bool_3(self):
result = validators.is_bool("true")
assert result
def test_is_bool_4(self):
result = validators.is_bool("false")
assert result
def test_is_bool_5(self):
result = validators.is_bool("1")
assert result
def test_is_bool_5(self):
with self.assertRaises(ValueError):
validators.is_bool("jljlj")
def test_is_date_1(self):
result = validators.is_date("2017")
assert result
def test_is_date_2(self):
result = validators.is_date("2017-12")
assert result
def test_is_date_3(self):
result = validators.is_date("2017-12-31")
assert result
def test_is_date_4(self):
with self.assertRaises(ValueError):
validators.is_date("asas")
def test_is_date_5(self):
with self.assertRaises(ValueError):
validators.is_date("2017-30")
def test_is_date_6(self):
with self.assertRaises(ValueError):
validators.is_date("2017-12-00")
def test_is_integer_1(self):
result = validators.is_integer("10")
assert result
def test_is_integer_1(self):
with self.assertRaises(ValueError):
validators.is_integer("-1")
def test_is_integer_3(self):
with self.assertRaises(ValueError):
validators.is_integer("dd")
|