MCPcopy Create free account
hub / github.com/dbcli/mssql-cli / test_file_time_check_rotation

Method test_file_time_check_rotation

tests/test_telemetry.py:103–120  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

101 self.assertIsNone(payload, 'Payload was uploaded when client opted out.')
102
103 def test_file_time_check_rotation(self):
104 test_telemetry_client = self.build_telemetry_client()
105 expired_id_file = tempfile.NamedTemporaryFile()
106 valid_id_file = tempfile.NamedTemporaryFile()
107 try:
108 st = os.stat(expired_id_file.name)
109 modified_time = st[ST_MTIME]
110 older_modified_time = modified_time - (25 * 3600)
111 # Update modified time.
112 os.utime(expired_id_file.name, (modified_time, older_modified_time))
113
114 # Verify both scenarios of a valid and expired id file.
115 # pylint: disable=protected-access
116 self.assertTrue(test_telemetry_client._user_id_file_is_old(expired_id_file.name))
117 self.assertFalse(test_telemetry_client._user_id_file_is_old(valid_id_file.name))
118 finally:
119 expired_id_file.close()
120 valid_id_file.close()
121
122
123if __name__ == u'__main__':

Callers

nothing calls this directly

Calls 2

closeMethod · 0.45

Tested by

no test coverage detected