def test_check_month_day_validity(self): for d in self.fail_date_month: print("FAIL month_day: {}".format(d)) assert_raises(ValueError, SolrDaterange._check_month_day_validity, d) for d in self.pass_date_month: print("PASS month_day: {}".format(d)) res = SolrDaterange._check_month_day_validity(d)
def test_validate(self): for t in self.pas_explicit_range: print("PASS validate: {}".format(t)) gd = SolrDaterange.validate(t) for t in self.fail_explicit_range: print("FAIL validate: {}".format(t)) assert_raises(ValueError, SolrDaterange.validate, t)
def test_check_date_element(self): for typ in self.fail: print("FAIL date_element typ: {}".format(typ)) for e in self.fail[typ]: print("FAIL date_element: {}".format(e)) assert_raises(ValueError, SolrDaterange._check_date_element, typ, e) for y in self.pas: print("PASS date_element typ: {}".format(typ)) for e in self.pas[typ]: print("PASS date_element: {}".format(e)) assert (SolrDaterange._check_date_element(typ, e) == e)
def test_check_implicit_range(self): for t in self.pas_implicit_range: print("PASS implicit_range: {}".format(t)) gd = SolrDaterange._check_implicit_range(t) check = gd['year'] try: check += '-' + gd['month'] check += '-' + gd['day'] check += 'T' + gd['hour'] check += ':' + gd['minute'] check += ':' + gd['second'] except TypeError: pass assert(check == t) for t in self.fail_implicit_range: print("FAIL implicit: {}".format(t)) assert_raises(ValueError, SolrDaterange._check_implicit_range, t)
def test_check_implicit_range(self): for t in self.pas_implicit_range: print("PASS implicit_range: {}".format(t)) gd = SolrDaterange._check_implicit_range(t) check = gd['year'] try: check += '-' + gd['month'] check += '-' + gd['day'] check += 'T' + gd['hour'] check += ':' + gd['minute'] check += ':' + gd['second'] except TypeError: pass assert (check == t) for t in self.fail_implicit_range: print("FAIL implicit: {}".format(t)) assert_raises(ValueError, SolrDaterange._check_implicit_range, t)