Beispiel #1
0
def test_bad_case_display():
    case_dict = {
        'name': "It's a trap",
        'modified_on': 'broken',
    }
    case_display = CaseDisplay(case_dict)
    assert_equal(case_display.modified_on, '')
Beispiel #2
0
def test_happy_case_display():
    case_dict = {
        'name': 'Foo',
        'modified_on': '2022-04-06T12:13:14Z',
    }
    case_display = CaseDisplay(case_dict)
    assert_equal(case_display.modified_on, 'Apr 06, 2022 12:13:14 UTC')
Beispiel #3
0
 def rows(self):
    for row in self.get_data():
         display = CaseDisplay(self, row['_case'])
         yield [
             display.case_id,
             display._dateprop('opened_on', iso=False),
             display._dateprop('closed_on', iso=False),
             self.lead_time(display.case['closed_on'], display.case['opened_on']),
             display.case['requisition_status']
         ]
Beispiel #4
0
def test_null_owner_id():
    # previously this would error
    owner_type, meta = CaseDisplay({'owner_id': None}).owner
    assert_equal(owner_type, 'user')
    assert_equal(meta, {'id': None, 'name': None})
Beispiel #5
0
def test_blank_owner_id():
    # previously this would error
    owner_type, meta = CaseDisplay({}).owner
    assert_equal(owner_type, 'user')
    assert_equal(meta, {'id': '', 'name': ''})
Beispiel #6
0
def test_parse_date_int():
    parsed = CaseDisplay({}).parse_date(4)
    assert_equal(parsed, 4)
Beispiel #7
0
def test_parse_date_none():
    parsed = CaseDisplay({}).parse_date(None)
    assert_equal(parsed, None)
Beispiel #8
0
def test_parse_date_str():
    parsed = CaseDisplay({}).parse_date('broken')
    assert_equal(parsed, 'broken')
Beispiel #9
0
def test_parse_date_date():
    parsed = CaseDisplay({}).parse_date('2022-04-06')
    assert_equal(parsed, datetime(2022, 4, 6, 0, 0, 0))
Beispiel #10
0
def test_parse_date_noniso_datetime():
    parsed = CaseDisplay({}).parse_date('Apr 06, 2022 12:13:14 UTC')
    assert_equal(parsed, datetime(2022, 4, 6, 12, 13, 14))
    assert_not_equal(parsed,
                     datetime(2022, 4, 6, 12, 13, 14, tzinfo=timezone.utc))
Beispiel #11
0
def test_parse_date_iso_datetime():
    parsed = CaseDisplay({}).parse_date('2022-04-06T12:13:14Z')
    assert_equal(parsed, datetime(2022, 4, 6, 12, 13, 14))
    # `date` is timezone naive
    assert_not_equal(parsed,
                     datetime(2022, 4, 6, 12, 13, 14, tzinfo=timezone.utc))