Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 1 | # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 | # Use of this source code is governed by a BSD-style |
| 3 | # license that can be found in the LICENSE file or at |
| 4 | # https://developers.google.com/open-source/licenses/bsd |
| 5 | |
| 6 | """Unit tests for issuelist module.""" |
| 7 | from __future__ import print_function |
| 8 | from __future__ import division |
| 9 | from __future__ import absolute_import |
| 10 | |
| 11 | import time |
| 12 | import unittest |
| 13 | |
| 14 | from framework import framework_constants |
| 15 | from framework import table_view_helpers |
| 16 | from framework import template_helpers |
| 17 | from proto import tracker_pb2 |
| 18 | from testing import fake |
| 19 | from testing import testing_helpers |
| 20 | from tracker import tablecell |
| 21 | from tracker import tracker_bizobj |
| 22 | |
| 23 | |
| 24 | class DisplayNameMock(object): |
| 25 | |
| 26 | def __init__(self, name): |
| 27 | self.display_name = name |
| 28 | self.user = None |
| 29 | |
| 30 | |
| 31 | def MakeTestIssue(local_id, issue_id, summary, status=None): |
| 32 | issue = tracker_pb2.Issue() |
| 33 | issue.local_id = local_id |
| 34 | issue.issue_id = issue_id |
| 35 | issue.summary = summary |
| 36 | if status: |
| 37 | issue.status = status |
| 38 | return issue |
| 39 | |
| 40 | |
| 41 | class TableCellUnitTest(unittest.TestCase): |
| 42 | |
| 43 | USERS_BY_ID = { |
| 44 | 23456: DisplayNameMock('Jason'), |
| 45 | 34567: DisplayNameMock('Nathan'), |
| 46 | } |
| 47 | |
| 48 | def setUp(self): |
| 49 | self.issue1 = MakeTestIssue( |
| 50 | local_id=1, issue_id=100001, summary='One', status="New") |
| 51 | self.issue2 = MakeTestIssue( |
| 52 | local_id=2, issue_id=100002, summary='Two', status="Fixed") |
| 53 | self.issue3 = MakeTestIssue( |
| 54 | local_id=3, issue_id=100003, summary='Three', status="UndefinedString") |
| 55 | self.issue5 = MakeTestIssue( |
| 56 | local_id=5, issue_id=100005, summary='FiveUnviewable', status="Fixed") |
| 57 | self.table_cell_kws = { |
| 58 | 'col': None, |
| 59 | 'users_by_id': self.USERS_BY_ID, |
| 60 | 'non_col_labels': [], |
| 61 | 'label_values': {}, |
| 62 | 'related_issues': {}, |
| 63 | 'config': tracker_bizobj.MakeDefaultProjectIssueConfig(678), |
| 64 | 'viewable_iids_set': {100001, 100002, 100003} |
| 65 | } |
| 66 | |
| 67 | def testTableCellNote(self): |
| 68 | table_cell_kws = self.table_cell_kws.copy() |
| 69 | table_cell_kws.update({'note': ''}) |
| 70 | cell = tablecell.TableCellNote( |
| 71 | self.issue1, **table_cell_kws) |
| 72 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_NOTE) |
| 73 | self.assertEqual(cell.values, []) |
| 74 | |
| 75 | def testTableCellNote_NoNote(self): |
| 76 | table_cell_kws = self.table_cell_kws.copy() |
| 77 | table_cell_kws.update({'note': 'some note'}) |
| 78 | cell = tablecell.TableCellNote( |
| 79 | self.issue1, **table_cell_kws) |
| 80 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_NOTE) |
| 81 | self.assertEqual(cell.values[0].item, 'some note') |
| 82 | |
| 83 | def testTableCellDateAdded(self): |
| 84 | table_cell_kws = self.table_cell_kws.copy() |
| 85 | table_cell_kws.update({'date_added': 1234}) |
| 86 | cell = tablecell.TableCellDateAdded( |
| 87 | self.issue1, **table_cell_kws) |
| 88 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_ATTR) |
| 89 | self.assertEqual(cell.values[0].item, 1234) |
| 90 | |
| 91 | def testTableCellAdderID(self): |
| 92 | table_cell_kws = self.table_cell_kws.copy() |
| 93 | table_cell_kws.update({'adder_id': 23456}) |
| 94 | cell = tablecell.TableCellAdderID( |
| 95 | self.issue1, **table_cell_kws) |
| 96 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_ATTR) |
| 97 | self.assertEqual(cell.values[0].item, 'Jason') |
| 98 | |
| 99 | def testTableCellRank(self): |
| 100 | table_cell_kws = self.table_cell_kws.copy() |
| 101 | table_cell_kws.update({'issue_rank': 3}) |
| 102 | cell = tablecell.TableCellRank( |
| 103 | self.issue1, **table_cell_kws) |
| 104 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_ATTR) |
| 105 | self.assertEqual(cell.values[0].item, 3) |
| 106 | |
| 107 | def testTableCellID(self): |
| 108 | cell = tablecell.TableCellID( |
| 109 | MakeTestIssue(4, 4, 'Four'), **self.table_cell_kws) |
| 110 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_ID) |
| 111 | # Note that the ID itself is accessed from the row, not the cell. |
| 112 | |
| 113 | def testTableCellOwner(self): |
| 114 | test_issue = MakeTestIssue(4, 4, 'Four') |
| 115 | test_issue.owner_id=23456 |
| 116 | |
| 117 | cell = tablecell.TableCellOwner( |
| 118 | test_issue, **self.table_cell_kws) |
| 119 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_ATTR) |
| 120 | self.assertEqual(cell.values[0].item, 'Jason') |
| 121 | |
| 122 | def testTableCellOwnerNoOwner(self): |
| 123 | test_issue = MakeTestIssue(4, 4, 'Four') |
| 124 | test_issue.owner_id=framework_constants.NO_USER_SPECIFIED |
| 125 | |
| 126 | cell = tablecell.TableCellOwner( |
| 127 | test_issue, **self.table_cell_kws) |
| 128 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_ATTR) |
| 129 | self.assertEqual(cell.values, []) |
| 130 | |
| 131 | def testTableCellReporter(self): |
| 132 | test_issue = MakeTestIssue(4, 4, 'Four') |
| 133 | test_issue.reporter_id=34567 |
| 134 | |
| 135 | cell = tablecell.TableCellReporter( |
| 136 | test_issue, **self.table_cell_kws) |
| 137 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_ATTR) |
| 138 | self.assertEqual(cell.values[0].item, 'Nathan') |
| 139 | |
| 140 | def testTableCellCc(self): |
| 141 | test_issue = MakeTestIssue(4, 4, 'Four') |
| 142 | test_issue.cc_ids = [23456, 34567] |
| 143 | |
| 144 | cell = tablecell.TableCellCc( |
| 145 | test_issue, **self.table_cell_kws) |
| 146 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_ATTR) |
| 147 | self.assertEqual(cell.values[0].item, 'Jason') |
| 148 | self.assertEqual(cell.values[1].item, 'Nathan') |
| 149 | |
| 150 | def testTableCellCcNoCcs(self): |
| 151 | cell = tablecell.TableCellCc( |
| 152 | MakeTestIssue(4, 4, 'Four'), **self.table_cell_kws) |
| 153 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_ATTR) |
| 154 | self.assertEqual(cell.values, []) |
| 155 | |
| 156 | def testTableCellAttachmentsNone(self): |
| 157 | cell = tablecell.TableCellAttachments( |
| 158 | MakeTestIssue(4, 4, 'Four'), **self.table_cell_kws) |
| 159 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_ATTR) |
| 160 | self.assertEqual(cell.values[0].item, 0) |
| 161 | |
| 162 | def testTableCellAttachments(self): |
| 163 | test_issue = MakeTestIssue(4, 4, 'Four') |
| 164 | test_issue.attachment_count = 2 |
| 165 | |
| 166 | cell = tablecell.TableCellAttachments( |
| 167 | test_issue, **self.table_cell_kws) |
| 168 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_ATTR) |
| 169 | self.assertEqual(cell.values[0].item, 2) |
| 170 | |
| 171 | def testTableCellOpened(self): |
| 172 | test_issue = MakeTestIssue(4, 4, 'Four') |
| 173 | test_issue.opened_timestamp = 1200000000 |
| 174 | |
| 175 | cell = tablecell.TableCellOpened( |
| 176 | test_issue, **self.table_cell_kws) |
| 177 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_UNFILTERABLE) |
| 178 | self.assertEqual(cell.values[0].item, 'Jan 2008') |
| 179 | |
| 180 | def testTableCellClosed(self): |
| 181 | test_issue = MakeTestIssue(4, 4, 'Four') |
| 182 | test_issue.closed_timestamp = None |
| 183 | |
| 184 | cell = tablecell.TableCellClosed( |
| 185 | test_issue, **self.table_cell_kws) |
| 186 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_UNFILTERABLE) |
| 187 | self.assertEqual(cell.values, []) |
| 188 | |
| 189 | test_issue.closed_timestamp = 1200000000 |
| 190 | cell = tablecell.TableCellClosed( |
| 191 | test_issue, **self.table_cell_kws) |
| 192 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_UNFILTERABLE) |
| 193 | self.assertEqual(cell.values[0].item, 'Jan 2008') |
| 194 | |
| 195 | def testTableCellModified(self): |
| 196 | test_issue = MakeTestIssue(4, 4, 'Four') |
| 197 | test_issue.modified_timestamp = None |
| 198 | |
| 199 | cell = tablecell.TableCellModified( |
| 200 | test_issue, **self.table_cell_kws) |
| 201 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_UNFILTERABLE) |
| 202 | self.assertEqual(cell.values, []) |
| 203 | |
| 204 | test_issue.modified_timestamp = 1200000000 |
| 205 | cell = tablecell.TableCellModified( |
| 206 | test_issue, **self.table_cell_kws) |
| 207 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_UNFILTERABLE) |
| 208 | self.assertEqual(cell.values[0].item, 'Jan 2008') |
| 209 | |
| 210 | def testTableCellOwnerLastVisit(self): |
| 211 | test_issue = MakeTestIssue(4, 4, 'Four') |
| 212 | test_issue.owner_id = None |
| 213 | |
| 214 | cell = tablecell.TableCellOwnerLastVisit( |
| 215 | test_issue, **self.table_cell_kws) |
| 216 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_UNFILTERABLE) |
| 217 | self.assertEqual(cell.values, []) |
| 218 | |
| 219 | test_issue.owner_id = 23456 |
| 220 | self.USERS_BY_ID[23456].user = testing_helpers.Blank(last_visit_timestamp=0) |
| 221 | cell = tablecell.TableCellOwnerLastVisit( |
| 222 | test_issue, **self.table_cell_kws) |
| 223 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_UNFILTERABLE) |
| 224 | self.assertEqual(cell.values, []) |
| 225 | |
| 226 | self.USERS_BY_ID[23456].user.last_visit_timestamp = int(time.time()) |
| 227 | cell = tablecell.TableCellOwnerLastVisit( |
| 228 | test_issue, **self.table_cell_kws) |
| 229 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_UNFILTERABLE) |
| 230 | self.assertEqual(cell.values[0].item, 'Today') |
| 231 | |
| 232 | self.USERS_BY_ID[23456].user.last_visit_timestamp = ( |
| 233 | int(time.time()) - 25 * framework_constants.SECS_PER_HOUR) |
| 234 | cell = tablecell.TableCellOwnerLastVisit( |
| 235 | test_issue, **self.table_cell_kws) |
| 236 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_UNFILTERABLE) |
| 237 | self.assertEqual(cell.values[0].item, 'Yesterday') |
| 238 | |
| 239 | def testTableCellBlockedOn(self): |
| 240 | test_issue = MakeTestIssue(4, 4, 'Four') |
| 241 | test_issue.blocked_on_iids = [ |
| 242 | self.issue1.issue_id, self.issue2.issue_id, self.issue3.issue_id, |
| 243 | self.issue5.issue_id] |
| 244 | table_cell_kws = self.table_cell_kws.copy() |
| 245 | table_cell_kws['related_issues'] = { |
| 246 | self.issue1.issue_id: self.issue1, self.issue2.issue_id: self.issue2, |
| 247 | self.issue3.issue_id: self.issue3, self.issue5.issue_id: self.issue5} |
| 248 | |
| 249 | cell = tablecell.TableCellBlockedOn( |
| 250 | test_issue, **table_cell_kws) |
| 251 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_ISSUES) |
| 252 | self.assertEqual( |
| 253 | [x.item for x in cell.values], [ |
| 254 | template_helpers.EZTItem( |
| 255 | href='/p/None/issues/detail?id=1', |
| 256 | id='1', |
| 257 | closed=None, |
| 258 | title='One'), |
| 259 | template_helpers.EZTItem( |
| 260 | href='/p/None/issues/detail?id=3', |
| 261 | id='3', |
| 262 | closed=None, |
| 263 | title='Three'), |
| 264 | template_helpers.EZTItem( |
| 265 | href='/p/None/issues/detail?id=5', |
| 266 | id='5', |
| 267 | closed=None, |
| 268 | title=''), |
| 269 | template_helpers.EZTItem( |
| 270 | href='/p/None/issues/detail?id=2', |
| 271 | id='2', |
| 272 | closed='yes', |
| 273 | title='Two') |
| 274 | ]) |
| 275 | |
| 276 | def testTableCellBlockedOnNone(self): |
| 277 | cell = tablecell.TableCellBlockedOn( |
| 278 | MakeTestIssue(4, 4, 'Four'), **self.table_cell_kws) |
| 279 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_ISSUES) |
| 280 | self.assertEqual(cell.values, []) |
| 281 | |
| 282 | def testTableCellBlocking(self): |
| 283 | test_issue = MakeTestIssue(4, 4, 'Four') |
| 284 | test_issue.blocking_iids = [ |
| 285 | self.issue1.issue_id, self.issue2.issue_id, self.issue3.issue_id, |
| 286 | self.issue5.issue_id] |
| 287 | table_cell_kws = self.table_cell_kws.copy() |
| 288 | table_cell_kws['related_issues'] = { |
| 289 | self.issue1.issue_id: self.issue1, self.issue2.issue_id: self.issue2, |
| 290 | self.issue3.issue_id: self.issue3, self.issue5.issue_id: self.issue5} |
| 291 | |
| 292 | cell = tablecell.TableCellBlocking( |
| 293 | test_issue, **table_cell_kws) |
| 294 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_ISSUES) |
| 295 | self.assertEqual( |
| 296 | [x.item for x in cell.values], [ |
| 297 | template_helpers.EZTItem( |
| 298 | href='/p/None/issues/detail?id=1', |
| 299 | id='1', |
| 300 | closed=None, |
| 301 | title='One'), |
| 302 | template_helpers.EZTItem( |
| 303 | href='/p/None/issues/detail?id=3', |
| 304 | id='3', |
| 305 | closed=None, |
| 306 | title='Three'), |
| 307 | template_helpers.EZTItem( |
| 308 | href='/p/None/issues/detail?id=5', |
| 309 | id='5', |
| 310 | closed=None, |
| 311 | title=''), |
| 312 | template_helpers.EZTItem( |
| 313 | href='/p/None/issues/detail?id=2', |
| 314 | id='2', |
| 315 | closed='yes', |
| 316 | title='Two') |
| 317 | ]) |
| 318 | |
| 319 | def testTableCellBlockingNone(self): |
| 320 | cell = tablecell.TableCellBlocking( |
| 321 | MakeTestIssue(4, 4, 'Four'), |
| 322 | **self.table_cell_kws) |
| 323 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_ISSUES) |
| 324 | self.assertEqual(cell.values, []) |
| 325 | |
| 326 | def testTableCellBlocked(self): |
| 327 | test_issue = MakeTestIssue(4, 4, 'Four') |
| 328 | test_issue.blocked_on_iids = [1, 2, 3] |
| 329 | |
| 330 | cell = tablecell.TableCellBlocked( |
| 331 | test_issue, **self.table_cell_kws) |
| 332 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_ATTR) |
| 333 | self.assertEqual(cell.values[0].item, 'Yes') |
| 334 | |
| 335 | def testTableCellBlockedNotBlocked(self): |
| 336 | cell = tablecell.TableCellBlocked( |
| 337 | MakeTestIssue(4, 4, 'Four'), **self.table_cell_kws) |
| 338 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_ATTR) |
| 339 | self.assertEqual(cell.values[0].item, 'No') |
| 340 | |
| 341 | def testTableCellMergedInto(self): |
| 342 | test_issue = MakeTestIssue(4, 4, 'Four') |
| 343 | test_issue.merged_into = self.issue2.issue_id |
| 344 | table_cell_kws = self.table_cell_kws.copy() |
| 345 | table_cell_kws['related_issues'] = {self.issue2.issue_id: self.issue2} |
| 346 | |
| 347 | cell = tablecell.TableCellMergedInto( |
| 348 | test_issue, **table_cell_kws) |
| 349 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_ISSUES) |
| 350 | self.assertEqual( |
| 351 | cell.values[0].item, |
| 352 | template_helpers.EZTItem( |
| 353 | href='/p/None/issues/detail?id=2', |
| 354 | id='2', |
| 355 | closed='yes', |
| 356 | title='Two')) |
| 357 | |
| 358 | def testTableCellMergedIntoUnviewable(self): |
| 359 | test_issue = MakeTestIssue(4, 4, 'Four') |
| 360 | test_issue.merged_into = self.issue5.issue_id |
| 361 | table_cell_kws = self.table_cell_kws.copy() |
| 362 | table_cell_kws['related_issues'] = {self.issue5.issue_id: self.issue5} |
| 363 | |
| 364 | cell = tablecell.TableCellMergedInto( |
| 365 | test_issue, **table_cell_kws) |
| 366 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_ISSUES) |
| 367 | self.assertEqual( |
| 368 | cell.values[0].item, |
| 369 | template_helpers.EZTItem( |
| 370 | href='/p/None/issues/detail?id=5', id='5', closed=None, title='')) |
| 371 | |
| 372 | def testTableCellMergedIntoNotMerged(self): |
| 373 | cell = tablecell.TableCellMergedInto( |
| 374 | MakeTestIssue(4, 4, 'Four'), **self.table_cell_kws) |
| 375 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_ISSUES) |
| 376 | self.assertEqual(cell.values, []) |
| 377 | |
| 378 | def testTableCellAllLabels(self): |
| 379 | labels = ['A', 'B', 'C', 'D-E', 'F-G'] |
| 380 | derived_labels = ['W', 'X', 'Y-Z'] |
| 381 | |
| 382 | test_issue = MakeTestIssue(4, 4, 'Four') |
| 383 | test_issue.labels = labels |
| 384 | test_issue.derived_labels = derived_labels |
| 385 | |
| 386 | cell = tablecell.TableCellAllLabels(test_issue) |
| 387 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_ATTR) |
| 388 | self.assertEqual([v.item for v in cell.values], labels + derived_labels) |
| 389 | |
| 390 | |
| 391 | class TableCellCSVTest(unittest.TestCase): |
| 392 | |
| 393 | USERS_BY_ID = { |
| 394 | 23456: DisplayNameMock('Jason'), |
| 395 | } |
| 396 | |
| 397 | def testTableCellOpenedTimestamp(self): |
| 398 | test_issue = MakeTestIssue(4, 4, 'Four') |
| 399 | test_issue.opened_timestamp = 1200000000 |
| 400 | |
| 401 | cell = tablecell.TableCellOpenedTimestamp(test_issue) |
| 402 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_UNFILTERABLE) |
| 403 | self.assertEqual(cell.values[0].item, 1200000000) |
| 404 | |
| 405 | def testTableCellClosedTimestamp(self): |
| 406 | test_issue = MakeTestIssue(4, 4, 'Four') |
| 407 | test_issue.closed_timestamp = None |
| 408 | |
| 409 | cell = tablecell.TableCellClosedTimestamp(test_issue) |
| 410 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_UNFILTERABLE) |
| 411 | self.assertEqual(cell.values[0].item, 0) |
| 412 | |
| 413 | test_issue.closed_timestamp = 1200000000 |
| 414 | cell = tablecell.TableCellClosedTimestamp(test_issue) |
| 415 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_UNFILTERABLE) |
| 416 | self.assertEqual(cell.values[0].item, 1200000000) |
| 417 | |
| 418 | def testTableCellModifiedTimestamp(self): |
| 419 | test_issue = MakeTestIssue(4, 4, 'Four') |
| 420 | test_issue.modified_timestamp = 0 |
| 421 | |
| 422 | cell = tablecell.TableCellModifiedTimestamp(test_issue) |
| 423 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_UNFILTERABLE) |
| 424 | self.assertEqual(cell.values[0].item, 0) |
| 425 | |
| 426 | test_issue.modified_timestamp = 1200000000 |
| 427 | cell = tablecell.TableCellModifiedTimestamp(test_issue) |
| 428 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_UNFILTERABLE) |
| 429 | self.assertEqual(cell.values[0].item, 1200000000) |
| 430 | |
| 431 | def testTableCellOwnerModifiedTimestamp(self): |
| 432 | test_issue = MakeTestIssue(4, 4, 'Four') |
| 433 | test_issue.owner_modified_timestamp = 0 |
| 434 | |
| 435 | cell = tablecell.TableCellOwnerModifiedTimestamp(test_issue) |
| 436 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_UNFILTERABLE) |
| 437 | self.assertEqual(cell.values[0].item, 0) |
| 438 | |
| 439 | test_issue.owner_modified_timestamp = 1200000000 |
| 440 | cell = tablecell.TableCellOwnerModifiedTimestamp(test_issue) |
| 441 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_UNFILTERABLE) |
| 442 | self.assertEqual(cell.values[0].item, 1200000000) |
| 443 | |
| 444 | def testTableCellStatusModifiedTimestamp(self): |
| 445 | test_issue = MakeTestIssue(4, 4, 'Four') |
| 446 | test_issue.status_modified_timestamp = 0 |
| 447 | |
| 448 | cell = tablecell.TableCellStatusModifiedTimestamp(test_issue) |
| 449 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_UNFILTERABLE) |
| 450 | self.assertEqual(cell.values[0].item, 0) |
| 451 | |
| 452 | test_issue.status_modified_timestamp = 1200000000 |
| 453 | cell = tablecell.TableCellStatusModifiedTimestamp(test_issue) |
| 454 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_UNFILTERABLE) |
| 455 | self.assertEqual(cell.values[0].item, 1200000000) |
| 456 | |
| 457 | def testTableCellComponentModifiedTimestamp(self): |
| 458 | test_issue = MakeTestIssue(4, 4, 'Four') |
| 459 | test_issue.component_modified_timestamp = 0 |
| 460 | |
| 461 | cell = tablecell.TableCellComponentModifiedTimestamp(test_issue) |
| 462 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_UNFILTERABLE) |
| 463 | self.assertEqual(cell.values[0].item, 0) |
| 464 | |
| 465 | test_issue.component_modified_timestamp = 1200000000 |
| 466 | cell = tablecell.TableCellComponentModifiedTimestamp(test_issue) |
| 467 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_UNFILTERABLE) |
| 468 | self.assertEqual(cell.values[0].item, 1200000000) |
| 469 | |
| 470 | def testTableCellOwnerLastVisitDaysAgo(self): |
| 471 | test_issue = MakeTestIssue(4, 4, 'Four') |
| 472 | test_issue.owner_id = None |
| 473 | |
| 474 | cell = tablecell.TableCellOwnerLastVisitDaysAgo( |
| 475 | test_issue, users_by_id=self.USERS_BY_ID) |
| 476 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_UNFILTERABLE) |
| 477 | self.assertEqual(None, cell.values[0].item) |
| 478 | |
| 479 | test_issue.owner_id = 23456 |
| 480 | self.USERS_BY_ID[23456].user = testing_helpers.Blank(last_visit_timestamp=0) |
| 481 | cell = tablecell.TableCellOwnerLastVisitDaysAgo( |
| 482 | test_issue, users_by_id=self.USERS_BY_ID) |
| 483 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_UNFILTERABLE) |
| 484 | self.assertEqual(None, cell.values[0].item) |
| 485 | |
| 486 | self.USERS_BY_ID[23456].user.last_visit_timestamp = ( |
| 487 | int(time.time()) - 25 * 60 * 60) |
| 488 | cell = tablecell.TableCellOwnerLastVisitDaysAgo( |
| 489 | test_issue, users_by_id=self.USERS_BY_ID) |
| 490 | self.assertEqual(cell.type, table_view_helpers.CELL_TYPE_UNFILTERABLE) |
| 491 | self.assertEqual(1, cell.values[0].item) |