aboutsummaryrefslogtreecommitdiff
path: root/catapult/telemetry/telemetry/internal/util/file_handle_unittest.py
blob: 28c426549b34b84de90c91ea98b44a372b781fd8 (plain)
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
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import os
import tempfile
import unittest

from telemetry.internal.util import file_handle


class FileHandleUnittest(unittest.TestCase):

  def setUp(self):
    self.temp_file_txt = tempfile.NamedTemporaryFile(
        suffix='.txt', delete=False)
    self.abs_path_html = tempfile.NamedTemporaryFile(
        suffix='.html', delete=False).name

  def tearDown(self):
    os.remove(self.abs_path_html)

  def testCreatingFileHandle(self):
    fh1 = file_handle.FromTempFile(self.temp_file_txt)
    self.assertEquals(fh1.extension, '.txt')

    fh2 = file_handle.FromFilePath(self.abs_path_html)
    self.assertEquals(fh2.extension, '.html')
    self.assertNotEquals(fh1.id, fh2.id)